Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/msdos/msdos.c view on Meta::CPAN
} else if (!S_ISDIR(G.statbuf.st_mode)) {
Info(slide, 1, ((char *)slide, LoadFarString(DirIsntDirectory),
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path existed but wasn't dir */
return MPN_ERR_SKIP;
}
if (too_long) {
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLong),
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
*end++ = '/';
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
return MPN_OK;
} /* end if (FUNCTION == APPEND_DIR) */
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
buildpath.
---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) {
strcpy(pathcomp, buildpath);
Trace((stderr, "getting and freeing path [%s]\n",
FnFilter1(pathcomp)));
free(buildpath);
buildpath = end = (char *)NULL;
return MPN_OK;
}
/*---------------------------------------------------------------------------
APPEND_NAME: assume the path component is the filename; append it and
return without checking for existence.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_NAME) {
#ifdef NOVELL_BUG_WORKAROUND
if (end == buildpath && !G.pInfo->vollabel) {
/* work-around for Novell's "overwriting executables" bug:
prepend "./" to name when no path component is specified */
*end++ = '.';
*end++ = '/';
}
#endif /* NOVELL_BUG_WORKAROUND */
Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0') {
++end;
if ((end-buildpath) >= FILNAMSIZ) {
*--end = '\0';
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLongTrunc),
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.
---------------------------------------------------------------------------*/
if (FUNCTION == INIT) {
Trace((stderr, "initializing buildpath to "));
/* allocate space for full filename, root path, and maybe "./" */
if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+3)) ==
(char *)NULL)
return MPN_NOMEM;
if (G.pInfo->vollabel) {
/* GRR: for network drives, do strchr() and return IZ_VOL_LABEL if not [1] */
if (renamed_fullpath && pathcomp[1] == ':')
*buildpath = (char)ToLower(*pathcomp);
else if (!renamed_fullpath && rootlen > 1 && rootpath[1] == ':')
*buildpath = (char)ToLower(*rootpath);
else {
GETDRIVE(nLabelDrive); /* assumed that a == 1, b == 2, etc. */
*buildpath = (char)(nLabelDrive - 1 + 'a');
}
nLabelDrive = *buildpath - 'a' + 1; /* save for mapname() */
if (uO.volflag == 0 || *buildpath < 'a' || /* no label/bogus disk */
(uO.volflag == 1 && !isfloppy(nLabelDrive))) /* -$: no fixed */
{
free(buildpath);
return MPN_VOL_LABEL; /* skipping with message */
}
*buildpath = '\0';
end = buildpath;
} else if (renamed_fullpath) { /* pathcomp = valid data */
end = buildpath;
while ((*end = *pathcomp++) != '\0')
++end;
} else if (rootlen > 0) {
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 neces-
sary; 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. Note that under OS/2 and MS-DOS, if a candidate extract-to
directory specification includes a drive letter (leading "x:"), it is
treated just as if it had a trailing '/'--that is, one directory level
will be created if the path doesn't exist, unless this is otherwise pro-
hibited (e.g., freshening).
---------------------------------------------------------------------------*/
( run in 0.547 second using v1.01-cache-2.11-cpan-6aa56a78535 )