1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-05 20:26:46 +02:00

more succinct way to get file sizes

This commit is contained in:
Jfreegman
2014-09-24 00:06:02 -04:00
parent b071a9e992
commit 893e88294b
6 changed files with 18 additions and 43 deletions

View File

@ -311,3 +311,14 @@ bool file_exists(const char *path)
struct stat s;
return stat(path, &s) == 0;
}
/* returns file size or -1 on error */
uint64_t file_size(const char *path)
{
struct stat st;
if (stat(path, &st) == -1)
return -1;
return (uint64_t) st.st_size;
}