Commit 90eae7175ca5e9f36a228314a88098d046608595
1 parent
91d472ac
added filesize check for GCC
Showing
1 changed file
with
8 additions
and
5 deletions
Show diff stats
stim/util/filesize.h
... | ... | @@ -3,6 +3,9 @@ |
3 | 3 | |
4 | 4 | #ifdef _WIN32 |
5 | 5 | #include <Windows.h> |
6 | +#else | |
7 | +#include <sys/types.h> | |
8 | +#include <sys/stat.h> | |
6 | 9 | #endif |
7 | 10 | |
8 | 11 | namespace stim{ |
... | ... | @@ -17,10 +20,10 @@ static size_t file_size(std::string filename){ |
17 | 20 | } |
18 | 21 | CloseHandle(hFile); |
19 | 22 | return (size_t)size.QuadPart; |
20 | -#elif | |
21 | - | |
22 | - | |
23 | - | |
23 | +#else | |
24 | + struct stat sb; | |
25 | + stat(filename.c_str(), &sb); | |
26 | + return sb.st_size; | |
24 | 27 | #endif |
25 | 28 | } |
26 | 29 | |
... | ... | @@ -28,4 +31,4 @@ static size_t file_size(std::string filename){ |
28 | 31 | |
29 | 32 | |
30 | 33 | |
31 | -#endif | |
32 | 34 | \ No newline at end of file |
35 | +#endif | ... | ... |