]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Get the file size with the available stat member
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 5 Mar 2015 14:35:03 +0000 (15:35 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 5 Mar 2015 14:35:03 +0000 (15:35 +0100)
On MinGW, the stat structure doesn't have all the member variables used to
compute the size of a file.

index.c

diff --git a/index.c b/index.c
index 675d16754bbf3628a90b74cb69d7b81757f93e1f..bed6f5b044e4b778fc62670702760e56f967bd5f 100644 (file)
--- a/index.c
+++ b/index.c
@@ -107,6 +107,7 @@ void make_index(void)
  */
 static long long int get_file_size(struct stat *statb)
 {
+#ifdef __linux__
        long long int blocks;
 
        //return(statb->st_size);//the size of the file content
@@ -114,6 +115,9 @@ static long long int get_file_size(struct stat *statb)
        if (statb->st_blksize==0) return(statb->st_size);
        blocks=(statb->st_size+statb->st_blksize-1)/statb->st_blksize;
        return(blocks*statb->st_blksize);//how many bytes occupied on disk
+#else
+       return(statb->st_size);
+#endif
 }
 
 /*!