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

📄 flexos.c

📁 完整的解压zip文件的源码。包含密码功能
💻 C
📖 第 1 页 / 共 3 页
字号:
/*---------------------------------------------------------------------------  flexos.c  FlexOS-specific routines for use with Info-ZIP's UnZip 5.2 and later.  Based upon the MSDOS version of this file (msdos/msdos.c)  Contains:  do_wild()             mapattr()             mapname()             map2fat()             checkdir()             close_outfile()             dateformat()             version()             _wildarg()  ---------------------------------------------------------------------------*/#define UNZIP_INTERNAL#include "unzip.h"#include <flexif.h>/* The following should really be a static declaration,  but the compiler   complains (crappy compiler can't cope with a static forward declaration). */extern void map2fat OF((char *pathcomp, char *last_dot));static int created_dir;        /* used by mapname(), checkdir() */static int renamed_fullpath;   /* ditto *//*****************************//*  Strings used in flexos.c  *//*****************************/#ifndef SFX  static char Far CantAllocateWildcard[] =    "warning:  cannot allocate wildcard buffers\n";#endifstatic char Far Creating[] = "   creating: %s\n";static char Far ConversionFailed[] = "mapname:  conversion of %s failed\n";static char Far PathTooLong[] = "checkdir error:  path too long: %s\n";static char Far CantCreateDir[] = "checkdir error:  cannot create %s\n\                 unable to process %s.\n";static char Far DirIsntDirectory[] =  "checkdir error:  %s exists but is not directory\n\                 unable to process %s.\n";static char Far PathTooLongTrunc[] =  "checkdir warning:  path too long; truncating\n                   %s\n\                -> %s\n";#if (!defined(SFX) || defined(SFX_EXDIR))   static char Far CantCreateExtractDir[] =     "checkdir:  cannot create extraction directory: %s\n";#endif#include <dirent.h>#ifndef SFX/************************//*  Function do_wild()  */   /* identical to OS/2 version *//************************/char *do_wild(__G__ wildspec)    __GDEF    char *wildspec;          /* only used first time on a given dir */{    static DIR *dir = (DIR *)NULL;    static char *dirname, *wildname, matchname[FILNAMSIZ];    static int firstcall=TRUE, have_dirname, dirnamelen;    char *fnamestart;    struct dirent *file;    /* Even when we're just returning wildspec, we *always* do so in     * matchname[]--calling routine is allowed to append four characters     * to the returned string, and wildspec may be a pointer to argv[].     */    if (firstcall) {        /* first call:  must initialize everything */        firstcall = FALSE;        if (!iswild(wildspec)) {            strcpy(matchname, wildspec);            have_dirname = FALSE;            dir = NULL;            return matchname;        }        /* break the wildspec into a directory part and a wildcard filename */        if ((wildname = strrchr(wildspec, '/')) == (char *)NULL &&            (wildname = strrchr(wildspec, ':')) == (char *)NULL) {            dirname = ".";            dirnamelen = 1;            have_dirname = FALSE;            wildname = wildspec;        } else {            ++wildname;     /* point at character after '/' or ':' */            dirnamelen = (int)(wildname - wildspec);            if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {                Info(slide, 1, ((char *)slide,                  LoadFarString(CantAllocateWildcard)));                strcpy(matchname, wildspec);                return matchname;   /* but maybe filespec was not a wildcard */            }/* GRR:  cannot strip trailing char for opendir since might be "d:/" or "d:" *       (would have to check for "./" at end--let opendir handle it instead) */            strncpy(dirname, wildspec, dirnamelen);            dirname[dirnamelen] = '\0';       /* terminate for strcpy below */            have_dirname = TRUE;        }        Trace((stderr, "do_wild:  dirname = [%s]\n", dirname));        if ((dir = opendir(dirname)) != (DIR *)NULL) {            if (have_dirname) {                strcpy(matchname, dirname);                fnamestart = matchname + dirnamelen;            } else                fnamestart = matchname;            while ((file = readdir(dir)) != (struct dirent *)NULL) {                Trace((stderr, "do_wild:  readdir returns %s\n", file->d_name));                strcpy(fnamestart, file->d_name);                if (strrchr(fnamestart, '.') == (char *)NULL)                    strcat(fnamestart, ".");                if (match(fnamestart, wildname, 1) &&  /* 1 == ignore case */                    /* skip "." and ".." directory entries */                    strcmp(fnamestart, ".") && strcmp(fnamestart, "..")) {                    Trace((stderr, "do_wild:  match() succeeds\n"));                    /* remove trailing dot */                    fnamestart += strlen(fnamestart) - 1;                    if (*fnamestart == '.')                        *fnamestart = '\0';                    return matchname;                }            }            /* if we get to here directory is exhausted, so close it */            closedir(dir);            dir = (DIR *)NULL;        }#ifdef DEBUG        else {            Trace((stderr, "do_wild:  opendir(%s) returns NULL\n", dirname));        }#endif /* DEBUG */        /* return the raw wildspec in case that works (e.g., directory not         * searchable, but filespec was not wild and file is readable) */        strcpy(matchname, wildspec);        return matchname;    }    /* last time through, might have failed opendir but returned raw wildspec */    if (dir == (DIR *)NULL) {        firstcall = TRUE;  /* nothing left to try--reset for new wildspec */        if (have_dirname)            free(dirname);        return (char *)NULL;    }    /* If we've gotten this far, we've read and matched at least one entry     * successfully (in a previous call), so dirname has been copied into     * matchname already.     */    if (have_dirname) {        /* strcpy(matchname, dirname); */        fnamestart = matchname + dirnamelen;    } else        fnamestart = matchname;    while ((file = readdir(dir)) != (struct dirent *)NULL) {        Trace((stderr, "do_wild:  readdir returns %s\n", file->d_name));        strcpy(fnamestart, file->d_name);        if (strrchr(fnamestart, '.') == (char *)NULL)            strcat(fnamestart, ".");        if (match(fnamestart, wildname, 1)) {   /* 1 == ignore case */            Trace((stderr, "do_wild:  match() succeeds\n"));            /* remove trailing dot */            fnamestart += strlen(fnamestart) - 1;            if (*fnamestart == '.')                *fnamestart = '\0';            return matchname;        }    }    closedir(dir);     /* have read at least one dir entry; nothing left */    dir = (DIR *)NULL;    firstcall = TRUE;  /* reset for new wildspec */    if (have_dirname)        free(dirname);    return (char *)NULL;} /* end function do_wild() */#endif /* !SFX *//**********************//* Function mapattr() *//**********************/int mapattr(__G)    __GDEF{    /* set archive bit (file is not backed up): */    G.pInfo->file_attr = (unsigned)(G.crec.external_file_attributes & 7) | 32;    return 0;}/************************//*  Function mapname()  *//************************/                             /* return 0 if no error, 1 if caution (filename */int mapname(__G__ renamed)   /*  truncated), 2 if warning (skip file because */    __GDEF                   /*  dir doesn't exist), 3 if error (skip file), */    int renamed;             /*  or 10 if out of memory (skip file) */{                            /*  [also IZ_VOL_LABEL, IZ_CREATED_DIR] */    char pathcomp[FILNAMSIZ];      /* path-component buffer */    char *pp, *cp=(char *)NULL;    /* character pointers */    char *lastsemi=(char *)NULL;   /* pointer to last semi-colon in pathcomp */    char *last_dot=(char *)NULL;   /* last dot not converted to underscore */    int dotname = FALSE;           /* path component begins with dot? */    int error = 0;    register unsigned workch;      /* hold the character being tested */    if (G.pInfo->vollabel)        return IZ_VOL_LABEL;    /* Cannot set disk volume labels in FlexOS *//*---------------------------------------------------------------------------    Initialize various pointers and counters and stuff.  ---------------------------------------------------------------------------*/    /* can create path as long as not just freshening, or if user told us */    G.create_dirs = (!uO.fflag || renamed);    created_dir = FALSE;        /* not yet */    renamed_fullpath = FALSE;    if (renamed) {        cp = G.filename - 1;    /* point to beginning of renamed name... */        while (*++cp)            if (*cp == '\\')    /* convert backslashes to forward */                *cp = '/';        cp = G.filename;        /* use temporary rootpath if user gave full pathname */        if (G.filename[0] == '/') {            renamed_fullpath = TRUE;            pathcomp[0] = '/';  /* copy the '/' and terminate */            pathcomp[1] = '\0';            ++cp;        } else if (isalpha(G.filename[0]) && G.filename[1] == ':') {            renamed_fullpath = TRUE;            pp = pathcomp;            *pp++ = *cp++;      /* copy the "d:" (+ '/', possibly) */            *pp++ = *cp++;            if (*cp == '/')                *pp++ = *cp++;  /* otherwise add "./"? */            *pp = '\0';        }    }    /* pathcomp is ignored unless renamed_fullpath is TRUE: */    if ((error = checkdir(__G__ pathcomp, INIT)) != 0) /* initialize path buf */        return error;           /* ...unless no mem or vol label on hard disk */    *pathcomp = '\0';           /* initialize translation buffer */    pp = pathcomp;              /* point to translation buffer */    if (!renamed) {             /* cp already set if renamed */        if (uO.jflag)           /* junking directories */            cp = (char *)strrchr(G.filename, '/');        if (cp == (char *)NULL) /* no '/' or not junking dirs */            cp = G.filename;    /* point to internal zipfile-member pathname */        else            ++cp;               /* point to start of last component of path */    }/*---------------------------------------------------------------------------    Begin main loop through characters in filename.  ---------------------------------------------------------------------------*/    while ((workch = (uch)*cp++) != 0) {

⌨️ 快捷键说明

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