MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / load_file

Function load_file

src/lodepng.cpp:6041–6053  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6039
6040#ifdef LODEPNG_COMPILE_DISK
6041void load_file(std::vector<unsigned char>& buffer, const std::string& filename)
6042{
6043 std::ifstream file(filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
6044
6045 /*get filesize*/
6046 std::streamsize size = 0;
6047 if(file.seekg(0, std::ios::end).good()) size = file.tellg();
6048 if(file.seekg(0, std::ios::beg).good()) size -= file.tellg();
6049
6050 /*read contents of the file into the vector*/
6051 buffer.resize(size_t(size));
6052 if(size > 0) file.read((char*)(&buffer[0]), size);
6053}
6054
6055/*write given buffer to the file, overwriting the file, it doesn't append to it.*/
6056void save_file(const std::vector<unsigned char>& buffer, const std::string& filename)

Callers 1

decodeFunction · 0.85

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected