私はLZMAです-以前lzma e <infile> <outfile> -lc0 -lp2
にターミナルから使用して圧縮し、プロジェクトにインポートしたリソースファイルを解凍します。ただし、このファイルに適用すると、最初の反復でLzmaDec_DecodeToBuf
返されます。つまり、LZMAデータエラーです。1
(また、いつまでに、inLen
は常にです。)5
outLen
0
何故ですか?
私のコードは次のとおりです。
SRes static decompress(FILE *inFile, FILE *outFile)
{
// Position the inFile pointer at the start.
fseek(inFile, 0, SEEK_SET);
// Read in LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header.
char unsigned header[LZMA_PROPS_SIZE+8];
fgets(header, sizeof(header), inFile);
CLzmaDec state;
LzmaDec_Construct(&state);
SRes res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &SzAllocForLzma);
if (res != SZ_OK) {
// Free all allocated structures.
LzmaDec_Free(&state, &SzAllocForLzma);
return res;
}
char unsigned inBuf[IN_BUF_SIZE];
char unsigned outBuf[OUT_BUF_SIZE];
LzmaDec_Init(&state);
ELzmaStatus status;
long unsigned outLen = sizeof(outBuf);
long unsigned inLen = sizeof(inBuf);
long unsigned inPos = ftell(inFile);
while (fgets(inBuf, sizeof(inBuf), inFile) != NULL) {
inLen = MIN(sizeof(inBuf), MAX(ftell(inFile)-inPos, 0));
outLen = sizeof(outBuf);
SRes res = LzmaDec_DecodeToBuf(&state,
outBuf,
&outLen,
inBuf,
&inLen,
LZMA_FINISH_ANY,
&status);
// continues...