Remember decompression state during extraction, so as to avoid
unnecessary work.
This commit is contained in:
parent
9e2b15da17
commit
b8675b4312
|
@ -234,7 +234,7 @@ char *FDI_read_string(HFDI hfdi, INT_PTR hf, long cabsize)
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (len == maxlen) {
|
if (len == maxlen) {
|
||||||
ERR("WARNING: cabinet is truncated\n");
|
ERR("cabinet is truncated\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len += 256;
|
len += 256;
|
||||||
|
@ -2216,6 +2216,7 @@ BOOL __cdecl FDICopy(
|
||||||
if (filehf) {
|
if (filehf) {
|
||||||
cab_UWORD comptype = fol->comp_type;
|
cab_UWORD comptype = fol->comp_type;
|
||||||
int ct1 = comptype & cffoldCOMPTYPE_MASK;
|
int ct1 = comptype & cffoldCOMPTYPE_MASK;
|
||||||
|
int ct2 = CAB(current) ? (CAB(current)->comp_type & cffoldCOMPTYPE_MASK) : 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
TRACE("Extracting file %s as requested by callee.\n", debugstr_a(file->filename));
|
TRACE("Extracting file %s as requested by callee.\n", debugstr_a(file->filename));
|
||||||
|
@ -2224,11 +2225,35 @@ BOOL __cdecl FDICopy(
|
||||||
CAB(hfdi) = hfdi;
|
CAB(hfdi) = hfdi;
|
||||||
CAB(filehf) = filehf;
|
CAB(filehf) = filehf;
|
||||||
CAB(cabhf) = cabhf;
|
CAB(cabhf) = cabhf;
|
||||||
CAB(current) = fol;
|
|
||||||
CAB(decomp_cab) = NULL;
|
|
||||||
|
|
||||||
/* set up the appropriate decompressor */
|
/* Was there a change of folder? Compression type? Did we somehow go backwards? */
|
||||||
switch (ct1) {
|
if ((ct1 != ct2) || (CAB(current) != fol) || (file->offset < CAB(offset))) {
|
||||||
|
|
||||||
|
TRACE("Resetting folder for file %s.\n", debugstr_a(file->filename));
|
||||||
|
|
||||||
|
/* free stuff for the old decompressor */
|
||||||
|
switch (ct2) {
|
||||||
|
case cffoldCOMPTYPE_LZX:
|
||||||
|
if (LZX(window)) {
|
||||||
|
PFDI_FREE(hfdi, LZX(window));
|
||||||
|
LZX(window) = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case cffoldCOMPTYPE_QUANTUM:
|
||||||
|
if (QTM(window)) {
|
||||||
|
PFDI_FREE(hfdi, QTM(window));
|
||||||
|
QTM(window) = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAB(decomp_cab) = NULL;
|
||||||
|
PFDI_SEEK(CAB(hfdi), CAB(cabhf), fol->offset, SEEK_SET);
|
||||||
|
CAB(offset) = 0;
|
||||||
|
CAB(outlen) = 0;
|
||||||
|
|
||||||
|
/* initialize the new decompressor */
|
||||||
|
switch (ct1) {
|
||||||
case cffoldCOMPTYPE_NONE:
|
case cffoldCOMPTYPE_NONE:
|
||||||
CAB(decompress) = NONEfdi_decomp;
|
CAB(decompress) = NONEfdi_decomp;
|
||||||
break;
|
break;
|
||||||
|
@ -2245,8 +2270,11 @@ BOOL __cdecl FDICopy(
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err = DECR_DATAFORMAT;
|
err = DECR_DATAFORMAT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAB(current) = fol;
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case DECR_OK:
|
case DECR_OK:
|
||||||
break;
|
break;
|
||||||
|
@ -2263,10 +2291,6 @@ BOOL __cdecl FDICopy(
|
||||||
goto bail_and_fail;
|
goto bail_and_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
PFDI_SEEK(CAB(hfdi), CAB(cabhf), fol->offset, SEEK_SET);
|
|
||||||
CAB(offset) = 0;
|
|
||||||
CAB(outlen) = 0;
|
|
||||||
|
|
||||||
if (file->offset > CAB(offset)) {
|
if (file->offset > CAB(offset)) {
|
||||||
/* decode bytes and send them to /dev/null */
|
/* decode bytes and send them to /dev/null */
|
||||||
switch ((err = fdi_decomp(file, 0, decomp_state, pszCabPath, pfnfdin, pvUser))) {
|
switch ((err = fdi_decomp(file, 0, decomp_state, pszCabPath, pfnfdin, pvUser))) {
|
||||||
|
@ -2317,24 +2341,6 @@ BOOL __cdecl FDICopy(
|
||||||
goto bail_and_fail;
|
goto bail_and_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free decompression temps */
|
|
||||||
switch (ct1) {
|
|
||||||
case cffoldCOMPTYPE_LZX:
|
|
||||||
if (LZX(window)) {
|
|
||||||
PFDI_FREE(hfdi, LZX(window));
|
|
||||||
LZX(window) = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case cffoldCOMPTYPE_QUANTUM:
|
|
||||||
if (QTM(window)) {
|
|
||||||
PFDI_FREE(hfdi, QTM(window));
|
|
||||||
QTM(window) = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fdintCLOSE_FILE_INFO notification */
|
/* fdintCLOSE_FILE_INFO notification */
|
||||||
ZeroMemory(&fdin, sizeof(FDINOTIFICATION));
|
ZeroMemory(&fdin, sizeof(FDINOTIFICATION));
|
||||||
fdin.pv = pvUser;
|
fdin.pv = pvUser;
|
||||||
|
@ -2359,6 +2365,16 @@ BOOL __cdecl FDICopy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free decompression temps */
|
||||||
|
if (LZX(window)) {
|
||||||
|
PFDI_FREE(hfdi, LZX(window));
|
||||||
|
LZX(window) = NULL;
|
||||||
|
}
|
||||||
|
if (QTM(window)) {
|
||||||
|
PFDI_FREE(hfdi, QTM(window));
|
||||||
|
QTM(window) = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (decomp_state) {
|
while (decomp_state) {
|
||||||
fdi_decomp_state *prev_fds;
|
fdi_decomp_state *prev_fds;
|
||||||
|
|
||||||
|
@ -2391,6 +2407,16 @@ BOOL __cdecl FDICopy(
|
||||||
|
|
||||||
bail_and_fail: /* here we free ram before error returns */
|
bail_and_fail: /* here we free ram before error returns */
|
||||||
|
|
||||||
|
/* free decompression temps */
|
||||||
|
if (LZX(window)) {
|
||||||
|
PFDI_FREE(hfdi, LZX(window));
|
||||||
|
LZX(window) = NULL;
|
||||||
|
}
|
||||||
|
if (QTM(window)) {
|
||||||
|
PFDI_FREE(hfdi, QTM(window));
|
||||||
|
QTM(window) = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (decomp_state) {
|
while (decomp_state) {
|
||||||
fdi_decomp_state *prev_fds;
|
fdi_decomp_state *prev_fds;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue