⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extract.c

📁 完整的解压zip文件的源码。包含密码功能
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif /* !SFX */                /* mapname can create dirs if not freshening or if renamed */                if ((error = mapname(__G__ renamed)) > PK_WARN) {                    if (error == IZ_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 = dirlist;                            dirlist = d_entry;                            dirlist->fn =                              (char *)malloc(strlen(G.filename) + 1);                            if (dirlist->fn == (char *)NULL) {                                Info(slide, 0x401, ((char *)slide,                                  LoadFarString(DirlistEntryNoMem)));                                dirlist = d_entry->next;                                free(d_entry);                                if (!error_in_archive)                                    error_in_archive = PK_WARN;                                continue;                            }                            strcpy(dirlist->fn, G.filename);                            dirlist->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 ? &(dirlist->u.t3) : NULL),#else                              &(dirlist->u.t3),#endif                              dirlist->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",                                  dirlist->u.t3.mtime));                            } else {                                dirlist->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",                                  dirlist->u.t3.atime));                            } else {                                dirlist->u.t3.atime =                                  dirlist->u.t3.mtime;                            }                            dirlist->have_uidgid =                                (uO.X_flag && (eb_izux_flg & EB_UX2_VALID));                            ++num_dirs;                        }#endif /* SET_DIR_ATTRIB */                    } else if (error == IZ_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                    /*  if (!error_in_archive)                            error_in_archive = PK_WARN;  */                    } else if (error > PK_ERR  &&  error_in_archive < PK_ERR)                        error_in_archive = PK_ERR;                    Trace((stderr, "mapname(%s) returns error = %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                        /* if freshening, don't skip if just renamed */                        if (uO.fflag && !renamed)                            continue;   /* freshen (no new files):  skip */                        break;                    case EXISTS_AND_OLDER:                        if (uO.overwrite_none) {#ifdef WINDLL                            char szStr[FILNAMSIZ+40]; /* add. space for text */                            if ((!G.prompt_always) || (done_once)) {                                sprintf(szStr,                                  "Target file exists.\nSkipping %s\n",                                  FnFilter1(G.filename));                                win_fprintf((zvoid *)&G, stdout,                                  strlen(szStr), szStr);                            } else {                                query = TRUE;                                break;                            }#endif /* WINDLL */                            continue;   /* never overwrite:  skip file */                        }#ifdef UNIXBACKUP                        if (!uO.overwrite_all && !uO.B_flag)#else                        if (!uO.overwrite_all)#endif                            query = TRUE;                        break;                    case EXISTS_AND_NEWER:             /* (or equal) */                        if (uO.overwrite_none || (uO.uflag && !renamed)) {#ifdef WINDLL                            char szStr[FILNAMSIZ+40]; /* add. space for text */                            if ((!G.prompt_always) || (done_once)) {                                sprintf(szStr,                                  "Target file newer.\nSkipping %s\n",                                  FnFilter1(G.filename));                                win_fprintf((zvoid *)&G, stdout,                                  strlen(szStr), szStr);                            } else {                                query = TRUE;                                break;                            }#endif /* WINDLL */                            continue;  /* skip if update/freshen & orig name */                        }#ifdef UNIXBACKUP                        if (!uO.overwrite_all && !uO.B_flag)#else                        if (!uO.overwrite_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_YES:                            break;                        case IDM_REPLACE_ALL:                            uO.overwrite_all = TRUE;                            uO.overwrite_none = FALSE;  /* just to make sure */                            break;                        case IDM_REPLACE_NONE:                            uO.overwrite_none = TRUE;                            uO.overwrite_all = FALSE;   /* make sure */                            done_once = TRUE;                            /* FALL THROUGH, skip */                        case IDM_REPLACE_NO:                            {                                char szStr[FILNAMSIZ+40];                                sprintf(szStr,                                  "Target file newer.\nSkipping %s\n",                                  FnFilter1(G.filename));                                win_fprintf((zvoid *)&G, stdout,                                  strlen(szStr), szStr);                            }                            continue;                    }#else /* !WINDLL */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 'A':   /* dangerous option:  force caps */                            uO.overwrite_all = TRUE;                            uO.overwrite_none = FALSE;  /* just to make sure */                            break;                        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 */                                len = strlen(G.filename);                                if (G.filename[len-1] == '\n')                                    G.filename[--len] = '\0';                            } while (len == 0);#ifdef WIN32  /* WIN32 fgets( ... , stdin) returns OEM coded strings */                            _OEM_INTERN(G.filename);#endif                            renamed = TRUE;                            goto startover;   /* sorry for a goto */                        case 'y':                        case 'Y':                            break;                        case 'N':                            uO.overwrite_none = TRUE;                            uO.overwrite_all = FALSE;   /* make sure */                            /* FALL THROUGH, skip */                        case 'n':                            continue;   /* skip file */                        default:                            Info(slide, 1, ((char *)slide,                              LoadFarString(InvalidResponse), *G.answerbuf));                            goto reprompt;   /* yet another goto? */                    } /* end switch (*answerbuf) */#endif /* ?WINDLL */                } /* end if (query) */            } /* end if (extracting to disk) */#ifdef DLL            if ((G.statreportcb != NULL) &&                (*G.statreportcb)(__G__ UZ_ST_START_EXTRACT, G.zipfn,                                  G.filename, NULL)) {                if (fn_matched)                    free((zvoid *)fn_matched);                if (xn_matched)                    free((zvoid *)xn_matched);                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                    if (fn_matched)                        free((zvoid *)fn_matched);                    if (xn_matched)                        free((zvoid *)xn_matched);                    return error_in_archive;        /* (unless disk full) */                }            }#ifdef DLL            if ((G.statreportcb != NULL) &&                (*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,                                  G.filename, (zvoid *)&G.lrec.ucsize)) {                if (fn_matched)                    free((zvoid *)fn_matched);                if (xn_matched)                    free((zvoid *)xn_matched);                return IZ_CTRLC;        /* cancel operation by user request */            }#endif#ifdef MACOS  /* MacOS is no preemptive OS, thus call event-handling by hand */            UserStop();#endif        } /* end for-loop (i:  files in current block) */        /*         * Jump back to where we were in the central directory, then go and do         * the next batch of files.         */#ifdef USE_STRM_INPUT        fseek((FILE *)G.zipfd, (LONGINT)cd_bufstart, SEEK_SET);        G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd);#else /* !USE_STRM_INPUT */        G.cur_zipfile_bufstart = lseek(G.zipfd,(LONGINT)cd_bufstart,SEEK_SET);#endif /* ?USE_STRM_INPUT */        read(G.zipfd, (char *)G.inbuf, INBUFSIZ);  /* been here before... */        G.inptr = cd_inptr;        G.incnt = cd_incnt;        ++blknum;#ifdef TEST        printf("\ncd_bufstart = %ld (%.8lXh)\n", cd_bufstart, cd_bufstart);        printf("cur_zipfile_bufstart = %ld (%.8lXh)\n", cur_zipfile_bufstart,          cur_zipfile_bufstart);        printf("inptr-inbuf = %d\n", G.inptr-G.inbuf);        printf("incnt = %d\n\n", G.incnt);#endif    } /* end while-loop (blocks of files in central directory) *//*---------------------------------------------------------------------------    Go back through saved list of directories, sort and set times/perms/UIDs    and GIDs from the deepest level on up.  ---------------------------------------------------------------------------*/#ifdef SET_DIR_ATTRIB    if (num_dirs > 0) {        sorted_dirlist = (dirtime **)malloc(num_dirs*sizeof(dirtime *));        if (sorted_dirlist == (dirtime **)NULL) {            Info(slide, 0x401, ((char *)slide,              LoadFarString(DirlistSortNoMem)));            while (dirlist != (dirtime *)NULL) {                dirtime *d = dirlist;                dirlist = dirlist->next;                free(d);            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -