MCPcopy Create free account
hub / github.com/DFHack/dfhack / lodepng_filesize

Function lodepng_filesize

depends/lodepng/lodepng.cpp:345–362  ·  view source on GitHub ↗

returns negative value on error. This should be pure C compatible, so no fstat. */

Source from the content-addressed store, hash-verified

343
344/* returns negative value on error. This should be pure C compatible, so no fstat. */
345static long lodepng_filesize(const char* filename) {
346 FILE* file;
347 long size;
348 file = fopen(filename, "rb");
349 if(!file) return -1;
350
351 if(fseek(file, 0, SEEK_END) != 0) {
352 fclose(file);
353 return -1;
354 }
355
356 size = ftell(file);
357 /* It may give LONG_MAX as directory size, this is invalid for us. */
358 if(size == LONG_MAX) size = -1;
359
360 fclose(file);
361 return size;
362}
363
364/* load file into buffer that already has the correct allocated size. Returns error code.*/
365static unsigned lodepng_buffer_file(unsigned char* out, size_t size, const char* filename) {

Callers 2

lodepng_load_fileFunction · 0.85
load_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected