MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / lodepng_filesize

Function lodepng_filesize

dependency/densecrf/examples/lodepng.cpp:351–370  ·  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

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