fixed --list command in presence of special blocks
block type RLE is special, compressed size is always 1. block type 3 is "reserved", aka not supported.
This commit is contained in:
+15
-9
@@ -994,23 +994,29 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
|
|||||||
{ int lastBlock = 0;
|
{ int lastBlock = 0;
|
||||||
do {
|
do {
|
||||||
BYTE blockHeaderBuffer[3];
|
BYTE blockHeaderBuffer[3];
|
||||||
U32 blockHeader;
|
|
||||||
int blockSize;
|
|
||||||
size_t const readBytes = fread(blockHeaderBuffer, 1, 3, srcFile);
|
size_t const readBytes = fread(blockHeaderBuffer, 1, 3, srcFile);
|
||||||
if (readBytes != 3) {
|
if (readBytes != 3) {
|
||||||
DISPLAY("There was a problem reading the block header\n");
|
DISPLAY("There was a problem reading the block header\n");
|
||||||
detectError = 1;
|
detectError = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
blockHeader = MEM_readLE24(blockHeaderBuffer);
|
{ U32 const blockHeader = MEM_readLE24(blockHeaderBuffer);
|
||||||
lastBlock = blockHeader & 1;
|
U32 const blockTypeID = (blockHeader >> 1) & 3;
|
||||||
blockSize = blockHeader >> 3; /* Warning : does not work when block is RLE type */
|
U32 const isRLE = (blockTypeID == 1);
|
||||||
{ int const ret = fseek(srcFile, blockSize, SEEK_CUR);
|
U32 const isWrongBlock = (blockTypeID == 3);
|
||||||
if (ret != 0) {
|
long const blockSize = isRLE ? 1 : (long)(blockHeader >> 3);
|
||||||
DISPLAY("Error: could not skip to end of block\n");
|
if (isWrongBlock) {
|
||||||
|
DISPLAY("Error: unsupported block type \n");
|
||||||
detectError = 1;
|
detectError = 1;
|
||||||
break;
|
break;
|
||||||
} }
|
}
|
||||||
|
lastBlock = blockHeader & 1;
|
||||||
|
{ int const ret = fseek(srcFile, blockSize, SEEK_CUR);
|
||||||
|
if (ret != 0) {
|
||||||
|
DISPLAY("Error: could not skip to end of block\n");
|
||||||
|
detectError = 1;
|
||||||
|
break;
|
||||||
|
} } }
|
||||||
} while (lastBlock != 1);
|
} while (lastBlock != 1);
|
||||||
|
|
||||||
if (detectError) break;
|
if (detectError) break;
|
||||||
|
|||||||
Reference in New Issue
Block a user