aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-15 10:26:18 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-15 10:32:36 +0000
commitfe0fae5089a66bd69221dbb899cf6ad6c76d7a26 (patch)
tree6d1bf55c810d01b6cdc9cc38ddf0eef26bfa105c /contrib/epee
parentMerge pull request #2906 (diff)
downloadmonero-fe0fae5089a66bd69221dbb899cf6ad6c76d7a26.tar.xz
epee: add a get_file_size function
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/file_io_utils.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h
index c387743a6..4d85a724d 100644
--- a/contrib/epee/include/file_io_utils.h
+++ b/contrib/epee/include/file_io_utils.h
@@ -132,6 +132,26 @@ namespace file_io_utils
return false;
}
}
+
+ inline
+ bool get_file_size(const std::string& path_to_file, uint64_t &size)
+ {
+ try
+ {
+ std::ifstream fstream;
+ fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
+ fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
+ size = fstream.tellg();
+ fstream.close();
+ return true;
+ }
+
+ catch(...)
+ {
+ return false;
+ }
+ }
+
}
}