view release on metacpan or search on metacpan
unzip-6.0/ToDo view on Meta::CPAN
o add new low-level, binary API; rewrite "normal" (command-line) UnZip
to use it
maybe soon (maybe 6.1)
o MSDOS/WIN32/others: detection of "reserved" names (= names of character
devices, or system extensions that look like a characters device driver)
at runtime; with the goal of emitting "meaningful" error messages and/or
rename queries.
(Currently, these reserved names are catched as "non-deletable files".
On MSDOS and WIN32, when the RTL stat() function allows to identify
character devices, the "reserved" names are automatically prefixed with
an underscore.)
o redesign "file exists -- is newer/older -- overwrite/skip/rename"
logic in extract.c and the corresponding system specific mapname()
services; to prevent superfluous decryption key prompts for entry
that will be skipped, later.
o rewrite to use fread/fseek/etc. [eventually: test
write(bytes) vs. fwrite(words), especially on Crays/Alphas]
unzip-6.0/ToDo view on Meta::CPAN
Requested features:
- extract or exclude on basis of UID [Armin Bub, Armin.Bub@bk.bosch.de, 970904]
=======================================
o miscellaneous little stuff: whenever
--------------------------
- change DOS -f/-u stuff to use DOS API for getting filetimes, not stat()
- add (-N?) option to lose all user input and/or switch to "(*input)()"
function, replaceable by UzpAltMain() param
- add -@ option to read from stdin (zip) or from file (PKZIP)? (go32 built-in)
- add -oo option to overwrite OS/2 and DOS system and hidden files, too
- add option to compute MD5 checksum on files and/or on entire zipfile?
- decide whether to use WinGUI "skipping" diagnostics in extract.c
- combine "y/n/A/N" query/response stuff into unified section with query
function(s) (InputFn?)
unzip-6.0/acorn/acorn.c view on Meta::CPAN
#endif
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath 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 ((end-buildpath) > FILNAMSIZ-3)
too_long = TRUE; /* check if extracting dir? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
FnFilter1(buildpath)));
fflush(stderr);
free(buildpath);
unzip-6.0/acorn/riscos.c view on Meta::CPAN
/* #define NO_UNZIPH_STUFF */
#define UNZIP_INTERNAL
#include "unzip.h"
#include "riscos.h"
#define MAXEXT 16
char *exts2swap = NULL; /* Extensions to swap (actually, directory names) */
int stat(char *filename,struct stat *res)
{
int attr; /* object attributes */
unsigned int load; /* load address */
unsigned int exec; /* exec address */
int type; /* type: 0 not found, 1 file, 2 dir, 3 image */
if (!res)
return -1;
if (SWI_OS_File_5(filename,&type,&load,&exec,(int *)&res->st_size,&attr)!=NULL)
unzip-6.0/acorn/riscos.h view on Meta::CPAN
# define TIMESTAMP
# endif
# define localtime riscos_localtime
# define gmtime riscos_gmtime
#endif /* !NO_UNZIPH_STUFF */
#define _raw_getc() SWI_OS_ReadC()
extern char *exts2swap; /* Extensions to swap */
int stat(char *filename,struct stat *res);
DIR *opendir(char *dirname);
struct dirent *readdir(DIR *d);
void closedir(DIR *d);
int unlink(char *f);
int rmdir(char *d);
int chmod(char *file, int mode);
void setfiletype(char *fname,int ftype);
void getRISCOSexts(char *envstr);
int checkext(char *suff);
void swapext(char *name, char *exptr);
unzip-6.0/amiga/Contents view on Meta::CPAN
Contents of the "amiga" directory for UnZip 5.5 and later:
Contents this file
amiga.c Amiga-specific file I/O routines
amiga.h Amiga-specific header file
filedate.c SetFileDate clone for OS 1.3, and other low-level resources
smakefile SAS/C makefile for UnZip, fUnZip, and UnZipSFX
makefile.azt Aztec C makefile for UnZip, fUnZip, and UnZipSFX
stat.c stat() emulation for Aztec, along with opendir()/readdir()/etc
z-stat.h replacement stat.h header file for use with stat.c
crc_68.a assembler version of crc32.c
flate.a assembler version of inflate_codes() (define ASM_INFLATECODES)
makesfx.c source for MakeSFX, without which UnZipSFX is not usable
Notes:
The crc_68.a source file is not currently used by the SAS/C makefile,
nor is flate.a; as of UnZip 5.2 neither of these wants args in
unzip-6.0/amiga/amiga.c view on Meta::CPAN
if (FUNCTION == ROOT) {
Trace((stderr, "initializing root path to [%s]\n",
FnFilter1(pathcomp)));
if (pathcomp == (char *)NULL) {
G.rootlen = 0;
return MPN_OK;
}
if (G.rootlen > 0) /* rootpath was already set, nothing to do */
return MPN_OK;
if ((G.rootlen = strlen(pathcomp)) > 0) {
if (stat(pathcomp, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode)) {
/* path does not exist */
if (!G.create_dirs) {
G.rootlen = 0;
/* skip (or treat as stored file) */
return MPN_INF_SKIP;
}
/* create the directory (could add loop here scanning pathcomp
* to create more than one level, but why really necessary?) */
if (MKDIR(pathcomp, 0777) == -1) {
Info(slide, 1, ((char *)slide,
unzip-6.0/amiga/filedate.c view on Meta::CPAN
ret = DeleteFile((char *) var);
UnLock(CurrentDir(spine));
}
}
me->pr_WindowPtr = old_window;
return ret;
}
/* Stores data from timezone and daylight to ENV:TZ. */
/* ENV:TZ is required to exist by some other SAS/C library functions, */
/* like stat() or fstat(). */
void set_TZ(long time_zone, int day_light)
{
char put_tz[MAXTIMEZONELEN]; /* string for putenv: "TZ=aaabbb:bb:bbccc" */
int offset;
void *exists; /* dummy ptr to see if global envvar TZ already exists */
exists = (void *)getenv(TZ_ENVVAR);
/* see if there is already an envvar TZ_ENVVAR. If not, create it */
if (exists == NULL) {
/* create TZ string by pieces: */
sprintf(put_tz, "GMT%+ld", time_zone / 3600L);
unzip-6.0/amiga/makesfx.c view on Meta::CPAN
if (argc < 3 || argc > 4) {
printf("Usage: %s <result-file> <zip-archive> [<self-extractor-"
"program>]\nThe third arg defaults to \"UnZipSFX\" in the"
" current dir or C:.\n", argv[0]);
exit(20);
}
if (!(arch = fopen(argv[2], "rb"))) {
printf("Could not find archive file %s\n", argv[2]);
exit(10);
}
if (stat(argv[2], &ss) || !(archivesize = ss.st_size)) {
fclose(arch);
printf("Could not check size of archive %s, or file is empty.\n",
argv[2]);
exit(10);
}
if (argc < 4)
toolname = "UnZipSFX";
if (!(tool = fopen(toolname, "rb"))) {
BPTR lk = Lock("C:", ACCESS_READ);
BPTR ocd = lk ? CurrentDir(lk) : 0;
unzip-6.0/amiga/stat.c view on Meta::CPAN
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* Here we have a handmade stat() function because Aztec's c.lib stat() */
/* does not support an st_mode field, which we need... also a chmod(). */
/* This stat() is by Paul Wells, modified by Paul Kienitz. */
/* Originally for use with Aztec C >= 5.0 and Lattice C <= 4.01 */
/* Adapted for SAS/C 6.5x by Haidinger Walter */
/* POLICY DECISION: We will not attempt to remove global variables from */
/* this source file for Aztec C. These routines are essentially just */
/* augmentations of Aztec's c.lib, which is itself not reentrant. If */
/* we want to produce a fully reentrant UnZip, we will have to use a */
/* suitable startup module, such as purify.a for Aztec by Paul Kienitz. */
#ifndef __amiga_stat_c
unzip-6.0/amiga/stat.c view on Meta::CPAN
/* CALL THIS WHEN HANDLING CTRL-C OR OTHER UNEXPECTED EXIT! */
void close_leftover_open_dirs(void)
{
while (dir_cleanup_list)
closedir(dir_cleanup_list);
}
unsigned short disk_not_mounted;
extern int stat(const char *file, struct stat *buf);
stat(file,buf)
const char *file;
struct stat *buf;
{
struct FileInfoBlock *inf;
BPTR lock;
time_t ftime;
struct tm local_tm;
if( (lock = Lock((char *)file,SHARED_LOCK))==0 )
unzip-6.0/amiga/stat.c view on Meta::CPAN
/* lastly, throw in the protection bits */
buf->st_mode |= ((inf->fib_Protection ^ 0xF) & 0xFF);
FreeMem((char *)inf, (long)sizeof(*inf));
UnLock((BPTR)lock);
return(0);
}
int fstat(int handle, struct stat *buf)
{
/* fake some reasonable values for stdin */
buf->st_mode = (S_IREAD|S_IWRITE|S_IFREG);
buf->st_size = -1;
buf->st_mtime = time(&buf->st_mtime);
return 0;
}
/* opendir(), readdir(), closedir(), rmdir(), and chmod() by Paul Kienitz. */
unzip-6.0/amiga/z-stat.h view on Meta::CPAN
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
#ifndef __amiga_z_stat_h
#define __amiga_z_stat_h
/* Since older versions of the Lattice C compiler for Amiga, and all current */
/* versions of the Manx Aztec C compiler for Amiga, either provide no stat() */
/* function or provide one inadequate for unzip (Aztec's has no st_mode */
/* field), we provide our own stat() function in stat.c by Paul Wells, and */
/* this fake stat.h file by Paul Kienitz. Paul Wells originally used the */
/* Lattice stat.h but that does not work for Aztec and is not distributable */
/* with this package, so I made a separate one. This has to be pulled into */
/* unzip.h when compiling an Amiga version, as "amiga/z-stat.h". */
/* We also provide here a "struct dirent" for use with opendir() & readdir() */
/* functions included in amiga/stat.c. If you use amiga/stat.c, this must */
/* be included wherever you use either readdir() or stat(). */
#ifdef AZTEC_C
# define __STAT_H
#else /* __SASC */
/* do not include the following header, replacement definitions are here */
# define _STAT_H /* do not include SAS/C <stat.h> */
# define _DIRENT_H /* do not include SAS/C <dirent.h> */
# define _SYS_DIR_H /* do not include SAS/C <sys/dir.h> */
# define _COMMIFMT_H /* do not include SAS/C <sys/commifmt.h> */
# include <dos.h>
unzip-6.0/amiga/z-stat.h view on Meta::CPAN
#define S_IHIDDEN (1<<7)
#define S_ISCRIPT (1<<6)
#define S_IPURE (1<<5)
#define S_IARCHIVE (1<<4)
#define S_IREAD (1<<3)
#define S_IWRITE (1<<2)
#define S_IEXECUTE (1<<1)
#define S_IDELETE (1<<0)
int stat(const char *name, struct stat *buf);
int fstat(int handle, struct stat *buf); /* returns dummy values */
typedef struct dirent {
struct dirent *d_cleanuplink,
**d_cleanupparent;
BPTR d_parentlock;
struct FileInfoBlock d_fib;
} DIR;
#define d_name d_fib.fib_FileName
extern unsigned short disk_not_mounted; /* flag set by opendir() */
unzip-6.0/aosvs/README view on Meta::CPAN
I also introduced a function zvs_credir() to create a directory
(as opposed to a CPD, though it can create CPDs to with the proper
file-type parameter). Directories in a path which are being created
will now be directories instead of CPDs.
The big change that's needed now is to have ZIP store (somehow)
the file's ACL and file type, and then to have UNZIP use this
information to recreate the file as it was before ZIPping. Ideally,
ZIP should also store links and CPD max-block info as well. Planned
strategy: either in the name field but after the name, or in a comment,
store the packet returned by ?FSTAT (using sys_fstat()), and then
use this packet for the ?CREATE call in zvs_create().
------------------------------------------------------------------
22-Jul-94
The changes to use the extra-field field for AOS/VS file info are in
place. In general, if a ZIPfile was created with the current rev of
ZIP.PR, the files should be restored with file type, ACL, etc. OK.
I didn't test to make sure element size & max index levels come
through OK, but I think they should.
unzip-6.0/aosvs/aosvs.c view on Meta::CPAN
{
int errc = 1; /* init to show no success with AOS/VS info */
long dmm, ddd, dyy, dhh, dmin, dss;
#ifdef DLL
if (G.redirect_data)
return redirect_outfile(__G)==FALSE;
#endif
if (stat(G.filename, &G.statbuf) == 0 && unlink(G.filename) < 0) {
Info(slide, 0x401, ((char *)slide, LoadFarString(CannotDeleteOldFile),
FnFilter1(G.filename)));
return 1;
}
/*---------------------------------------------------------------------------
If the file didn't already exist, we created it earlier. But we just
deleted it, which we still had to do in case we are overwriting an exis-
ting file. So we must create it now, again, to set the creation time
properly. (The creation time is the best functional approximation of
unzip-6.0/aosvs/aosvs.c view on Meta::CPAN
If we stored this with an AOS/VS Zip that set the extra field to contain
the ?FSTAT packet and the ACL, we should use info from the ?FSTAT call
now. Otherwise (or if that fails), we should create anyway as best we
can from the normal Zip info.
In theory, we should look through an entire series of extra fields that
might exist for the same file, but we're not going to bother. If we set
up other types of extra fields, or if other environments we run into may
add their own stuff to existing entries in Zip files, we'll have to.
Note that all the packet types for sys_fstat() are the same size & mostly
have the same structure, with some fields being unused, etc. Ditto for
sys_create(). Thus, we assume a normal one here, not a dir/cpd or device
or IPC file, & make little adjustments as necessary. We will set ACLs
later (to reduce the chance of lacking access to what we create now); note
that for links the resolution name should be stored in the ACL field (once
we get Zip recognizing links OK).
---------------------------------------------------------------------------*/
if (G.extra_field != NULL) {
memcpy((char *) &zzextrafld, G.extra_field, sizeof(zzextrafld));
unzip-6.0/atari/atari.c view on Meta::CPAN
*(end = old_end + FILENAME_MAX) = '\0';
#endif
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath 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. */
if ((end-buildpath) > FILNAMSIZ-3) /* need '/', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
unzip-6.0/atari/atari.c view on Meta::CPAN
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?) */
unzip-6.0/cmsmvs/vmmvs.c view on Meta::CPAN
Contains: vmmvs_open_infile()
open_outfile()
close_outfile()
close_infile()
getVMMVSexfield()
do_wild()
mapattr()
mapname()
checkdir()
check_for_newer()
stat()
version()
---------------------------------------------------------------------------*/
#define __VMMVS_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h"
unzip-6.0/cmsmvs/vmmvs.c view on Meta::CPAN
fclose(stream);
/* File exists, assume it is "newer" than archive entry. */
return EXISTS_AND_NEWER;
}
/* File does not exist. */
return DOES_NOT_EXIST;
} /* end function check_for_newer() */
/*********************/
/* Function stat() */
/*********************/
int stat(const char *path, struct stat *buf)
{
FILE *fp;
char fname[PATH_MAX];
time_t ltime;
if ((fp = fopen(path, FOPR)) != NULL) {
fldata_t fdata;
if (fldata( fp, fname, &fdata ) == 0) {
buf->st_dev = fdata.__device;
buf->st_mode = *(short *)(&fdata);
unzip-6.0/cmsmvs/vmstat.h view on Meta::CPAN
int st_uid;
int st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define _STAT_DEFINED
#endif
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
#define S_IFMT 0xFFFF
#define _FLDATA(m) (*(fldata_t *) &m)
#define S_ISDIR(m) (_FLDATA(m).__dsorgPDSdir)
#define S_ISREG(m) (_FLDATA(m).__dsorgPO | \
_FLDATA(m).__dsorgPDSmem | \
_FLDATA(m).__dsorgPS)
#define S_ISBLK(m) (_FLDATA(m).__recfmBlk)
#define S_ISMEM(m) (_FLDATA(m).__dsorgMem)
unzip-6.0/extract.c view on Meta::CPAN
/*-----------------------------------------------------------------------
Second loop: process files in current block, extracting or testing
each one.
-----------------------------------------------------------------------*/
for (i = 0; i < numchunk; ++i) {
(*pfilnum)++; /* *pfilnum = i + blknum*DIR_BLKSIZ + 1; */
G.pInfo = &G.info[i];
#ifdef NOVELL_BUG_FAILSAFE
G.dne = FALSE; /* assume file exists until stat() says otherwise */
#endif
/* if the target position is not within the current input buffer
* (either haven't yet read far enough, or (maybe) skipping back-
* ward), skip to the target position and reset readbuf(). */
/* seek_zipf(__G__ pInfo->offset); */
request = G.pInfo->offset + G.extra_bytes;
inbuf_offset = request % INBUFSIZ;
bufstart = request - inbuf_offset;
unzip-6.0/extract.c view on Meta::CPAN
FnFilter1(G.filename), error));
continue; /* go on to next file */
}
#ifdef QDOS
QFilename(__G__ G.filename);
#endif
switch (check_for_newer(__G__ G.filename)) {
case DOES_NOT_EXIST:
#ifdef NOVELL_BUG_FAILSAFE
G.dne = TRUE; /* stat() says file DOES NOT EXIST */
#endif
/* freshen (no new files): skip unless just renamed */
if (uO.fflag && !renamed)
skip_entry = SKIP_Y_NONEXIST;
break;
case EXISTS_AND_OLDER:
#ifdef UNIXBACKUP
if (!uO.B_flag)
#endif
{
unzip-6.0/fileio.c view on Meta::CPAN
do_string()
makeword()
makelong()
makeint64()
fzofft()
str2iso() (CRYPT && NEED_STR2ISO, only)
str2oem() (CRYPT && NEED_STR2OEM, only)
memset() (ZMEM only)
memcpy() (ZMEM only)
zstrnicmp() (NO_STRNICMP only)
zstat() (REGULUS only)
plastchar() (_MBCS only)
uzmbclen() (_MBCS && NEED_UZMBCLEN, only)
uzmbschr() (_MBCS && NEED_UZMBSCHR, only)
uzmbsrchr() (_MBCS && NEED_UZMBSRCHR, only)
fLoadFarString() (SMALL_MEM only)
fLoadFarStringSmall() (SMALL_MEM only)
fLoadFarStringSmall2() (SMALL_MEM only)
zfstrcpy() (SMALL_MEM only)
zfstrcmp() (SMALL_MEM && !(SFX || FUNZIP) only)
unzip-6.0/fileio.c view on Meta::CPAN
static ZCONST char Far CannotDeleteOldFile[] =
"error: cannot delete old %s\n %s\n";
#ifdef UNIXBACKUP
static ZCONST char Far CannotRenameOldFile[] =
"error: cannot rename old %s\n %s\n";
static ZCONST char Far BackupSuffix[] = "~";
#endif
#endif /* ATH_BEO_THS_UNX || DOS_FLX_NLM_OS2_W32 */
#ifdef NOVELL_BUG_FAILSAFE
static ZCONST char Far NovellBug[] =
"error: %s: stat() says does not exist, but fopen() found anyway\n";
#endif
static ZCONST char Far CannotCreateFile[] =
"error: cannot create %s\n %s\n";
#endif /* !TANDEM */
#endif /* !VMS && !AOS_VS && !CMS_MVS && !MACOS */
static ZCONST char Far ReadError[] = "error: zipfile read error\n";
static ZCONST char Far FilenameTooLongTrunc[] =
"warning: filename too long--truncating.\n";
#ifdef UNICODE_SUPPORT
unzip-6.0/fileio.c view on Meta::CPAN
{
#ifdef DLL
if (G.redirect_data)
return (redirect_outfile(__G) == FALSE);
#endif
#ifdef QDOS
QFilename(__G__ G.filename);
#endif
#if (defined(DOS_FLX_NLM_OS2_W32) || defined(ATH_BEO_THS_UNX))
#ifdef BORLAND_STAT_BUG
/* Borland 5.0's stat() barfs if the filename has no extension and the
* file doesn't exist. */
if (access(G.filename, 0) == -1) {
FILE *tmp = fopen(G.filename, "wb+");
/* file doesn't exist, so create a dummy file to keep stat() from
* failing (will be over-written anyway) */
fputc('0', tmp); /* just to have something in the file */
fclose(tmp);
}
#endif /* BORLAND_STAT_BUG */
#ifdef SYMLINKS
if (SSTAT(G.filename, &G.statbuf) == 0 ||
lstat(G.filename, &G.statbuf) == 0)
#else
if (SSTAT(G.filename, &G.statbuf) == 0)
#endif /* ?SYMLINKS */
{
Trace((stderr, "open_outfile: stat(%s) returns 0: file exists\n",
FnFilter1(G.filename)));
#ifdef UNIXBACKUP
if (uO.B_flag) { /* do backup */
char *tname;
z_stat tmpstat;
int blen, flen, tlen;
blen = strlen(BackupSuffix);
flen = strlen(G.filename);
tlen = flen + blen + 6; /* includes space for 5 digits */
unzip-6.0/fileio.c view on Meta::CPAN
/* under AOS/VS, file times can only be set at creation time,
* with the info in a special DG format. Make sure we can create
* it here - we delete it later & re-create it, whether or not
* it exists now.
*/
if (!zvs_create(filename, (((ulg)dgdate(dmm, ddd, dyy)) << 16) |
(dhh*1800L + dmin*30L + dss/2L), -1L, -1L, (char *) -1, -1, -1, -1))
return DOES_NOT_EXIST;
#endif /* AOS_VS */
Trace((stderr, "check_for_newer: doing stat(%s)\n", FnFilter1(filename)));
if (SSTAT(filename, &G.statbuf)) {
Trace((stderr,
"check_for_newer: stat(%s) returns %d: file does not exist\n",
FnFilter1(filename), SSTAT(filename, &G.statbuf)));
#ifdef SYMLINKS
Trace((stderr, "check_for_newer: doing lstat(%s)\n",
FnFilter1(filename)));
/* GRR OPTION: could instead do this test ONLY if G.symlnk is true */
if (lstat(filename, &G.statbuf) == 0) {
Trace((stderr,
"check_for_newer: lstat(%s) returns 0: symlink does exist\n",
FnFilter1(filename)));
if (QCOND2 && !IS_OVERWRT_ALL)
Info(slide, 0, ((char *)slide, LoadFarString(FileIsSymLink),
FnFilter1(filename), " with no real file"));
return EXISTS_AND_OLDER; /* symlink dates are meaningless */
}
#endif /* SYMLINKS */
return DOES_NOT_EXIST;
}
Trace((stderr, "check_for_newer: stat(%s) returns 0: file exists\n",
FnFilter1(filename)));
#ifdef SYMLINKS
/* GRR OPTION: could instead do this test ONLY if G.symlnk is true */
if (lstat(filename, &G.statbuf) == 0 && S_ISLNK(G.statbuf.st_mode)) {
Trace((stderr, "check_for_newer: %s is a symbolic link\n",
FnFilter1(filename)));
if (QCOND2 && !IS_OVERWRT_ALL)
Info(slide, 0, ((char *)slide, LoadFarString(FileIsSymLink),
FnFilter1(filename), ""));
return EXISTS_AND_OLDER; /* symlink dates are meaningless */
}
#endif /* SYMLINKS */
NATIVE_TO_TIMET(G.statbuf.st_mtime) /* NOP unless MSC 7.0 or Macintosh */
unzip-6.0/fileio.c view on Meta::CPAN
#endif /* NO_STRNICMP */
#ifdef REGULUS /* returns the inode number on success(!)...argh argh argh */
# undef stat
/********************/
/* Function zstat() */
/********************/
int zstat(p, s)
ZCONST char *p;
struct stat *s;
{
return (stat((char *)p,s) >= 0? 0 : (-1));
}
#endif /* REGULUS */
#ifdef _MBCS
/* DBCS support for Info-ZIP's zip (mainly for japanese (-: )
unzip-6.0/flexos/flexos.c view on Meta::CPAN
while ((*end = *pathcomp++) != '\0')
++end;
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath 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. */
if ((end-buildpath) > FILNAMSIZ-3) /* need '/', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
if (stat(buildpath, &G.statbuf)) /* path doesn't exist */
{
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLong),
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
unzip-6.0/globals.h view on Meta::CPAN
int didCRlast; /* fileio static */
ulg numlines; /* fileio static: number of lines printed */
int sol; /* fileio static: at start of line */
int no_ecrec; /* process static */
#ifdef SYMLINKS
int symlnk;
slinkentry *slink_head; /* pointer to head of symlinks list */
slinkentry *slink_last; /* pointer to last entry in symlinks list */
#endif
#ifdef NOVELL_BUG_FAILSAFE
int dne; /* true if stat() says file doesn't exist */
#endif
FILE *outfile;
uch *outbuf;
uch *realbuf;
#ifndef VMS /* if SMALL_MEM, outbuf2 is initialized in */
uch *outbuf2; /* process_zipfiles() (never changes); */
#endif /* else malloc'd ONLY if unshrink and -a */
#endif /* !FUNZIP */
unzip-6.0/macos/Contents view on Meta::CPAN
source/ subdirectory containing all sources:
a) UnZip specific code
macbin3.c macbinary III code, used for extraction of ZipIt archives
macbin3.h macbinary III header, macbinary docu + public prototyping
macos.c Mac-specific filesystem code
maccfg.h Mac-specific configuration and global declarations
macdir.c Macintosh Posix-style directory emulation ("dirent")
macdir.h header file for directory emulation
macscreen.c screen functions to be used in standalone UnZip application
macstat.c Macintosh stat() emulation
macstat.h header file for stat() emulation
macunzip.c Macintosh standalone version main function
sxunzip.c main function for use with static library (SIOUX)
unzip_rc.hqx UnZip resource file for standalone application (BinHex)
b) general utilities shared between Zip and UnZip
charmap.h character mapping tables ISO 8859-1 <--> MacRoman
getenv.c simulation of unix compatible getenv() on MacOS
helpers.c some helper functions
helpers.h
macstuff.h wrapper to pull in some "MoreFiles" filemanager stuff
unzip-6.0/macos/source/macos.c view on Meta::CPAN
*(end = old_end + NAME_MAX) = '\0';
#endif
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath 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. */
if ((end-buildpath) > NAME_MAX-3) /* need ':', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLong),
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
unzip-6.0/macos/source/macos.c view on Meta::CPAN
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'; /* strip trailing delimiter */
}
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?) */
unzip-6.0/macos/source/macstat.c view on Meta::CPAN
/* Prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Functions */
/*****************************************************************************/
int UZmacstat(const char *path, struct stat *buf)
{
Boolean isDirectory;
long dirID;
char fullpath[NAME_MAX], UnmangledPath[NAME_MAX];
CInfoPBRec fpb;
HVolumeParam vpb;
FSSpec fileSpec;
OSErr err, err2;
short CurrentFork;
unzip-6.0/macos/source/macstat.h view on Meta::CPAN
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) /* = 00070 */
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) /* = 00007 */
extern int UZmacstat(const char *path, struct stat *buf);
#endif /* !__macstat_h */
unzip-6.0/match.c view on Meta::CPAN
s1++;
s2++;
}
} /* end function namecmp() */
#endif /* !THEOS */
int iswild(p) /* originally only used for stat()-bug workaround in */
ZCONST char *p; /* VAX C, Turbo/Borland C, Watcom C, Atari MiNT libs; */
{ /* now used in process_zipfiles() as well */
for (; *p; INCSTR(p))
if (*p == '\\' && *(p+1))
++p;
#ifdef THEOS
else if (*p == '?' || *p == '*' || *p=='#'|| *p == '@')
#else /* !THEOS */
#ifdef VMS
else if (*p == '%' || *p == '*')
unzip-6.0/msdos/doscfg.h view on Meta::CPAN
#ifdef __32BIT__
# if !defined(IZ_CRC_LE_OPTIMIZ) && !defined(NO_CRC_OPTIMIZ)
# define IZ_CRC_LE_OPTIMIZ
# endif
#else /* __16BIT__ does not support optimized C crc32 code */
# ifdef IZ_CRC_LE_OPTIMIZ
# undef IZ_CRC_LE_OPTIMIZ
# endif
#endif
/* another stat()/fopen() bug with some 16-bit compilers on Novell drives;
* very dangerous (silently overwrites executables in other directories)
*/
#define NOVELL_BUG_WORKAROUND
/* enables additional test and message code that directs UnZip to fail safely
* in case the "workaround" enabled above does not work as intended
*/
#define NOVELL_BUG_FAILSAFE
/* Some implementations of stat() tend to fail on "." in root directories
* or on remote (root) directories specified by an UNC network path. This
* patch of stat() is useful for at least the WATCOM compilers. The
* stat_bandaid() wrapper detects stat failures on root directories and
* fills in suitable values.
*/
#ifdef DOS_STAT_BANDAID
# ifdef SSTAT
# undef SSTAT
# endif
# ifdef WILD_STAT_BUG
# define SSTAT(path,pbuf) (iswild(path) || stat_bandaid(path,pbuf))
# else
unzip-6.0/msdos/msdos.c view on Meta::CPAN
#endif
#if !defined(S_ISCHR)
# if defined(_S_ISCHR)
# define S_ISCHR(m) _S_ISCHR(m)
# elif defined(S_IFCHR)
# define S_ISCHR(m) ((m) & S_IFCHR)
# endif
#endif
#ifdef DEBUG
if (stat(pathcomp, &G.statbuf) == 0) {
Trace((stderr,
"maskDOSdevice() stat(\"%s\", buf) st_mode result: %X, %o\n",
FnFilter1(pathcomp), G.statbuf.st_mode, G.statbuf.st_mode));
} else {
Trace((stderr, "maskDOSdevice() stat(\"%s\", buf) failed\n",
FnFilter1(pathcomp)));
}
#endif
if (stat(pathcomp, &G.statbuf) == 0 && S_ISCHR(G.statbuf.st_mode)) {
extent i;
/* pathcomp contains a name of a DOS character device (builtin or
* installed device driver).
* Prepend a '_' to allow creation of the item in the file system.
*/
for (i = strlen(pathcomp) + 1; i > 0; --i)
pathcomp[i] = pathcomp[i - 1];
pathcomp[0] = '_';
if (last_dot != (char *)NULL)
unzip-6.0/msdos/msdos.c view on Meta::CPAN
* exists and is not a directory, but is supposed to be
* MPN_ERR_TOOLONG - path is too long
* MPN_NOMEM - can't allocate memory for filename buffers
*/
{
static int rootlen = 0; /* length of rootpath */
static char *rootpath; /* user's "extract-to" directory */
static char *buildpath; /* full path (so far) to extracted file */
static char *end; /* pointer to end of buildpath ('\0') */
#ifdef MSC
int attrs; /* work around MSC stat() bug */
#endif
# 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
unzip-6.0/msdos/msdos.c view on Meta::CPAN
while ((*end = *pathcomp++) != '\0')
++end;
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath 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. */
if ((end-buildpath) > FILNAMSIZ-3) /* need '/', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
#ifdef MSC /* MSC 6.00 bug: stat(non-existent-dir) == 0 [exists!] */
if (_dos_getfileattr(buildpath, &attrs) || stat(buildpath, &G.statbuf))
#else
if (SSTAT(buildpath, &G.statbuf)) /* path doesn't exist */
#endif
{
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
/* path doesn't exist: nothing to do */
return MPN_INF_SKIP;
}
if (too_long) {
unzip-6.0/msdos/msdos.c view on Meta::CPAN
has_drive = TRUE; /* drive designator */
if (tmproot[rootlen-1] == '/' || tmproot[rootlen-1] == '\\') {
tmproot[--rootlen] = '\0';
had_trailing_pathsep = TRUE;
}
if (has_drive && (rootlen == 2)) {
if (!had_trailing_pathsep) /* i.e., original wasn't "x:/" */
add_dot = TRUE; /* relative path: add '.' before '/' */
} else if (rootlen > 0) { /* need not check "x:." and "x:/" */
#ifdef MSC
/* MSC 6.00 bug: stat(non-existent-dir) == 0 [exists!] */
if (_dos_getfileattr(tmproot, &attrs) ||
SSTAT(tmproot, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode))
#else
if (SSTAT(tmproot, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode))
#endif
{
/* path does not exist */
if (!G.create_dirs /* || iswild(tmproot) */ ) {
free(tmproot);
rootlen = 0;
unzip-6.0/msdos/msdos.c view on Meta::CPAN
regs.x.dx = __tb & 0x0f;
regs.x.ds = (__tb >> 4) & 0xffff;
_doserrno = __dpmi_int(0x21, ®s);
*(ush*)countrybuffer = _farpeekw(_dos_ds, __tb & 0xfffff);
return (unsigned)_doserrno;
}
/* Disable determination of "x" bit in st_mode field for [f]stat() calls. */
int _is_executable (const char *path, int fhandle, const char *ext)
{
return 0;
}
#ifndef USE_DJGPP_GLOB
/* Prevent globbing of filenames. This gives the same functionality as
* "stubedit <program> globbing=no" did with DJGPP v1.
*/
char **__crt0_glob_function(char *_arg)
unzip-6.0/msdos/msdos.c view on Meta::CPAN
}
#endif /* WATCOMC_386 */
#ifdef DOS_STAT_BANDAID
/* This papers over a bug in Watcom 10.6's standard library...sigh.
* Apparently it applies to both the DOS and Win32 stat()s. */
int stat_bandaid(const char *path, struct stat *buf)
{
char newname[4];
if (!stat(path, buf))
return 0;
else if (!strcmp(path, ".") || (path[0] && !strcmp(path + 1, ":."))) {
strcpy(newname, path);
newname[strlen(path) - 1] = '\\'; /* stat(".") fails for root! */
return stat(newname, buf);
} else
return -1;
}
#endif /* DOS_STAT_BANDAID */
#endif /* !FUNZIP */
unzip-6.0/netware/netware.c view on Meta::CPAN
*(end = old_end + FILENAME_MAX) = '\0';
#endif
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath 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. */
if ((end-buildpath) > FILNAMSIZ-3) /* need '/', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
/* path doesn't exist: nothing to do */
return MPN_INF_SKIP;
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
FnFilter1(buildpath)));
free(buildpath);
unzip-6.0/netware/netware.c view on Meta::CPAN
Trace((stderr, "initializing root path to [%s]\n",
FnFilter1(pathcomp)));
if (pathcomp == (char *)NULL) {
rootlen = 0;
return MPN_OK;
}
if ((rootlen = strlen(pathcomp)) > 0) {
if (pathcomp[rootlen-1] == '/') {
pathcomp[--rootlen] = '\0';
}
if (rootlen > 0 && (stat(pathcomp, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode))) /* path does not exist */
{
if (!G.create_dirs /* || iswild(pathcomp) */ ) {
rootlen = 0;
/* skip (or treat as stored file) */
return MPN_INF_SKIP;
}
/* create the directory (could add loop here to scan pathcomp
* and create more than one level, but why really necessary?) */
if (mkdir(pathcomp) == -1) {
unzip-6.0/os2/os2.c view on Meta::CPAN
}
}
else
if ( nbuf[len - 1] == ':' )
{
strcpy(nbuf+len, ".");
++len;
}
/* GRR: Borland and Watcom C return non-zero on wildcards... < 0 ? */
if (stat(nbuf, &statb) < 0 || (statb.st_mode & S_IFMT) != S_IFDIR)
{
Trace((stderr, "opendir: stat(%s) returns negative or not directory\n",
FnFilter1(nbuf)));
return NULL;
}
if ( (dirp = malloc(sizeof(DIR))) == NULL )
return NULL;
if ( nbuf[len - 1] == '.' && (len == 1 || nbuf[len - 2] != '.') )
strcpy(nbuf+len-1, "*");
else
unzip-6.0/os2/os2.c view on Meta::CPAN
}
/* GRR: could do better check, see if overrunning buffer as we go:
* check endHPFS-G.os2.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.os2.endHPFS-G.os2.buildpathHPFS) > FILNAMSIZ-3)
too_long = TRUE; /* check if extracting dir? */
#ifdef MSC /* MSC 6.00 bug: stat(non-existent-dir) == 0 [exists!] */
if (GetFileTime(G.os2.buildpathFAT) == -1 || stat(G.os2.buildpathFAT, &G.statbuf))
#else
if (stat(G.os2.buildpathFAT, &G.statbuf)) /* path doesn't exist */
#endif
{
if (!G.create_dirs) { /* told not to create (freshening) */
free(G.os2.buildpathHPFS);
free(G.os2.buildpathFAT);
/* path doesn't exist: nothing to do */
return MPN_INF_SKIP;
}
if (too_long) { /* GRR: should allow FAT extraction w/o EAs */
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLong),
unzip-6.0/os2/os2.c view on Meta::CPAN
if (isalpha((uch)tmproot[0]) && tmproot[1] == ':')
has_drive = TRUE; /* drive designator */
if (tmproot[G.os2.rootlen-1] == '/') {
tmproot[--G.os2.rootlen] = '\0';
had_trailing_pathsep = TRUE;
}
if (has_drive && (G.os2.rootlen == 2)) {
if (!had_trailing_pathsep) /* i.e., original wasn't "x:/" */
add_dot = TRUE; /* relative path: add '.' before '/' */
} else if (G.os2.rootlen > 0) { /* need not check "x:." and "x:/" */
#ifdef MSC /* MSC 6.00 bug: stat(non-existent-dir) == 0 [exists!] */
if (GetFileTime(tmproot) == -1 ||
SSTAT(tmproot, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode))
#else
if (SSTAT(tmproot, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode))
#endif
{ /* path does not exist */
if (!G.create_dirs /* || iswild(tmproot) */
) {
free(tmproot);
G.os2.rootlen = 0;
unzip-6.0/os2/os2data.h view on Meta::CPAN
char d_name[MAXNAMLEN + 1]; /* null terminated */
/* nonstandard fields */
long d_size; /* size in bytes */
unsigned d_mode; /* MS-DOS or OS/2 file attributes */
unsigned d_time;
unsigned d_date;
};
/* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel). The
* find_first and find_next calls deliver these data without any extra cost.
* If these data are needed, the fields save a lot of extra calls to stat()
* (each stat() again performs a find_first call !).
*/
struct _dircontents
{
char *_d_entry;
long _d_size;
unsigned _d_mode, _d_time, _d_date;
struct _dircontents *_d_next;
};
unzip-6.0/process.c view on Meta::CPAN
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();