Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/process.c  view on Meta::CPAN


    if (SSTAT(G.zipfn, &G.statbuf) ||
#ifdef THEOS
        (error = S_ISLIB(G.statbuf.st_mode)) != 0 ||
#endif
        (error = S_ISDIR(G.statbuf.st_mode)) != 0)
    {
#ifndef SFX
        if (lastchance && (uO.qflag < 3)) {
#if defined(UNIX) || defined(QDOS)
            if (G.no_ecrec)
                Info(slide, 1, ((char *)slide,
                  LoadFarString(CannotFindZipfileDirMsg),
                  LoadFarStringSmall((uO.zipinfo_mode ? Zipnfo : Unzip)),
                  G.wildzipfn, uO.zipinfo_mode? "  " : "", G.wildzipfn,
                  G.zipfn));
            else
                Info(slide, 1, ((char *)slide,
                  LoadFarString(CannotFindEitherZipfile),
                  LoadFarStringSmall((uO.zipinfo_mode ? Zipnfo : Unzip)),
                  G.wildzipfn, G.wildzipfn, G.zipfn));
#else /* !(UNIX || QDOS) */
            if (G.no_ecrec)
                Info(slide, 0x401, ((char *)slide,
                  LoadFarString(CannotFindZipfileDirMsg),
                  LoadFarStringSmall((uO.zipinfo_mode ? Zipnfo : Unzip)),
                  G.wildzipfn, uO.zipinfo_mode? "  " : "", G.zipfn));
            else
#ifdef VMS
                Info(slide, 0x401, ((char *)slide,
                  LoadFarString(CannotFindEitherZipfile),
                  LoadFarStringSmall((uO.zipinfo_mode ? Zipnfo : Unzip)),
                  G.wildzipfn,
                  (*G.zipfn ? G.zipfn : vms_msg_text())));
#else /* !VMS */
                Info(slide, 0x401, ((char *)slide,
                  LoadFarString(CannotFindEitherZipfile),
                  LoadFarStringSmall((uO.zipinfo_mode ? Zipnfo : Unzip)),
                  G.wildzipfn, G.zipfn));
#endif /* ?VMS */
#endif /* ?(UNIX || QDOS) */
        }
#endif /* !SFX */
        return error? IZ_DIR : PK_NOZIP;
    }
    G.ziplen = G.statbuf.st_size;

#ifndef SFX
#if defined(UNIX) || defined(DOS_OS2_W32) || defined(THEOS)
    if (G.statbuf.st_mode & S_IEXEC)   /* no extension on Unix exes:  might */
        maybe_exe = TRUE;               /*  find unzip, not unzip.zip; etc. */
#endif
#endif /* !SFX */

#ifdef VMS
    if (check_format(__G))              /* check for variable-length format */
        return PK_ERR;
#endif

    if (open_input_file(__G))   /* this should never happen, given */
        return PK_NOZIP;        /*  the stat() test above, but... */

#ifdef DO_SAFECHECK_2GB
    /* Need more care: Do not trust the size returned by stat() but
       determine it by reading beyond the end of the file. */
    G.ziplen = file_size(G.zipfd);

    if (G.ziplen == EOF) {
        Info(slide, 0x401, ((char *)slide, LoadFarString(ZipfileTooBig)));
        /*
        printf(
" We need a better error message for: 64-bit file, 32-bit program.\n");
        */
        CLOSE_INFILE();
        return IZ_ERRBF;
    }
#endif /* DO_SAFECHECK_2GB */

/*---------------------------------------------------------------------------
    Find and process the end-of-central-directory header.  UnZip need only
    check last 65557 bytes of zipfile:  comment may be up to 65535, end-of-
    central-directory record is 18 bytes, and signature itself is 4 bytes;
    add some to allow for appended garbage.  Since ZipInfo is often used as
    a debugging tool, search the whole zipfile if zipinfo_mode is true.
  ---------------------------------------------------------------------------*/

    G.cur_zipfile_bufstart = 0;
    G.inptr = G.inbuf;

#if ((!defined(WINDLL) && !defined(SFX)) || !defined(NO_ZIPINFO))
# if (!defined(WINDLL) && !defined(SFX))
    if ( (!uO.zipinfo_mode && !uO.qflag
#  ifdef TIMESTAMP
          && !uO.T_flag
#  endif
         )
#  ifndef NO_ZIPINFO
         || (uO.zipinfo_mode && uO.hflag)
#  endif
       )
# else /* not (!WINDLL && !SFX) ==> !NO_ZIPINFO !! */
    if (uO.zipinfo_mode && uO.hflag)
# endif /* if..else..: (!WINDLL && !SFX) */
# ifdef WIN32   /* Win32 console may require codepage conversion for G.zipfn */
        Info(slide, 0, ((char *)slide, LoadFarString(LogInitline),
          FnFilter1(G.zipfn)));
# else
        Info(slide, 0, ((char *)slide, LoadFarString(LogInitline), G.zipfn));
# endif
#endif /* (!WINDLL && !SFX) || !NO_ZIPINFO */

    if ( (error_in_archive = find_ecrec(__G__
#ifndef NO_ZIPINFO
                                        uO.zipinfo_mode ? G.ziplen :
#endif
                                        MIN(G.ziplen, 66000L)))
         > PK_WARN )
    {
        CLOSE_INFILE();

#ifdef SFX
        ++lastchance;   /* avoid picky compiler warnings */
        return error_in_archive;
#else



( run in 0.999 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )