📄 extract.c
字号:
{ if (error > error_in_archive) error_in_archive = error; if (error > PK_WARN) { Info(slide, 0x401, ((char *)slide, LoadFarString(ExtFieldMsg), FnFilter1(G.filename), "local")); continue; /* go on */ } }#if CRYPT if (G.pInfo->encrypted && (error = decrypt(__G__ uO.pwdarg)) != PK_COOL) { if (error == PK_WARN) { if (!((uO.tflag && uO.qflag) || (!uO.tflag && !QCOND2))) Info(slide, 0x401, ((char *)slide, LoadFarString(SkipIncorrectPasswd), FnFilter1(G.filename))); ++(*pnum_bad_pwd); } else { /* (error > PK_WARN) */ if (error > error_in_archive) error_in_archive = error; Info(slide, 0x401, ((char *)slide, LoadFarString(SkipCannotGetPasswd), FnFilter1(G.filename))); } continue; /* go on to next file */ }#endif /* CRYPT */ /* * just about to extract file: if extracting to disk, check if * already exists, and if so, take appropriate action according to * fflag/uflag/overwrite_all/etc. (we couldn't do this in upper * loop because we don't store the possibly renamed filename[] in * info[]) */#ifdef DLL if (!uO.tflag && !uO.cflag && !G.redirect_data)#else if (!uO.tflag && !uO.cflag)#endif { renamed = FALSE; /* user hasn't renamed output file yet */startover: query = FALSE; skip_entry = SKIP_NO; /* for files from DOS FAT, check for use of backslash instead * of slash as directory separator (bug in some zipper(s); so * far, not a problem in HPFS, NTFS or VFAT systems) */#ifndef SFX if (G.pInfo->hostnum == FS_FAT_ && !MBSCHR(G.filename, '/')) { char *p=G.filename; if (*p) do { if (*p == '\\') { if (!G.reported_backslash) { Info(slide, 0x21, ((char *)slide, LoadFarString(BackslashPathSep), G.zipfn)); G.reported_backslash = TRUE; if (!error_in_archive) error_in_archive = PK_WARN; } *p = '/'; } } while (*PREINCSTR(p)); }#endif /* !SFX */ if (!renamed) { /* remove absolute path specs */ if (G.filename[0] == '/') { Info(slide, 0x401, ((char *)slide, LoadFarString(AbsolutePathWarning), FnFilter1(G.filename))); if (!error_in_archive) error_in_archive = PK_WARN; do { char *p = G.filename + 1; do { *(p-1) = *p; } while (*p++ != '\0'); } while (G.filename[0] == '/'); } } /* mapname can create dirs if not freshening or if renamed */ error = mapname(__G__ renamed); if ((errcode = error & ~MPN_MASK) != PK_OK && error_in_archive < errcode) error_in_archive = errcode; if ((errcode = error & MPN_MASK) > MPN_INF_TRUNC) { if (errcode == MPN_CREATED_DIR) {#ifdef SET_DIR_ATTRIB dirtime *d_entry; d_entry = (dirtime *)malloc(sizeof(dirtime)); if (d_entry == (dirtime *)NULL) { Info(slide, 0x401, ((char *)slide, LoadFarString(DirlistEntryNoMem))); } else { unsigned eb_izux_flg; d_entry->next = (*pdirlist); (*pdirlist) = d_entry; (*pdirlist)->fn = (char *)malloc(strlen(G.filename) + 1); if ((*pdirlist)->fn == (char *)NULL) { Info(slide, 0x401, ((char *)slide, LoadFarString(DirlistEntryNoMem))); (*pdirlist) = d_entry->next; free(d_entry); if (!error_in_archive) error_in_archive = PK_WARN; continue; } strcpy((*pdirlist)->fn, G.filename); (*pdirlist)->perms = G.pInfo->file_attr;#ifdef USE_EF_UT_TIME eb_izux_flg = G.extra_field? ef_scan_for_izux( G.extra_field, G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,#ifdef IZ_CHECK_TZ (G.tz_is_valid ? &((*pdirlist)->u.t3) : NULL),#else &((*pdirlist)->u.t3),#endif (*pdirlist)->uidgid) : 0;#else /* !USE_EF_UT_TIME */ eb_izux_flg = 0;#endif /* ?USE_EF_UT_TIME */ if (eb_izux_flg & EB_UT_FL_MTIME) { TTrace((stderr, "\nextract: Unix dir e.f. modtime = %ld\n", (*pdirlist)->u.t3.mtime)); } else { (*pdirlist)->u.t3.mtime = dos_to_unix_time( G.lrec.last_mod_dos_datetime); } if (eb_izux_flg & EB_UT_FL_ATIME) { TTrace((stderr, "\nextract: Unix dir e.f. actime = %ld\n", (*pdirlist)->u.t3.atime)); } else { (*pdirlist)->u.t3.atime = (*pdirlist)->u.t3.mtime; } (*pdirlist)->have_uidgid =#ifdef RESTORE_UIDGID (uO.X_flag && (eb_izux_flg & EB_UX2_VALID));#else 0;#endif ++(*pnum_dirs); }#endif /* SET_DIR_ATTRIB */ } else if (errcode == MPN_VOL_LABEL) {#ifdef DOS_OS2_W32 Info(slide, 0x401, ((char *)slide, LoadFarString(SkipVolumeLabel), FnFilter1(G.filename), uO.volflag? "hard disk " : ""));#else Info(slide, 1, ((char *)slide, LoadFarString(SkipVolumeLabel), FnFilter1(G.filename), ""));#endif } else if (errcode > MPN_INF_SKIP && error_in_archive < PK_ERR) error_in_archive = PK_ERR; Trace((stderr, "mapname(%s) returns error code = %d\n", FnFilter1(G.filename), error)); continue; /* go on to next file */ }#ifdef QDOS QFilename(__G__ G.filename);#endif switch (check_for_newer(__G__ G.filename)) { case DOES_NOT_EXIST:#ifdef NOVELL_BUG_FAILSAFE G.dne = TRUE; /* stat() says file DOES NOT EXIST */#endif /* freshen (no new files): skip unless just renamed */ if (uO.fflag && !renamed) skip_entry = SKIP_Y_NONEXIST; break; case EXISTS_AND_OLDER:#ifdef UNIXBACKUP if (!uO.B_flag)#endif { if (IS_OVERWRT_NONE) /* never overwrite: skip file */ skip_entry = SKIP_Y_EXISTING; else if (!IS_OVERWRT_ALL) query = TRUE; } break; case EXISTS_AND_NEWER: /* (or equal) */#ifdef UNIXBACKUP if ((!uO.B_flag && IS_OVERWRT_NONE) ||#else if (IS_OVERWRT_NONE ||#endif (uO.uflag && !renamed)) { /* skip if update/freshen & orig name */ skip_entry = SKIP_Y_EXISTING; } else {#ifdef UNIXBACKUP if (!IS_OVERWRT_ALL && !uO.B_flag)#else if (!IS_OVERWRT_ALL)#endif query = TRUE; } break; } if (query) {#ifdef WINDLL switch (G.lpUserFunctions->replace != NULL ? (*G.lpUserFunctions->replace)(G.filename) : IDM_REPLACE_NONE) { case IDM_REPLACE_RENAME: _ISO_INTERN(G.filename); renamed = TRUE; goto startover; case IDM_REPLACE_ALL: G.overwrite_mode = OVERWRT_ALWAYS; /* FALL THROUGH, extract */ case IDM_REPLACE_YES: break; case IDM_REPLACE_NONE: G.overwrite_mode = OVERWRT_NEVER; /* FALL THROUGH, skip */ case IDM_REPLACE_NO: skip_entry = SKIP_Y_EXISTING; break; }#else /* !WINDLL */ extent fnlen;reprompt: Info(slide, 0x81, ((char *)slide, LoadFarString(ReplaceQuery), FnFilter1(G.filename))); if (fgets(G.answerbuf, 9, stdin) == (char *)NULL) { Info(slide, 1, ((char *)slide, LoadFarString(AssumeNone))); *G.answerbuf = 'N'; if (!error_in_archive) error_in_archive = 1; /* not extracted: warning */ } switch (*G.answerbuf) { case 'r': case 'R': do { Info(slide, 0x81, ((char *)slide, LoadFarString(NewNameQuery))); fgets(G.filename, FILNAMSIZ, stdin); /* usually get \n here: better check for it */ fnlen = strlen(G.filename); if (lastchar(G.filename, fnlen) == '\n') G.filename[--fnlen] = '\0'; } while (fnlen == 0);#ifdef WIN32 /* WIN32 fgets( ... , stdin) returns OEM coded strings */ _OEM_INTERN(G.filename);#endif renamed = TRUE; goto startover; /* sorry for a goto */ case 'A': /* dangerous option: force caps */ G.overwrite_mode = OVERWRT_ALWAYS; /* FALL THROUGH, extract */ case 'y': case 'Y': break; case 'N': G.overwrite_mode = OVERWRT_NEVER; /* FALL THROUGH, skip */ case 'n': /* skip file */ skip_entry = SKIP_Y_EXISTING; break; default: Info(slide, 1, ((char *)slide, LoadFarString(InvalidResponse), *G.answerbuf)); goto reprompt; /* yet another goto? */ } /* end switch (*answerbuf) */#endif /* ?WINDLL */ } /* end if (query) */ if (skip_entry != SKIP_NO) {#ifdef WINDLL if (skip_entry == SKIP_Y_EXISTING) { /* report skipping of an existing entry */ Info(slide, 0, ((char *)slide, ((IS_OVERWRT_NONE || !uO.uflag || renamed) ? "Target file exists.\nSkipping %s\n" : "Target file newer.\nSkipping %s\n"), FnFilter1(G.filename))); }#endif /* WINDLL */ continue; } } /* end if (extracting to disk) */#ifdef DLL if ((G.statreportcb != NULL) && (*G.statreportcb)(__G__ UZ_ST_START_EXTRACT, G.zipfn, G.filename, NULL)) { return IZ_CTRLC; /* cancel operation by user request */ }#endif#ifdef MACOS /* MacOS is no preemptive OS, thus call event-handling by hand */ UserStop();#endif#ifdef AMIGA G.filenote_slot = i;#endif G.disk_full = 0; if ((error = extract_or_test_member(__G)) != PK_COOL) { if (error > error_in_archive) error_in_archive = error; /* ...and keep going */#ifdef DLL if (G.disk_full > 1 || error_in_archive == IZ_CTRLC) {#else if (G.disk_full > 1) {#endif return error_in_archive; /* (unless disk full) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -