getFileSize moved to common/util.h

This commit is contained in:
inikep
2016-04-28 12:23:33 +02:00
parent 1007a1fe3d
commit 69fcd7c0ae
10 changed files with 440 additions and 462 deletions
+2 -25
View File
@@ -53,15 +53,7 @@
#include "fse_static.h"
#include "zbuff.h"
#include "datagen.h"
/*_************************************
* Compiler Options
**************************************/
/* S_ISREG & gettimeofday() are not supported by MSVC */
#if !defined(S_ISREG)
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
#endif
#include "util.h" /* UTIL_GetFileSize */
/*_************************************
@@ -135,21 +127,6 @@ static size_t BMK_findMaxMem(U64 requiredMem)
}
static U64 BMK_GetFileSize(const char* infilename)
{
int r;
#if defined(_MSC_VER)
struct _stat64 statbuf;
r = _stat64(infilename, &statbuf);
#else
struct stat statbuf;
r = stat(infilename, &statbuf);
#endif
if (r || !S_ISREG(statbuf.st_mode)) return 0; /* No good... */
return (U64)statbuf.st_size;
}
/*_*******************************************************
* Benchmark wrappers
*********************************************************/
@@ -446,7 +423,7 @@ static int benchFiles(const char** fileNamesTable, const int nbFiles, U32 benchN
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }
/* Memory allocation & restrictions */
inFileSize = BMK_GetFileSize(inFileName);
inFileSize = UTIL_getFileSize(inFileName);
benchedSize = BMK_findMaxMem(inFileSize*3) / 3;
if ((U64)benchedSize > inFileSize) benchedSize = (size_t)inFileSize;
if (benchedSize < inFileSize)