MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / load_file

Function load_file

samples/shared/lodepng.cpp:5885–5897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5883
5884#ifdef LODEPNG_COMPILE_DISK
5885void load_file(std::vector<unsigned char>& buffer, const std::string& filename)
5886{
5887 std::ifstream file(filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
5888
5889 /*get filesize*/
5890 std::streamsize size = 0;
5891 if(file.seekg(0, std::ios::end).good()) size = file.tellg();
5892 if(file.seekg(0, std::ios::beg).good()) size -= file.tellg();
5893
5894 /*read contents of the file into the vector*/
5895 buffer.resize(size_t(size));
5896 if(size > 0) file.read((char*)(&buffer[0]), size);
5897}
5898
5899/*write given buffer to the file, overwriting the file, it doesn't append to it.*/
5900void save_file(const std::vector<unsigned char>& buffer, const std::string& filename)

Callers 1

decodeFunction · 0.85

Calls 2

goodMethod · 0.80
resizeMethod · 0.80

Tested by

no test coverage detected