tbm-utils/source/file.c
2017-07-07 15:43:52 +02:00

21 lines
266 B
C

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <file.h>
int get_file_size(size_t *size, const char *path)
{
struct stat st;
if (!size || !path)
return -1;
if (stat(path, &st) < 0)
return -1;
*size = st.st_size;
return 0;
}