Merge branch 'list' into dev
This commit is contained in:
commit
3a5cead6aa
@ -874,7 +874,7 @@ typedef struct {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads information from file, stores in *info
|
* Reads information from file, stores in *info
|
||||||
* if successful, returns 0, otherwise returns 1
|
* if successful, returns 0, returns 1 for frame analysis error, returns 2 for file not compressed with zstd
|
||||||
*/
|
*/
|
||||||
static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
||||||
int detectError = 0;
|
int detectError = 0;
|
||||||
@ -884,16 +884,12 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
info->compressedSize = (unsigned long long)UTIL_getFileSize(inFileName);
|
info->compressedSize = (unsigned long long)UTIL_getFileSize(inFileName);
|
||||||
info->decompressedSize = 0;
|
|
||||||
info->numActualFrames = 0;
|
|
||||||
info->numSkippableFrames = 0;
|
|
||||||
info->canComputeDecompSize = 1;
|
|
||||||
/* begin analyzing frame */
|
/* begin analyzing frame */
|
||||||
for( ; ; ){
|
for( ; ; ){
|
||||||
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
||||||
size_t const numBytesRead = fread(headerBuffer, 1, sizeof(headerBuffer), srcFile);
|
size_t const numBytesRead = fread(headerBuffer, 1, sizeof(headerBuffer), srcFile);
|
||||||
if (numBytesRead < ZSTD_frameHeaderSize_min) {
|
if (numBytesRead < ZSTD_frameHeaderSize_min) {
|
||||||
if(feof(srcFile)){
|
if (feof(srcFile)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -981,7 +977,7 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
}
|
}
|
||||||
else if (magicNumber == ZSTD_MAGIC_SKIPPABLE_START) {
|
else if (magicNumber == ZSTD_MAGIC_SKIPPABLE_START) {
|
||||||
BYTE frameSizeBuffer[4];
|
BYTE frameSizeBuffer[4];
|
||||||
size_t readBytes = fread(frameSizeBuffer, 1, 4, srcFile);
|
size_t const readBytes = fread(frameSizeBuffer, 1, 4, srcFile);
|
||||||
if (readBytes != 4) {
|
if (readBytes != 4) {
|
||||||
DISPLAY("There was an error reading skippable frame size");
|
DISPLAY("There was an error reading skippable frame size");
|
||||||
detectError = 1;
|
detectError = 1;
|
||||||
@ -998,6 +994,10 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
}
|
}
|
||||||
info->numSkippableFrames++;
|
info->numSkippableFrames++;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
detectError = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(srcFile);
|
fclose(srcFile);
|
||||||
@ -1008,12 +1008,13 @@ static void displayInfo(const char* inFileName, fileInfo_t* info, int displayLev
|
|||||||
double const compressedSizeMB = (double)info->compressedSize/(1 MB);
|
double const compressedSizeMB = (double)info->compressedSize/(1 MB);
|
||||||
double const decompressedSizeMB = (double)info->decompressedSize/(1 MB);
|
double const decompressedSizeMB = (double)info->decompressedSize/(1 MB);
|
||||||
const char* checkString = (info->usesCheck ? "XXH64" : "None");
|
const char* checkString = (info->usesCheck ? "XXH64" : "None");
|
||||||
if(displayLevel<=2){
|
if (displayLevel <= 2) {
|
||||||
if (info->canComputeDecompSize) {
|
if (info->canComputeDecompSize) {
|
||||||
|
double const ratio = (info->decompressedSize == 0) ? 0.0 : compressedSizeMB/decompressedSizeMB;
|
||||||
DISPLAYOUT("Skippable Non-Skippable Compressed Uncompressed Ratio Check Filename\n");
|
DISPLAYOUT("Skippable Non-Skippable Compressed Uncompressed Ratio Check Filename\n");
|
||||||
DISPLAYOUT("%9d %13d %7.2f MB %9.2f MB %5.3f %s %s\n",
|
DISPLAYOUT("%9d %13d %7.2f MB %9.2f MB %5.3f %s %s\n",
|
||||||
info->numSkippableFrames, info->numActualFrames, compressedSizeMB, decompressedSizeMB,
|
info->numSkippableFrames, info->numActualFrames, compressedSizeMB, decompressedSizeMB,
|
||||||
compressedSizeMB/decompressedSizeMB, checkString, inFileName);
|
ratio, checkString, inFileName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DISPLAYOUT("Skippable Non-Skippable Compressed Check Filename\n");
|
DISPLAYOUT("Skippable Non-Skippable Compressed Check Filename\n");
|
||||||
@ -1039,16 +1040,28 @@ static void displayInfo(const char* inFileName, fileInfo_t* info, int displayLev
|
|||||||
|
|
||||||
int FIO_listFile(const char* inFileName, int displayLevel){
|
int FIO_listFile(const char* inFileName, int displayLevel){
|
||||||
fileInfo_t info;
|
fileInfo_t info;
|
||||||
|
|
||||||
|
/* initialize info to avoid warnings */
|
||||||
|
info.numActualFrames = 0;
|
||||||
|
info.numSkippableFrames = 0;
|
||||||
|
info.decompressedSize = 0;
|
||||||
|
info.canComputeDecompSize = 1;
|
||||||
|
info.compressedSize = 0;
|
||||||
|
info.usesCheck = 0;
|
||||||
DISPLAYOUT("File: %s\n", inFileName);
|
DISPLAYOUT("File: %s\n", inFileName);
|
||||||
{
|
{
|
||||||
int const error = getFileInfo(&info, inFileName);
|
int const error = getFileInfo(&info, inFileName);
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
|
/* display error, but provide output */
|
||||||
DISPLAY("An error occurred with getting file info\n");
|
DISPLAY("An error occurred with getting file info\n");
|
||||||
|
}
|
||||||
|
else if (error == 2) {
|
||||||
|
DISPLAYOUT("File %s not compressed with zstd\n\n", inFileName);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
displayInfo(inFileName, &info, displayLevel);
|
displayInfo(inFileName, &info, displayLevel);
|
||||||
return 0;
|
return error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIO_compressMultipleFilenames(const char** inFileNamesTable, unsigned nbFiles,
|
int FIO_compressMultipleFilenames(const char** inFileNamesTable, unsigned nbFiles,
|
||||||
|
@ -675,7 +675,7 @@ int main(int argCount, const char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(operation==zom_list){
|
if (operation == zom_list) {
|
||||||
g_displayOut = stdout;
|
g_displayOut = stdout;
|
||||||
if(filenameIdx==0){
|
if(filenameIdx==0){
|
||||||
DISPLAY("No files given\n");
|
DISPLAY("No files given\n");
|
||||||
@ -686,12 +686,13 @@ int main(int argCount, const char* argv[])
|
|||||||
DISPLAY("===========================================\n");
|
DISPLAY("===========================================\n");
|
||||||
DISPLAY("Number of files listed: %d\n", filenameIdx);
|
DISPLAY("Number of files listed: %d\n", filenameIdx);
|
||||||
{
|
{
|
||||||
|
int error = 0;
|
||||||
unsigned u;
|
unsigned u;
|
||||||
for(u=0; u<filenameIdx;u++){
|
for(u=0; u<filenameIdx;u++){
|
||||||
FIO_listFile(filenameTable[u],g_displayLevel);
|
error = FIO_listFile(filenameTable[u],g_displayLevel);
|
||||||
}
|
}
|
||||||
|
CLEAN_RETURN(error);
|
||||||
}
|
}
|
||||||
CLEAN_RETURN(0);
|
|
||||||
}
|
}
|
||||||
/* Check if benchmark is selected */
|
/* Check if benchmark is selected */
|
||||||
if (operation==zom_bench) {
|
if (operation==zom_bench) {
|
||||||
|
@ -537,6 +537,29 @@ fi
|
|||||||
|
|
||||||
rm tmp*
|
rm tmp*
|
||||||
|
|
||||||
|
$ECHO "\n**** zstd --list/-l single frame tests ****"
|
||||||
|
./datagen > tmp1
|
||||||
|
./datagen > tmp2
|
||||||
|
./datagen > tmp3
|
||||||
|
./datagen > tmp4
|
||||||
|
$ZSTD tmp*
|
||||||
|
$ZSTD -l tmp*
|
||||||
|
$ZSTD -lv tmp*
|
||||||
|
$ZSTD --list tmp*
|
||||||
|
$ZSTD --list -v tmp*
|
||||||
|
|
||||||
|
$ECHO "\n**** zstd --list/-l multiple frame tests ****"
|
||||||
|
cat tmp1.zst tmp2.zst > tmp12.zst
|
||||||
|
cat tmp3.zst tmp4.zst > tmp34.zst
|
||||||
|
cat tmp12.zst tmp34.zst > tmp1234.zst
|
||||||
|
cat tmp12.zst tmp4.zst > tmp124.zst
|
||||||
|
$ZSTD -l tmp*
|
||||||
|
$ZSTD -lv tmp*
|
||||||
|
$ZSTD --list tmp*
|
||||||
|
$ZSTD --list -v tmp*
|
||||||
|
|
||||||
|
rm tmp*
|
||||||
|
|
||||||
if [ "$1" != "--test-large-data" ]; then
|
if [ "$1" != "--test-large-data" ]; then
|
||||||
$ECHO "Skipping large data tests"
|
$ECHO "Skipping large data tests"
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user