MCPcopy Create free account
hub / github.com/comaps/comaps / loadFile

Function loadFile

libs/coding/coding_tests/png_decoder_test.cpp:9–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace std;
8
9void loadFile(vector<unsigned char> & buffer,
10 string const & filename) // designed for loading files from hard disk in an std::vector
11{
12 ifstream file(filename.c_str(), ios::in | ios::binary | ios::ate);
13
14 // get filesize
15 streamsize size = 0;
16 if (file.seekg(0, ios::end).good())
17 size = file.tellg();
18 if (file.seekg(0, ios::beg).good())
19 size -= file.tellg();
20
21 // read contents of the file into the vector
22 if (size > 0)
23 {
24 buffer.resize((size_t)size);
25 file.read((char *)(&buffer[0]), size);
26 }
27 else
28 buffer.clear();
29}
30
31UNIT_TEST(PngDecode)
32{

Callers

nothing calls this directly

Calls 3

resizeMethod · 0.45
readMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected