getTotalFileSize moved to common/util.h

dev
inikep 2016-04-28 16:50:13 +02:00
parent d5ff2c3d9a
commit 55d047aa92
3 changed files with 13 additions and 21 deletions

View File

@ -138,6 +138,16 @@ UTIL_STATIC U64 UTIL_getFileSize(const char* infilename)
} }
UTIL_STATIC U64 UTIL_getTotalFileSize(const char** fileNamesTable, unsigned nbFiles)
{
U64 total = 0;
unsigned n;
for (n=0; n<nbFiles; n++)
total += UTIL_getFileSize(fileNamesTable[n]);
return total;
}
UTIL_STATIC U32 UTIL_isDirectory(const char* infilename) UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
{ {
int r; int r;

View File

@ -44,11 +44,11 @@
/* ************************************* /* *************************************
* Includes * Includes
***************************************/ ***************************************/
#include "util.h" /* UTIL_GetFileSize */
#include <stdlib.h> /* malloc, free */ #include <stdlib.h> /* malloc, free */
#include <string.h> /* memset */ #include <string.h> /* memset */
#include <stdio.h> /* fprintf, fopen, ftello64 */ #include <stdio.h> /* fprintf, fopen, ftello64 */
#include "util.h" /* UTIL_GetFileSize */
#include "mem.h" #include "mem.h"
#include "zstd_static.h" #include "zstd_static.h"
#include "datagen.h" /* RDG_genBuffer */ #include "datagen.h" /* RDG_genBuffer */
@ -421,14 +421,6 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
} }
} }
static U64 BMK_getTotalFileSize(const char** fileNamesTable, unsigned nbFiles)
{
U64 total = 0;
unsigned n;
for (n=0; n<nbFiles; n++)
total += UTIL_getFileSize(fileNamesTable[n]);
return total;
}
/*! BMK_loadFiles() : /*! BMK_loadFiles() :
Loads `buffer` with content of files listed within `fileNamesTable`. Loads `buffer` with content of files listed within `fileNamesTable`.
@ -469,7 +461,7 @@ static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles,
void* dictBuffer = NULL; void* dictBuffer = NULL;
size_t dictBufferSize = 0; size_t dictBufferSize = 0;
size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t)); size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t));
U64 totalSizeToLoad = BMK_getTotalFileSize(fileNamesTable, nbFiles); U64 totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles);
char mfName[20] = {0}; char mfName[20] = {0};
const char* displayName = NULL; const char* displayName = NULL;

View File

@ -105,16 +105,6 @@ const char* DiB_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCo
/* ******************************************************** /* ********************************************************
* File related operations * File related operations
**********************************************************/ **********************************************************/
static unsigned long long DiB_getTotalFileSize(const char** fileNamesTable, unsigned nbFiles)
{
unsigned long long total = 0;
unsigned n;
for (n=0; n<nbFiles; n++)
total += UTIL_getFileSize(fileNamesTable[n]);
return total;
}
static void DiB_loadFiles(void* buffer, size_t bufferSize, static void DiB_loadFiles(void* buffer, size_t bufferSize,
size_t* fileSizes, size_t* fileSizes,
const char** fileNamesTable, unsigned nbFiles) const char** fileNamesTable, unsigned nbFiles)
@ -209,7 +199,7 @@ int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
void* srcBuffer; void* srcBuffer;
size_t benchedSize; size_t benchedSize;
size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t)); size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t));
unsigned long long totalSizeToLoad = DiB_getTotalFileSize(fileNamesTable, nbFiles); unsigned long long totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles);
void* dictBuffer = malloc(maxDictSize); void* dictBuffer = malloc(maxDictSize);
size_t dictSize; size_t dictSize;
int result = 0; int result = 0;