! BMK_loadFiles() : Loads `buffer` with content of files listed within `fileNamesTable`. At most, fills `buffer` entirely */
| 675 | Loads `buffer` with content of files listed within `fileNamesTable`. |
| 676 | At most, fills `buffer` entirely */ |
| 677 | static void BMK_loadFiles(void* buffer, size_t bufferSize, |
| 678 | size_t* fileSizes, |
| 679 | const char** fileNamesTable, unsigned nbFiles) |
| 680 | { |
| 681 | size_t pos = 0, totalSize = 0; |
| 682 | unsigned n; |
| 683 | for (n=0; n<nbFiles; n++) { |
| 684 | FILE* f; |
| 685 | U64 fileSize = UTIL_getFileSize(fileNamesTable[n]); |
| 686 | if (UTIL_isDirectory(fileNamesTable[n])) { |
| 687 | DISPLAYLEVEL(2, "Ignoring %s directory... \n", fileNamesTable[n]); |
| 688 | fileSizes[n] = 0; |
| 689 | continue; |
| 690 | } |
| 691 | if (fileSize == UTIL_FILESIZE_UNKNOWN) { |
| 692 | DISPLAYLEVEL(2, "Cannot determine size of %s ... \n", fileNamesTable[n]); |
| 693 | fileSizes[n] = 0; |
| 694 | continue; |
| 695 | } |
| 696 | f = fopen(fileNamesTable[n], "rb"); |
| 697 | if (f==NULL) EXM_THROW(10, "impossible to open file %s", fileNamesTable[n]); |
| 698 | DISPLAYUPDATE(2, "Loading %s... \r", fileNamesTable[n]); |
| 699 | if (fileSize > bufferSize-pos) fileSize = bufferSize-pos, nbFiles=n; /* buffer too small - stop after this file */ |
| 700 | { size_t const readSize = fread(((char*)buffer)+pos, 1, (size_t)fileSize, f); |
| 701 | if (readSize != (size_t)fileSize) EXM_THROW(11, "could not read %s", fileNamesTable[n]); |
| 702 | pos += readSize; } |
| 703 | fileSizes[n] = (size_t)fileSize; |
| 704 | totalSize += (size_t)fileSize; |
| 705 | fclose(f); |
| 706 | } |
| 707 | |
| 708 | if (totalSize == 0) EXM_THROW(12, "no data to bench"); |
| 709 | } |
| 710 | |
| 711 | static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles, |
| 712 | const char* dictFileName, int cLevel, int cLevelLast) |
no test coverage detected