Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/os2/os2.c view on Meta::CPAN
/* The buildpathHPFS buffer has been allocated large enough to
* hold the complete combined name, so there is no need to check
* for OS filename size limit overflow within the copy loop.
*/
while ((*G.os2.endHPFS = *p++) != '\0') { /* copy to HPFS filename */
++G.os2.endHPFS;
}
/* Now, check for OS filename size overflow. When detected, the
* mapped HPFS name is truncated and a warning message is shown.
*/
if ((G.os2.endHPFS-G.os2.buildpathHPFS) >= FILNAMSIZ) {
G.os2.buildpathHPFS[FILNAMSIZ-1] = '\0';
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLongTrunc),
FnFilter1(G.filename), FnFilter2(G.os2.buildpathHPFS)));
error = MPN_INF_TRUNC; /* filename truncated */
}
/* GRR: how can longnameEA ever be set before this point??? we don't want
* to save the original name to EAs if user renamed it, do we?
*
* if (!G.os2.longnameEA && ((G.os2.longnameEA = !IsFileNameValid(name)) != 0))
*/
/* The buildpathFAT buffer has the same allocated size as the
* buildpathHPFS buffer, so there is no need for an overflow check
* within the following copy loop, either.
*/
if (G.pInfo->vollabel || IsFileNameValid(G.os2.buildpathHPFS)) {
G.os2.longnameEA = FALSE;
/* copy to FAT filename, too */
p = pathcomp;
while ((*G.os2.endFAT = *p++) != '\0')
++G.os2.endFAT;
} else {
G.os2.longnameEA = TRUE;
if ((G.os2.lastpathcomp = (char *)malloc(strlen(pathcomp)+1)) ==
(char *)NULL)
{
Info(slide, 1, ((char *)slide,
"checkdir warning: cannot save longname EA: out of memory\n"));
G.os2.longnameEA = FALSE;
/* can't set .LONGNAME extended attribute */
error = MPN_INF_TRUNC;
} else /* used and freed in close_outfile() */
strcpy(G.os2.lastpathcomp, pathcomp);
/* map, put in FAT fn, update endFAT */
map2fat(pathcomp, &G.os2.endFAT);
}
/* Check that the FAT path does not exceed the FILNAMSIZ limit, and
* truncate when neccessary.
* Note that truncation can only happen when the HPFS path (which is
* never shorter than the FAT path) has been already truncated.
* So, emission of the warning message and setting the error code
* has already happened.
*/
if ((G.os2.endFAT-G.os2.buildpathFAT) >= FILNAMSIZ)
G.os2.buildpathFAT[FILNAMSIZ-1] = '\0';
Trace((stderr, "buildpathHPFS: %s\nbuildpathFAT: %s\n",
FnFilter1(G.os2.buildpathHPFS), FnFilter2(G.os2.buildpathFAT)));
return error; /* could check for existence, prompt for new name... */
} /* end if (FUNCTION == APPEND_NAME) */
/*---------------------------------------------------------------------------
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 buildpathHPFS and buildpathFAT to "));
#ifdef ACORN_FTYPE_NFS
if ((G.os2.buildpathHPFS = (char *)malloc(G.os2.fnlen+G.os2.rootlen+
(uO.acorn_nfs_ext ? 5 : 1)))
#else
if ((G.os2.buildpathHPFS = (char *)malloc(G.os2.fnlen+G.os2.rootlen+1))
#endif
== (char *)NULL)
return MPN_NOMEM;
#ifdef ACORN_FTYPE_NFS
if ((G.os2.buildpathFAT = (char *)malloc(G.os2.fnlen+G.os2.rootlen+
(uO.acorn_nfs_ext ? 5 : 1)))
#else
if ((G.os2.buildpathFAT = (char *)malloc(G.os2.fnlen+G.os2.rootlen+1))
#endif
== (char *)NULL) {
free(G.os2.buildpathHPFS);
return MPN_NOMEM;
}
if (G.pInfo->vollabel) { /* use root or renamed path, but don't store */
/* GRR: for network drives, do strchr() and return IZ_VOL_LABEL if not [1] */
if (G.os2.renamed_fullpath && pathcomp[1] == ':')
*G.os2.buildpathHPFS = (char)ToLower(*pathcomp);
else if (!G.os2.renamed_fullpath && G.os2.rootlen > 1 && G.os2.rootpath[1] == ':')
*G.os2.buildpathHPFS = (char)ToLower(*G.os2.rootpath);
else {
ULONG lMap;
DosQueryCurrentDisk(&G.os2.nLabelDrive, &lMap);
*G.os2.buildpathHPFS = (char)(G.os2.nLabelDrive - 1 + 'a');
}
G.os2.nLabelDrive = *G.os2.buildpathHPFS - 'a' + 1; /* save for mapname() */
if (uO.volflag == 0 || *G.os2.buildpathHPFS < 'a' || /* no labels/bogus? */
(uO.volflag == 1 && !isfloppy(G.os2.nLabelDrive))) { /* -$: no fixed */
free(G.os2.buildpathHPFS);
free(G.os2.buildpathFAT);
return MPN_VOL_LABEL; /* skipping with message */
}
*G.os2.buildpathHPFS = '\0';
} else if (G.os2.renamed_fullpath) /* pathcomp = valid data */
strcpy(G.os2.buildpathHPFS, pathcomp);
else if (G.os2.rootlen > 0)
strcpy(G.os2.buildpathHPFS, G.os2.rootpath);
else
*G.os2.buildpathHPFS = '\0';
G.os2.endHPFS = G.os2.buildpathHPFS;
G.os2.endFAT = G.os2.buildpathFAT;
while ((*G.os2.endFAT = *G.os2.endHPFS) != '\0') {
++G.os2.endFAT;
++G.os2.endHPFS;
}
( run in 3.701 seconds using v1.01-cache-2.11-cpan-a49fcb8fa48 )