Merge pull request #2929

ae55bacd resumption support for updates using range requests (moneromooo-monero)
fe0fae50 epee: add a get_file_size function (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-12-25 21:20:22 +02:00
commit b38f6dcf0b
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
3 changed files with 104 additions and 12 deletions

View file

@ -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;
}
}
}
}