use boost::filesystem::file_size() to get the file size (instead of seeking the file).
This commit is contained in:
parent
d8d9ac8686
commit
62c8b70f78
11
include/storage/io.hpp
Normal file → Executable file
11
include/storage/io.hpp
Normal file → Executable file
@ -10,6 +10,7 @@
|
|||||||
#include "util/log.hpp"
|
#include "util/log.hpp"
|
||||||
#include "util/version.hpp"
|
#include "util/version.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/iostreams/device/array.hpp>
|
#include <boost/iostreams/device/array.hpp>
|
||||||
#include <boost/iostreams/seek.hpp>
|
#include <boost/iostreams/seek.hpp>
|
||||||
@ -60,6 +61,15 @@ class FileReader
|
|||||||
|
|
||||||
std::size_t GetSize()
|
std::size_t GetSize()
|
||||||
{
|
{
|
||||||
|
const boost::filesystem::path path(filepath);
|
||||||
|
try {
|
||||||
|
return std::size_t(boost::filesystem::file_size(path)) - ((fingerprint == FingerprintFlag::VerifyFingerprint) ? sizeof(util::FingerPrint) : 0);
|
||||||
|
}
|
||||||
|
catch (boost::filesystem::filesystem_error& ex) {
|
||||||
|
std::cout << ex.what() << std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
/*
|
||||||
const boost::filesystem::ifstream::pos_type position = input_stream.tellg();
|
const boost::filesystem::ifstream::pos_type position = input_stream.tellg();
|
||||||
input_stream.seekg(0, std::ios::end);
|
input_stream.seekg(0, std::ios::end);
|
||||||
const boost::filesystem::ifstream::pos_type file_size = input_stream.tellg();
|
const boost::filesystem::ifstream::pos_type file_size = input_stream.tellg();
|
||||||
@ -84,6 +94,7 @@ class FileReader
|
|||||||
{
|
{
|
||||||
return file_size;
|
return file_size;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read count objects of type T into pointer dest */
|
/* Read count objects of type T into pointer dest */
|
||||||
|
Loading…
Reference in New Issue
Block a user