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

📄 win32.c

📁 完整的解压zip文件的源码。包含密码功能
💻 C
📖 第 1 页 / 共 5 页
字号:
        case '<':             /*  so no colons allowed */        case '>':             /* no redirection symbols allowed either */        case '|':             /* no pipe signs allowed */        case '"':             /* no double quotes allowed */        case '?':             /* no wildcards allowed */        case '*':            *pp++ = '_';      /* these rules apply equally to FAT and NTFS */            break;        case ';':             /* start of VMS version? */            lastsemi = pp;    /* remove VMS version later... */            *pp++ = ';';      /*  but keep semicolon for now */            break;        case ' ':             /* keep spaces unless specifically */            /* NT cannot create filenames with spaces on FAT volumes */            if (uO.sflag || IsVolumeOldFAT(__G__ G.filename))                *pp++ = '_';            else                *pp++ = ' ';            break;        default:            /* allow European characters in filenames: */            if (isprint(workch) || workch >= 127)                *pp++ = (char)workch;        } /* end switch */    } /* end while loop */    *pp = '\0';                   /* done with pathcomp:  terminate it */    /* if not saving them, remove VMS version numbers (appended "###") */    if (!uO.V_flag && lastsemi) {        pp = lastsemi + 1;        /* semi-colon was kept:  expect #'s after */        while (isdigit((uch)(*pp)))            ++pp;        if (*pp == '\0')          /* only digits between ';' and end:  nuke */            *lastsemi = '\0';    }/*---------------------------------------------------------------------------    Report if directory was created (and no file to create:  filename ended    in '/'), check name to be sure it exists, and combine path and name be-    fore exiting.  ---------------------------------------------------------------------------*/    if (G.filename[G.fnlen-1] == '/') {        checkdir(__G__ G.filename, GETPATH);        if (G.created_dir) {#ifdef __RSXNT__        /* RSXNT/EMX C rtl uses OEM charset */            char *ansi_name = (char *)alloca(strlen(G.filename) + 1);            INTERN_TO_ISO(G.filename, ansi_name);#           define Ansi_Fname  ansi_name#else#           define Ansi_Fname  G.filename#endif            if (QCOND2) {                Info(slide, 0, ((char *)slide, "   creating: %-22s\n",                  FnFilter1(G.filename)));            }            /* set file attributes:               The default for newly created directories is "DIR attribute               flags set", so there is no need to change attributes unless               one of the DOS style attribute flags is set. The readonly               attribute need not be masked, since it does not prevent               modifications in the new directory. */            if(G.pInfo->file_attr & (0x7F & ~FILE_ATTRIBUTE_DIRECTORY)) {                if (!SetFileAttributes(Ansi_Fname, G.pInfo->file_attr & 0x7F))                    Info(slide, 1, ((char *)slide,                      "\nwarning (%d): could not set file attributes for %s\n",                      (int)GetLastError(), G.filename));            }#ifdef NTSD_EAS            /* set extra fields, both stored-in-zipfile and .LONGNAME flavors */            if (G.extra_field) { /* zipfile e.f. may have extended attribs */                int err = EvalExtraFields(__G__ G.filename, G.extra_field,                                          G.lrec.extra_field_length);                if (err == IZ_EF_TRUNC) {                    if (uO.qflag)                        Info(slide, 1, ((char *)slide, "%-22s ",                          FnFilter1(G.filename)));                    Info(slide, 1, ((char *)slide, LoadFarString(TruncNTSD),                      makeword(G.extra_field+2)-10, uO.qflag? "\n":""));                }            }#endif /* NTSD_EAS */            return IZ_CREATED_DIR;      /* set dir time (note trailing '/') */        }        return 2;   /* dir existed already; don't look for data to extract */    }    if (*pathcomp == '\0') {        Info(slide, 1, ((char *)slide, "mapname:  conversion of %s failed\n",          FnFilter1(G.filename)));        return 3;    }    checkdir(__G__ pathcomp, APPEND_NAME);  /* returns 1 if truncated: care? */    checkdir(__G__ G.filename, GETPATH);    Trace((stderr, "mapname returns with filename = [%s] (error = %d)\n\n",      FnFilter1(G.filename), error));    if (G.pInfo->vollabel) {    /* set the volume label now */        char drive[4];#ifdef __RSXNT__        /* RSXNT/EMX C rtl uses OEM charset */        char *ansi_name = (char *)alloca(strlen(G.filename) + 1);        INTERN_TO_ISO(G.filename, ansi_name);#       define Ansi_Fname  ansi_name#else#       define Ansi_Fname  G.filename#endif        /* Build a drive string, e.g. "b:" */        drive[0] = (char)('a' + G.nLabelDrive - 1);        strcpy(drive + 1, ":\\");        if (QCOND2)            Info(slide, 0, ((char *)slide, "labelling %s %-22s\n", drive,              FnFilter1(G.filename)));        if (!SetVolumeLabel(drive, Ansi_Fname)) {            Info(slide, 1, ((char *)slide,              "mapname:  error setting volume label\n"));            return 3;        }        return 2;   /* success:  skip the "extraction" quietly */#undef Ansi_Fname    }    return error;} /* end function mapname() *//**********************//* Function map2fat() */        /* Not quite identical to OS/2 version *//**********************/static void map2fat(pathcomp, pEndFAT)    char *pathcomp, **pEndFAT;{    char *ppc = pathcomp;       /* variable pointer to pathcomp */    char *pEnd = *pEndFAT;      /* variable pointer to buildpathFAT */    char *pBegin = *pEndFAT;    /* constant pointer to start of this comp. */    char *last_dot = NULL;      /* last dot not converted to underscore */    int dotname = FALSE;        /* flag:  path component begins with dot */                                /*  ("." and ".." don't count) */    register unsigned workch;   /* hold the character being tested */    /* Only need check those characters which are legal in NTFS but not     * in FAT:  to get here, must already have passed through mapname.     * Also must truncate path component to ensure 8.3 compliance.     */    while ((workch = (uch)*ppc++) != 0) {        switch (workch) {            case '[':            case ']':            case '+':            case ',':            case ';':            case '=':                *pEnd++ = '_';      /* convert brackets to underscores */                break;            case '.':                if (pEnd == *pEndFAT) {   /* nothing appended yet... */                    if (*ppc == '\0')     /* don't bother appending a */                        break;            /*  "./" component to the path */                    else if (*ppc == '.' && ppc[1] == '\0') {   /* "../" */                        *pEnd++ = '.';    /* add first dot, unchanged... */                        ++ppc;            /* skip second dot, since it will */                    } else {              /*  be "added" at end of if-block */                        *pEnd++ = '_';    /* FAT doesn't allow null filename */                        dotname = TRUE;   /*  bodies, so map .exrc -> _.exrc */                    }                     /*  (extra '_' now, "dot" below) */                } else if (dotname) {     /* found a second dot, but still */                    dotname = FALSE;      /*  have extra leading underscore: */                    *pEnd = '\0';         /*  remove it by shifting chars */                    pEnd = *pEndFAT + 1;  /*  left one space (e.g., .p1.p2: */                    while (pEnd[1]) {     /*  __p1 -> _p1_p2 -> _p1.p2 when */                        *pEnd = pEnd[1];  /*  finished) [opt.:  since first */                        ++pEnd;           /*  two chars are same, can start */                    }                     /*  shifting at second position] */                }                last_dot = pEnd;    /* point at last dot so far... */                *pEnd++ = '_';      /* convert dot to underscore for now */                break;            default:                *pEnd++ = (char)workch;        } /* end switch */    } /* end while loop */    *pEnd = '\0';                 /* terminate buildpathFAT */    /* NOTE:  keep in mind that pEnd points to the end of the path     * component, and *pEndFAT still points to the *beginning* of it...     * Also note that the algorithm does not try to get too fancy:     * if there are no dots already, the name either gets truncated     * at 8 characters or the last underscore is converted to a dot     * (only if more characters are saved that way).  In no case is     * a dot inserted between existing characters.     */    if (last_dot == NULL) {       /* no dots:  check for underscores... */        char *plu = strrchr(pBegin, '_');   /* pointer to last underscore */        if (plu == NULL) {   /* no dots, no underscores:  truncate at 8 chars */            *pEndFAT += 8;        /* (or could insert '.' and keep 11...?) */            if (*pEndFAT > pEnd)                *pEndFAT = pEnd;  /* oops...didn't have 8 chars to truncate */            else                **pEndFAT = '\0';        } else if (MIN(plu - pBegin, 8) + MIN(pEnd - plu - 1, 3) > 8) {            last_dot = plu;       /* be lazy:  drop through to next if-blk */        } else if ((pEnd - *pEndFAT) > 8) {            *pEndFAT += 8;        /* more fits into just basename than if */            **pEndFAT = '\0';     /*  convert last underscore to dot */        } else            *pEndFAT = pEnd;      /* whole thing fits into 8 chars or less */    }    if (last_dot != NULL) {       /* one dot (or two, in the case of */        *last_dot = '.';          /*  "..") is OK:  put it back in */        if ((last_dot - pBegin) > 8) {            char *p, *q;            int i;            p = last_dot;            q = last_dot = pBegin + 8;            for (i = 0;  (i < 4) && *p;  ++i)  /* too many chars in basename: */                *q++ = *p++;                   /*  shift .ext left and trun- */            *q = '\0';                         /*  cate/terminate it */            *pEndFAT = q;        } else if ((pEnd - last_dot) > 4) {    /* too many chars in extension */            *pEndFAT = last_dot + 4;            **pEndFAT = '\0';        } else            *pEndFAT = pEnd;   /* filename is fine; point at terminating zero */        if ((last_dot - pBegin) > 0 && last_dot[-1] == ' ')            last_dot[-1] = '_';                /* NO blank in front of '.'! */    }} /* end function map2fat() *//***********************/       /* Borrowed from os2.c for UnZip 5.1.        *//* Function checkdir() */       /* Difference: no EA stuff                   *//***********************/       /*             HPFS stuff works on NTFS too  */int checkdir(__G__ pathcomp, flag)    __GDEF    char *pathcomp;    int flag;/* * returns:  1 - (on APPEND_NAME) truncated filename *           2 - path doesn't exist, not allowed to create *           3 - path doesn't exist, tried to create and failed; or *               path exists and is not a directory, but is supposed to be *           4 - path is too long *          10 - can't allocate memory for filename buffers */{ /* static int rootlen = 0;     */   /* length of rootpath */ /* static char *rootpath;      */   /* user's "extract-to" directory */ /* static char *buildpathHPFS; */   /* full path (so far) to extracted file, */ /* static char *buildpathFAT;  */   /*  both HPFS/EA (main) and FAT versions */ /* static char *endHPFS;       */   /* corresponding pointers to end of */ /* static char *endFAT;        */   /*  buildpath ('\0') */#   define FN_MASK   7#   define FUNCTION  (flag & FN_MASK)/*---------------------------------------------------------------------------    APPEND_DIR:  append the path component to the path being built and check    for its existence.  If doesn't exist and we are creating directories, do    so for this one; else signal success or error as appropriate.  ---------------------------------------------------------------------------*/    if (FUNCTION == APPEND_DIR) {        char *p = pathcomp;        int too_long=FALSE;        Trace((stderr, "appending dir segment [%s]\n", pathcomp));        while ((*G.endHPFS = *p++) != '\0')     /* copy to HPFS filename */            ++G.endHPFS;        if (!IsVolumeOldFAT(__G__ G.buildpathHPFS)) {            p = pathcomp;            while ((*G.endFAT = *p++) != '\0')  /* copy to FAT filename, too */                ++G.endFAT;        } else            map2fat(pathcomp, &G.endFAT);   /* map into FAT fn, update endFAT */        /* GRR:  could do better check, see if overrunning buffer as we go:         * check endHPFS-buildpathHPFS after each append, set warning variable         * if within 20 of FILNAMSIZ; then if var set, do careful check when         * appending.  Clear variable when begin new path. */        /* next check:  need to append '/', at least one-char name, '\0' */        if ((G.endHPFS-G.buildpathHPFS) > FILNAMSIZ-3)            too_long = TRUE;                    /* check if extracting dir? */#ifdef FIX_STAT_BUG        /* Borland C++ 5.0 does not handle a call to stat() well if the         * directory does not exist (it tends to crash in strange places.)         * This is apparently a problem only when compiling for GUI rather         * than console. The code below attempts to work around this problem.         */        if (access(G.buildpathFAT, 0) != 0) {            if (!G.create_dirs) { /* told not to create (freshening) */                free(G.buildpathHPFS);                free(G.buildpathFAT);                return 2;         /* path doesn't exist:  nothing to do */            }            if (too_long) {   /* GRR:  should allow FAT extraction w/o EAs */                Info(slide, 1, ((char *)slide,                  "checkdir error:  path too long: %s\n",                  FnFilter1(G.buildpathHPFS)));                free(G.buildpathHPFS);                free(G.buildpathFAT);                return 4;         /* no room for filenames:  fatal */            }            if (MKDIR(G.buildpathFAT, 0777) == -1) { /* create the directory */                Info(slide, 1, ((char *)slide,                  "checkdir error:  cannot create %s\n\                 unable to process %s.\n",                  FnFilter2(G.buildpathFAT), FnFilter1(G.filename)));                free(G.buildpathHPFS);                free(G.buildpathFAT);                return 3;      /* path didn't exist, tried to create, failed */            }            G.created_dir = TRUE;        }#endif /* FIX_STAT_BUG */        if (SSTAT(G.buildpathFAT, &G.statbuf))   /* path doesn't exist */        {            if (!G.create_dirs) { /* told not to create (freshening) */                free(G.buildpathHPFS);                free(G.buildpathFAT);                return 2;         /* path doesn't exist:  nothing to do */            }            if (too_long) {   /* GRR:  should allow FAT extraction w/o EAs */                Info(slide, 1, ((char *)slide,                  "checkdir error:  path too long: %s\n",                  FnFilter1(G.buildpathHPFS)));                free(G.buildpathHPFS);                free(G.buildpathFAT);                return 4;         /* no room for filenames:  fatal */            }            if (MKDIR(G.buildpathFAT, 0777) == -1) { /* create the directory */                Info(slide, 1, ((char *)slide,                  "checkdir error:  cannot create %s\n\                 unable to process %s.\n",                  FnFilter2(G.buildpathFAT), FnFilter1(G.filename)));                free(G.buildpathHPFS);                free(G.buildpathFAT);                return 3;      /* path didn't exist, tried to create, failed */            }            G.created_dir = TRUE;        } else if (!S_ISDIR(G.statbuf.st_mode)) {            Info(slide, 1, ((char *)slide,              "checkdir error:  %s exists but is not directory\n   \              unable to process %s.\n",              FnFilter2(G.buildpathFAT), 

⌨️ 快捷键说明

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