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

📄 atari.c

📁 zip压缩
💻 C
📖 第 1 页 / 共 3 页
字号:
        Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp)));        while ((*end = *pathcomp++) != '\0') {            ++end;/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */#ifdef SHORT_NAMES  /* truncate name at 14 characters, typically */            if ((end-old_end) > FILENAME_MAX)      /* GRR:  proper constant? */                *(end = old_end + FILENAME_MAX) = '\0';#endif            if ((end-buildpath) >= FILNAMSIZ) {                *--end = '\0';                Info(slide, 0x201, ((char *)slide,                  "checkdir warning:  path too long; truncating\n\                   %s\n                -> %s\n",                  FnFilter1(G.filename), FnFilter2(buildpath)));                return MPN_INF_TRUNC;   /* filename truncated */            }        }        Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));        /* could check for existence here, prompt for new name... */        return MPN_OK;    }/*---------------------------------------------------------------------------    INIT:  allocate and initialize buffer space for the file currently being    extracted.  If file was renamed with an absolute path, don't prepend the    extract-to path.  ---------------------------------------------------------------------------*//* GRR:  for VMS and TOPS-20, add up to 13 to strlen */    if (FUNCTION == INIT) {        Trace((stderr, "initializing buildpath to "));#ifdef ACORN_FTYPE_NFS        if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+                                        (uO.acorn_nfs_ext ? 5 : 1)))#else        if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1))#endif            == (char *)NULL)            return MPN_NOMEM;        if ((rootlen > 0) && !renamed_fullpath) {            strcpy(buildpath, rootpath);            end = buildpath + rootlen;        } else {            *buildpath = '\0';            end = buildpath;        }        Trace((stderr, "[%s]\n", FnFilter1(buildpath)));        return MPN_OK;    }/*---------------------------------------------------------------------------    ROOT:  if appropriate, store the path in rootpath and create it if    necessary; else assume it's a zipfile member and return.  This path    segment gets used in extracting all members from every zipfile specified    on the command line.  ---------------------------------------------------------------------------*/#if (!defined(SFX) || defined(SFX_EXDIR))    if (FUNCTION == ROOT) {        Trace((stderr, "initializing root path to [%s]\n", pathcomp));        if (pathcomp == (char *)NULL) {            rootlen = 0;            return MPN_OK;        }        if (rootlen > 0)        /* rootpath was already set, nothing to do */            return MPN_OK;        if ((rootlen = strlen(pathcomp)) > 0) {            char *tmproot;            if ((tmproot = (char *)malloc(rootlen+2)) == (char *)NULL) {                rootlen = 0;                return MPN_NOMEM;            }            strcpy(tmproot, pathcomp);            if (tmproot[rootlen-1] == '/') {                tmproot[--rootlen] = '\0';            }            if (rootlen > 0 && (stat(tmproot, &G.statbuf) ||                !S_ISDIR(G.statbuf.st_mode)))            {   /* path does not exist */                if (!G.create_dirs /* || iswild(tmproot) */ ) {                    free(tmproot);                    rootlen = 0;                    /* skip (or treat as stored file) */                    return MPN_INF_SKIP;                }                /* create the directory (could add loop here scanning tmproot                 * to create more than one level, but why really necessary?) */                if (mkdir(tmproot, 0777) == -1) {                    Info(slide, 1, ((char *)slide,                      "checkdir:  cannot create extraction directory: %s\n",                      FnFilter1(tmproot)));                    free(tmproot);                    rootlen = 0;                    /* path didn't exist, tried to create, and failed: */                    /* file exists, or 2+ subdir levels required */                    return MPN_ERR_SKIP;                }            }            tmproot[rootlen++] = '/';            tmproot[rootlen] = '\0';            if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) {                free(tmproot);                rootlen = 0;                return MPN_NOMEM;            }            Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath)));        }        return MPN_OK;    }#endif /* !SFX || SFX_EXDIR *//*---------------------------------------------------------------------------    END:  free rootpath, immediately prior to program exit.  ---------------------------------------------------------------------------*/    if (FUNCTION == END) {        Trace((stderr, "freeing rootpath\n"));        if (rootlen > 0) {            free(rootpath);            rootlen = 0;        }        return MPN_OK;    }    return MPN_INVALID; /* should never reach */} /* end function checkdir() *//****************************//* Function close_outfile() *//****************************/void close_outfile(__G)    /* GRR: change to return PK-style warning level */    __GDEF{#ifdef USE_EF_UT_TIME    unsigned eb_izux_flg;    iztimes zt;#endif    ztimbuf tp;/*---------------------------------------------------------------------------    If symbolic links are supported, allocate a storage area, put the uncom-    pressed "data" in it, and create the link.  Since we know it's a symbolic    link to start with, we shouldn't have to worry about overflowing unsigned    ints with unsigned longs.  ---------------------------------------------------------------------------*/    /* symlinks allowed on minix filesystems [cjh]     * Hopefully this will work properly... We won't bother to try if     * MiNT isn't present; the symlink should fail if we're on a TOS     * filesystem.     * BUG: should we copy the original file to the "symlink" if the     *      link fails?     */    if (G.symlnk) {        unsigned ucsize = (unsigned)G.lrec.ucsize;        char *linktarget = (char *)malloc((unsigned)G.lrec.ucsize+1);        fclose(G.outfile);                      /* close "data" file... */        G.outfile = fopen(G.filename, FOPR);    /* ...and reopen for reading */        if (!linktarget || (fread(linktarget, 1, ucsize, G.outfile) !=                            (int)ucsize)) {            Info(slide, 0x201, ((char *)slide,              "warning:  symbolic link (%s) failed\n", FnFilter1(G.filename)));            if (linktarget)                free(linktarget);            fclose(G.outfile);            return;        }        fclose(G.outfile);                  /* close "data" file for good... */        unlink(G.filename);                 /* ...and delete it */        linktarget[ucsize] = '\0';        if (QCOND2)            Info(slide, 0, ((char *)slide, "-> %s ", FnFilter1(linktarget)));        if (symlink(linktarget, G.filename))  /* create the real link */            perror("symlink error");        free(linktarget);        return;                             /* can't set time on symlinks */    }    fclose(G.outfile);/*---------------------------------------------------------------------------    Convert from MSDOS-format local time and date to Unix-format 32-bit GMT    time:  adjust base year from 1980 to 1970, do usual conversions from    yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-    light savings time differences.  ---------------------------------------------------------------------------*/#ifdef USE_EF_UT_TIME    eb_izux_flg = (G.extra_field#ifdef IZ_CHECK_TZ                   && G.tz_is_valid#endif                   ? ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length,                       0, G.lrec.last_mod_dos_datetime, &zt, NULL)                   : 0);    if (eb_izux_flg & EB_UT_FL_MTIME) {        tp.modtime = zt.mtime;        TTrace((stderr, "\nclose_outfile:  Unix e.f. modif. time = %ld\n",          tp.modtime));    } else {        tp.modtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);    }    if (eb_izux_flg & EB_UT_FL_ATIME) {        tp.actime = zt.atime;        TTrace((stderr, "close_outfile:  Unix e.f. access time = %ld\n",          tp.actime));    } else {        tp.actime = tp.modtime;        TTrace((stderr, "\nclose_outfile:  modification/access times = %ld\n",          tp.modtime));    }#else /* !USE_EF_UT_TIME */    tp.actime = tp.modtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);    TTrace((stderr, "\nclose_outfile:  modification/access times = %ld\n",      tp.modtime));#endif /* ?USE_EF_UT_TIME */    /* set the file's access and modification times */    if (utime(G.filename, &tp))        Info(slide, 0x201, ((char *)slide,          "warning:  cannot set the time for %s\n", FnFilter1(G.filename)));/*---------------------------------------------------------------------------    Change the file permissions from default ones to those stored in the    zipfile.  ---------------------------------------------------------------------------*/#ifndef NO_CHMOD    if (chmod(G.filename, 0xffff & G.pInfo->file_attr))            perror("chmod (file attributes) error");#endif} /* end function close_outfile() */#ifdef TIMESTAMP/***************************//*  Function stamp_file()  *//***************************/int stamp_file(fname, modtime)    ZCONST char *fname;    time_t modtime;{    ztimbuf tp;    tp.modtime = tp.actime = modtime;    return (utime(fname, &tp));} /* end function stamp_file() */#endif /* TIMESTAMP */#ifndef SFX/************************//*  Function version()  *//************************/void version(__G)    __GDEF{#ifdef __TURBOC__    char buf[40];#endif    sprintf((char *)slide, LoadFarString(CompiledWith),#ifdef __GNUC__      "gcc ", __VERSION__,#else#  if 0      "cc ", (sprintf(buf, " version %d", _RELEASE), buf),#  else#  ifdef __TURBOC__      "Turbo C", (sprintf(buf, " (0x%04x = %d)", __TURBOC__, __TURBOC__), buf),#  else      "unknown compiler", "",#  endif#  endif#endif#ifdef __MINT__      "Atari TOS/MiNT",#else      "Atari TOS",#endif      " (Atari ST/TT/Falcon030)",#ifdef __DATE__      " on ", __DATE__#else      "", ""#endif    );    (*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);} /* end function version() */#endif /* !SFX */

⌨️ 快捷键说明

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