MCPcopy Create free account
hub / github.com/TheHPXProject/hpx / file_wrapper

Method file_wrapper

examples/quickstart/file_serialization.cpp:23–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21struct file_wrapper
22{
23 file_wrapper(std::string const& name, std::ios_base::openmode mode)
24 : stream_(name.c_str(), mode)
25 , mode_(mode)
26 {
27 if (!stream_.is_open())
28 throw std::runtime_error("Couldn't open file: " + name);
29
30 std::fstream::pos_type fsize = stream_.tellg();
31 stream_.seekg(0, std::ios::end);
32 data_.resize(stream_.tellg() - fsize);
33 stream_.seekg(fsize, std::ios::beg);
34
35 if (mode & std::ios_base::in)
36 {
37 stream_.read(data_.data(), data_.size());
38 }
39 }
40
41 ~file_wrapper()
42 {

Callers

nothing calls this directly

Calls 4

resizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected