mirror of
https://github.com/facebook/zstd.git
synced 2025-10-09 00:05:28 -04:00
rearranging code to allow for consts
This commit is contained in:
parent
e49afae2ab
commit
0757eae6ff
@ -877,6 +877,7 @@ typedef struct {
|
|||||||
* if successful, returns 0, otherwise returns 1
|
* if successful, returns 0, otherwise returns 1
|
||||||
*/
|
*/
|
||||||
static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
||||||
|
int detectError = 0;
|
||||||
FILE* const srcFile = FIO_openSrcFile(inFileName);
|
FILE* const srcFile = FIO_openSrcFile(inFileName);
|
||||||
if (srcFile == NULL) {
|
if (srcFile == NULL) {
|
||||||
DISPLAY("Error: could not open source file %s\n", inFileName);
|
DISPLAY("Error: could not open source file %s\n", inFileName);
|
||||||
@ -887,7 +888,6 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
info->numActualFrames = 0;
|
info->numActualFrames = 0;
|
||||||
info->numSkippableFrames = 0;
|
info->numSkippableFrames = 0;
|
||||||
info->canComputeDecompSize = 1;
|
info->canComputeDecompSize = 1;
|
||||||
int detectError = 0;
|
|
||||||
/* begin analyzing frame */
|
/* begin analyzing frame */
|
||||||
for( ; ; ){
|
for( ; ; ){
|
||||||
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
||||||
@ -902,6 +902,7 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
U32 const magicNumber = MEM_readLE32(headerBuffer);
|
U32 const magicNumber = MEM_readLE32(headerBuffer);
|
||||||
if (magicNumber == ZSTD_MAGICNUMBER) {
|
if (magicNumber == ZSTD_MAGICNUMBER) {
|
||||||
U64 const frameContentSize = ZSTD_getFrameContentSize(headerBuffer, numBytesRead);
|
U64 const frameContentSize = ZSTD_getFrameContentSize(headerBuffer, numBytesRead);
|
||||||
@ -911,15 +912,14 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
else {
|
else {
|
||||||
info->decompressedSize += frameContentSize;
|
info->decompressedSize += frameContentSize;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
/* move to the end of the frame header */
|
||||||
size_t const headerSize = ZSTD_frameHeaderSize(headerBuffer, numBytesRead);
|
size_t const headerSize = ZSTD_frameHeaderSize(headerBuffer, numBytesRead);
|
||||||
if (ZSTD_isError(headerSize)) {
|
if (ZSTD_isError(headerSize)) {
|
||||||
DISPLAY("Error: could not determine frame header size\n");
|
DISPLAY("Error: could not determine frame header size\n");
|
||||||
detectError = 1;
|
detectError = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
/* move to the end of the frame header */
|
|
||||||
int const ret = fseek(srcFile, ((long)headerSize)-((long)numBytesRead), SEEK_CUR);
|
int const ret = fseek(srcFile, ((long)headerSize)-((long)numBytesRead), SEEK_CUR);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DISPLAY("Error: could not move to end of frame header\n");
|
DISPLAY("Error: could not move to end of frame header\n");
|
||||||
@ -985,8 +985,8 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
detectError = 1;
|
detectError = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long const frameSize = MEM_readLE32(frameSizeBuffer);
|
|
||||||
{
|
{
|
||||||
|
long const frameSize = MEM_readLE32(frameSizeBuffer);
|
||||||
int const ret = fseek(srcFile, frameSize, SEEK_CUR);
|
int const ret = fseek(srcFile, frameSize, SEEK_CUR);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DISPLAY("Error: could not find end of skippable frame\n");
|
DISPLAY("Error: could not find end of skippable frame\n");
|
||||||
@ -994,10 +994,10 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fseek(srcFile, frameSize, SEEK_CUR);
|
|
||||||
info->numSkippableFrames++;
|
info->numSkippableFrames++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fclose(srcFile);
|
fclose(srcFile);
|
||||||
return detectError;
|
return detectError;
|
||||||
}
|
}
|
||||||
@ -1036,8 +1036,8 @@ 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){
|
||||||
DISPLAYOUT("File: %s\n", inFileName);
|
|
||||||
fileInfo_t info;
|
fileInfo_t info;
|
||||||
|
DISPLAYOUT("File: %s\n", inFileName);
|
||||||
int const error = getFileInfo(&info, inFileName);
|
int const error = getFileInfo(&info, inFileName);
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
DISPLAY("An error occurred with getting file info\n");
|
DISPLAY("An error occurred with getting file info\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user