MCPcopy Create free account
hub / github.com/creatale/node-dv / lodepng_filesize

Function lodepng_filesize

deps/lodepng/lodepng.cpp:359–378  ·  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

357
358/* returns negative value on error. This should be pure C compatible, so no fstat. */
359static long lodepng_filesize(const char* filename)
360{
361 FILE* file;
362 long size;
363 file = fopen(filename, "rb");
364 if(!file) return -1;
365
366 if(fseek(file, 0, SEEK_END) != 0)
367 {
368 fclose(file);
369 return -1;
370 }
371
372 size = ftell(file);
373 /* It may give LONG_MAX as directory size, this is invalid for us. */
374 if(size == LONG_MAX) size = -1;
375
376 fclose(file);
377 return size;
378}
379
380/* load file into buffer that already has the correct allocated size. Returns error code.*/
381static 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