📄 list.c
字号:
(unsigned)cfactor, mo, dy, yr, hh, mm, (char)(G.pInfo->lcflag ? '^' : ' '), (LPSTR)fnfilter(G.filename, slide), (LPSTR)methbuf, G.crec.crc32, (char)((G.crec.general_purpose_bit_flag & 1) ? 'E' : ' '));#else /* !WINDLL */ if (cfactor == 100) sprintf(cfactorstr, LoadFarString(CompFactor100)); else sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor); if (longhdr) Info(slide, 0, ((char *)slide, LoadFarString(LongHdrStats), G.crec.ucsize, methbuf, csiz, cfactorstr, mo, dy, yr, hh, mm, G.crec.crc32, (G.pInfo->lcflag? '^':' '))); else#ifdef OS2_EAS Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats), G.crec.ucsize, ea_size, acl_size, mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));#else Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats), G.crec.ucsize, mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));#endif fnprint(__G);#endif /* ?WINDLL */ if ((error = do_string(__G__ G.crec.file_comment_length, QCOND? DISPL_8 : SKIP)) != 0) { error_in_archive = error; /* might be just warning */ if (error > PK_WARN) /* fatal */ return error; } tot_ucsize += G.crec.ucsize; tot_csize += csiz; ++members;#ifdef OS2_EAS if (ea_size) { tot_easize += ea_size; ++tot_eafiles; } if (acl_size) { tot_aclsize += acl_size; ++tot_aclfiles; }#endif#ifdef OS2DLL } /* end of "if (G.processExternally) {...} else {..." */#endif } else { /* not listing this file */ SKIP_(G.crec.file_comment_length) } } /* end for-loop (j: files in central directory) *//*--------------------------------------------------------------------------- Print footer line and totals (compressed size, uncompressed size, number of members in zipfile). ---------------------------------------------------------------------------*/ if (uO.qflag < 2#ifdef OS2DLL && !G.processExternally#endif ) { if ((cfactor = ratio(tot_ucsize, tot_csize)) < 0) {#ifndef WINDLL sgn = '-';#endif cfactor = (-cfactor + 5) / 10; } else {#ifndef WINDLL sgn = ' ';#endif cfactor = (cfactor + 5) / 10; }#ifdef WINDLL /* pass the totals back to the calling application */ G.lpUserFunctions->TotalSizeComp = tot_csize; G.lpUserFunctions->TotalSize = tot_ucsize; G.lpUserFunctions->CompFactor = (ulg)cfactor; G.lpUserFunctions->NumMembers = members;#else /* !WINDLL */ if (cfactor == 100) sprintf(cfactorstr, LoadFarString(CompFactor100)); else sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor); if (longhdr) { Info(slide, 0, ((char *)slide, LoadFarString(LongFileTrailer), tot_ucsize, tot_csize, cfactorstr, members, members==1? "":"s"));#ifdef OS2_EAS if (tot_easize || tot_aclsize) Info(slide, 0, ((char *)slide, "\n")); if (tot_eafiles && tot_easize) Info(slide, 0, ((char *)slide, LoadFarString(OS2ExtAttrTrailer), tot_eafiles, tot_eafiles == 1? " has" : "s have a total of", tot_easize)); if (tot_aclfiles && tot_aclsize) Info(slide, 0, ((char *)slide, LoadFarString(OS2ACLTrailer), tot_aclfiles, tot_aclfiles == 1? " has" : "s have a total of", tot_aclsize));#endif /* OS2_EAS */ } else#ifdef OS2_EAS Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer), tot_ucsize, tot_easize, tot_aclsize, members, members == 1? "" : "s"));#else Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer), tot_ucsize, members, members == 1? "" : "s"));#endif /* OS2_EAS */#endif /* ?WINDLL */ }/*--------------------------------------------------------------------------- Double check that we're back at the end-of-central-directory record. ---------------------------------------------------------------------------*/ if (strncmp(G.sig, end_central_sig, 4)) { /* just to make sure again */ Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg))); error_in_archive = PK_WARN; /* didn't find sig */ } if (members == 0L && error_in_archive <= PK_WARN) error_in_archive = PK_FIND; return error_in_archive;} /* end function list_files() */#ifdef TIMESTAMP/************************//* Function fn_is_dir() *//************************/static int fn_is_dir(__G) /* returns TRUE if G.filename is directory */ __GDEF{ extent fn_len = strlen(G.filename); register char endc; return fn_len > 0 && ((endc = lastchar(G.filename, fn_len)) == '/' || (G.pInfo->hostnum == FS_FAT_ && !MBSCHR(G.filename, '/') && endc == '\\'));}/*****************************//* Function get_time_stamp() *//*****************************/int get_time_stamp(__G__ last_modtime, nmember) /* return PK-type error code */ __GDEF time_t *last_modtime; ulg *nmember;{ int do_this_file=FALSE, error, error_in_archive=PK_COOL; ulg j;#ifdef USE_EF_UT_TIME iztimes z_utime;#endif min_info info;/*--------------------------------------------------------------------------- Unlike extract_or_test_files() but like list_files(), this function works on information in the central directory alone. Thus we have a single, large loop through the entire directory, searching for the latest time stamp. ---------------------------------------------------------------------------*/ *last_modtime = 0L; /* assuming no zipfile data older than 1970 */ *nmember = 0L; G.pInfo = &info; for (j = 1L;; j++) { if (readbuf(__G__ G.sig, 4) == 0) return PK_EOF; if (strncmp(G.sig, central_hdr_sig, 4)) { /* is it a CentDir entry? */ if (((unsigned)(j - 1) & (unsigned)0xFFFF) == (unsigned)G.ecrec.total_entries_central_dir) { /* "j modulus 64k" matches the reported 16-bit-unsigned * number of directory entries -> probably, the regular * end of the central directory has been reached */ break; } else { Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j)); Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg))); return PK_BADERR; /* sig not found */ } } /* process_cdir_file_hdr() sets pInfo->lcflag: */ if ((error = process_cdir_file_hdr(__G)) != PK_COOL) return error; /* only PK_EOF defined */ if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) != PK_OK) { /* ^-- (uses pInfo->lcflag) */ error_in_archive = error; if (error > PK_WARN) /* fatal: can't continue */ return error; } if (G.extra_field != (uch *)NULL) { free(G.extra_field); G.extra_field = (uch *)NULL; } if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0) { error_in_archive = error; if (error > PK_WARN) /* fatal */ return error; } if (!G.process_all_files) { /* check if specified on command line */ unsigned i; do_this_file = FALSE; for (i = 0; i < G.filespecs; i++) if (match(G.filename, G.pfnames[i], uO.C_flag)) { do_this_file = TRUE; break; /* found match, so stop looping */ } if (do_this_file) { /* check if this is an excluded file */ for (i = 0; i < G.xfilespecs; i++) if (match(G.filename, G.pxnames[i], uO.C_flag)) { do_this_file = FALSE; /* ^-- ignore case in match */ break; } } } /* If current file was specified on command line, or if no names were * specified, check the time for this file. Either way, get rid of the * file comment and go back for the next file. * Directory entries are always ignored, to stay compatible with both * Zip and PKZIP. */ if ((G.process_all_files || do_this_file) && !fn_is_dir(__G)) {#ifdef USE_EF_UT_TIME if (G.extra_field &&#ifdef IZ_CHECK_TZ G.tz_is_valid &&#endif (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1, G.crec.last_mod_dos_datetime, &z_utime, NULL) & EB_UT_FL_MTIME)) { if (*last_modtime < z_utime.mtime) *last_modtime = z_utime.mtime; } else#endif /* USE_EF_UT_TIME */ { time_t modtime = dos_to_unix_time(G.crec.last_mod_dos_datetime); if (*last_modtime < modtime) *last_modtime = modtime; } ++*nmember; } SKIP_(G.crec.file_comment_length) } /* end for-loop (j: files in central directory) *//*--------------------------------------------------------------------------- Double check that we're back at the end-of-central-directory record. ---------------------------------------------------------------------------*/ if (strncmp(G.sig, end_central_sig, 4)) { /* just to make sure again */ Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg))); error_in_archive = PK_WARN; } if (*nmember == 0L && error_in_archive <= PK_WARN) error_in_archive = PK_FIND; return error_in_archive;} /* end function get_time_stamp() */#endif /* TIMESTAMP *//********************//* Function ratio() */ /* also used by ZipInfo routines *//********************/int ratio(uc, c) ulg uc, c;{ ulg denom; if (uc == 0) return 0; if (uc > 2000000L) { /* risk signed overflow if multiply numerator */ denom = uc / 1000L; return ((uc >= c) ? (int) ((uc-c + (denom>>1)) / denom) : -((int) ((c-uc + (denom>>1)) / denom))); } else { /* ^^^^^^^^ rounding */ denom = uc; return ((uc >= c) ? (int) ((1000L*(uc-c) + (denom>>1)) / denom) : -((int) ((1000L*(c-uc) + (denom>>1)) / denom))); } /* ^^^^^^^^ rounding */}/************************//* Function fnprint() */ /* also used by ZipInfo routines *//************************/void fnprint(__G) /* print filename (after filtering) and newline */ __GDEF{ char *name = fnfilter(G.filename, slide); (*G.message)((zvoid *)&G, (uch *)name, (ulg)strlen(name), 0); (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);} /* end function fnprint() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -