mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
changed fileInfo initialization, updated error code
This commit is contained in:
@ -867,7 +867,7 @@ typedef struct {
|
|||||||
int numActualFrames;
|
int numActualFrames;
|
||||||
int numSkippableFrames;
|
int numSkippableFrames;
|
||||||
unsigned long long decompressedSize;
|
unsigned long long decompressedSize;
|
||||||
int canComputeDecompSize;
|
int decompUnavailable;
|
||||||
unsigned long long compressedSize;
|
unsigned long long compressedSize;
|
||||||
int usesCheck;
|
int usesCheck;
|
||||||
} fileInfo_t;
|
} fileInfo_t;
|
||||||
@ -903,7 +903,7 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
if (magicNumber == ZSTD_MAGICNUMBER) {
|
if (magicNumber == ZSTD_MAGICNUMBER) {
|
||||||
U64 const frameContentSize = ZSTD_getFrameContentSize(headerBuffer, numBytesRead);
|
U64 const frameContentSize = ZSTD_getFrameContentSize(headerBuffer, numBytesRead);
|
||||||
if (frameContentSize == ZSTD_CONTENTSIZE_ERROR || frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN) {
|
if (frameContentSize == ZSTD_CONTENTSIZE_ERROR || frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN) {
|
||||||
info->canComputeDecompSize = 0;
|
info->decompUnavailable = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
info->decompressedSize += frameContentSize;
|
info->decompressedSize += frameContentSize;
|
||||||
@ -1008,7 +1008,7 @@ static void displayInfo(const char* inFileName, fileInfo_t* info, int displayLev
|
|||||||
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->decompUnavailable) {
|
||||||
double const ratio = (info->decompressedSize == 0) ? 0.0 : compressedSizeMB/decompressedSizeMB;
|
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",
|
||||||
@ -1025,7 +1025,7 @@ static void displayInfo(const char* inFileName, fileInfo_t* info, int displayLev
|
|||||||
DISPLAYOUT("# Zstandard Frames: %d\n", info->numActualFrames);
|
DISPLAYOUT("# Zstandard Frames: %d\n", info->numActualFrames);
|
||||||
DISPLAYOUT("# Skippable Frames: %d\n", info->numSkippableFrames);
|
DISPLAYOUT("# Skippable Frames: %d\n", info->numSkippableFrames);
|
||||||
DISPLAYOUT("Compressed Size: %.2f MB (%llu B)\n", compressedSizeMB, info->compressedSize);
|
DISPLAYOUT("Compressed Size: %.2f MB (%llu B)\n", compressedSizeMB, info->compressedSize);
|
||||||
if (info->canComputeDecompSize) {
|
if (!info->decompUnavailable) {
|
||||||
DISPLAYOUT("Decompressed Size: %.2f MB (%llu B)\n", decompressedSizeMB, info->decompressedSize);
|
DISPLAYOUT("Decompressed Size: %.2f MB (%llu B)\n", decompressedSizeMB, info->decompressedSize);
|
||||||
DISPLAYOUT("Ratio: %.4f\n", compressedSizeMB/decompressedSizeMB);
|
DISPLAYOUT("Ratio: %.4f\n", compressedSizeMB/decompressedSizeMB);
|
||||||
}
|
}
|
||||||
@ -1038,15 +1038,9 @@ 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;
|
|
||||||
|
|
||||||
/* initialize info to avoid warnings */
|
/* initialize info to avoid warnings */
|
||||||
info.numActualFrames = 0;
|
fileInfo_t info;
|
||||||
info.numSkippableFrames = 0;
|
memset(&info, 0, sizeof(info));
|
||||||
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);
|
||||||
|
@ -688,8 +688,8 @@ int main(int argCount, const char* argv[])
|
|||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
unsigned u;
|
unsigned u;
|
||||||
for(u=0; u<filenameIdx;u++){
|
for (u=0; u<filenameIdx;u++) {
|
||||||
error = FIO_listFile(filenameTable[u],g_displayLevel);
|
error |= FIO_listFile(filenameTable[u], g_displayLevel);
|
||||||
}
|
}
|
||||||
CLEAN_RETURN(error);
|
CLEAN_RETURN(error);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user