aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-12-25 21:20:22 +0200
committerRiccardo Spagni <ric@spagni.net>2017-12-25 21:20:22 +0200
commitb38f6dcf0bfce873f554746e31b0063ed6a5300d (patch)
treefb509202d6ee414b4d24dc2ff01b682e55dbcaf7 /contrib
parentMerge pull request #2928 (diff)
parentresumption support for updates using range requests (diff)
downloadmonero-b38f6dcf0bfce873f554746e31b0063ed6a5300d.tar.xz
Merge pull request #2929
ae55bacd resumption support for updates using range requests (moneromooo-monero) fe0fae50 epee: add a get_file_size function (moneromooo-monero)
Diffstat (limited to 'contrib')
-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 f037b4dd5..989d16fba 100644
--- a/contrib/epee/include/file_io_utils.h
+++ b/contrib/epee/include/file_io_utils.h
@@ -133,6 +133,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;
+ }
+ }
+
}
}