私は先に端末からlzma e <infile> <outfile> -lc0 -lp2
を使用して圧縮したリソースファイルをLZMA解凍してプロジェクトにインポートしました。しかし、このファイルに適用すると、LzmaDec_DecodeToBuf
は最初の反復で1
、つまりLZMAデータエラーを返します。 (また、inLen
はいつも5
です。は0
です)スタティックLZMA圧縮ファイルをプログラムで圧縮解除する
なぜですか?
私のコードを読み取ります
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...
クリスタルボール曇り。デバッグを試して、どこがうまくいかないかを見てください。しかし、すべての深刻さで、これはインターネットデバッグを試みるのは非常に難しい問題です。おそらくあなたは欠落しているか、データにヘッダーを追加していますか?おそらくあなたはごみを渡していますか?たぶんあなたはそのデータのいくつかを偶然ぶつかったでしょう。デバッグはあなたを正しい方向に向けるかもしれませんが、私はあなたに運が欲しいです。 –