commit 92fb7aa573843047090b1e7cd7921eab2853f7b1
parent e27b80910239d8c6b1ffd8d3854ded45e2a320a4
Author: Frederic Cambus <fred@statdns.com>
Date: Sat, 15 Apr 2017 23:41:45 +0200
Use fstat to get the file size
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/main.c b/src/main.c
@@ -283,7 +283,11 @@ int main(int argc, char *argv[]) {
// get the file size (bytes)
struct stat input_file_stat;
- stat (input, &input_file_stat);
+
+ if (fstat(fileno(input_file), &input_file_stat)) {
+ perror("Can't stat file");
+ return 1;
+ }
size_t inputFileSize=input_file_stat.st_size;
// next up is loading our file into a dynamically allocated memory buffer