cabinet: Simplify concatenation of path and filename.
This commit is contained in:
parent
8b6f917518
commit
94bfd24f67
@ -2041,7 +2041,7 @@ static int fdi_decomp(const struct fdi_file *fi, int savemode, fdi_decomp_state
|
|||||||
/* outlen=0 means this block was the last contiguous part
|
/* outlen=0 means this block was the last contiguous part
|
||||||
of a split block, continued in the next cabinet */
|
of a split block, continued in the next cabinet */
|
||||||
if (outlen == 0) {
|
if (outlen == 0) {
|
||||||
int pathlen, filenamelen, idx, i;
|
int pathlen, filenamelen, i;
|
||||||
INT_PTR cabhf;
|
INT_PTR cabhf;
|
||||||
char fullpath[MAX_PATH], userpath[256];
|
char fullpath[MAX_PATH], userpath[256];
|
||||||
FDINOTIFICATION fdin;
|
FDINOTIFICATION fdin;
|
||||||
@ -2065,18 +2065,16 @@ static int fdi_decomp(const struct fdi_file *fi, int savemode, fdi_decomp_state
|
|||||||
|
|
||||||
/* copy pszCabPath to userpath */
|
/* copy pszCabPath to userpath */
|
||||||
ZeroMemory(userpath, 256);
|
ZeroMemory(userpath, 256);
|
||||||
pathlen = (pszCabPath) ? strlen(pszCabPath) : 0;
|
pathlen = pszCabPath ? strlen(pszCabPath) : 0;
|
||||||
if (pathlen) {
|
if (pathlen) {
|
||||||
if (pathlen < 256) {
|
if (pathlen < 256) /* else we are in a weird place... let's leave it blank and see if the user fixes it */
|
||||||
for (i = 0; i <= pathlen; i++)
|
strcpy(userpath, pszCabPath);
|
||||||
userpath[i] = pszCabPath[i];
|
|
||||||
} /* else we are in a weird place... let's leave it blank and see if the user fixes it */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initial fdintNEXT_CABINET notification */
|
/* initial fdintNEXT_CABINET notification */
|
||||||
ZeroMemory(&fdin, sizeof(FDINOTIFICATION));
|
ZeroMemory(&fdin, sizeof(FDINOTIFICATION));
|
||||||
fdin.psz1 = (cab->mii.nextname) ? cab->mii.nextname : &emptystring;
|
fdin.psz1 = cab->mii.nextname ? cab->mii.nextname : &emptystring;
|
||||||
fdin.psz2 = (cab->mii.nextinfo) ? cab->mii.nextinfo : &emptystring;
|
fdin.psz2 = cab->mii.nextinfo ? cab->mii.nextinfo : &emptystring;
|
||||||
fdin.psz3 = userpath;
|
fdin.psz3 = userpath;
|
||||||
fdin.fdie = FDIERROR_NONE;
|
fdin.fdie = FDIERROR_NONE;
|
||||||
fdin.pv = pvUser;
|
fdin.pv = pvUser;
|
||||||
@ -2086,7 +2084,7 @@ static int fdi_decomp(const struct fdi_file *fi, int savemode, fdi_decomp_state
|
|||||||
do {
|
do {
|
||||||
|
|
||||||
pathlen = strlen(userpath);
|
pathlen = strlen(userpath);
|
||||||
filenamelen = (cab->mii.nextname) ? strlen(cab->mii.nextname) : 0;
|
filenamelen = cab->mii.nextname ? strlen(cab->mii.nextname) : 0;
|
||||||
|
|
||||||
/* slight overestimation here to save CPU cycles in the developer's brain */
|
/* slight overestimation here to save CPU cycles in the developer's brain */
|
||||||
if ((pathlen + filenamelen + 3) > MAX_PATH) {
|
if ((pathlen + filenamelen + 3) > MAX_PATH) {
|
||||||
@ -2095,13 +2093,14 @@ static int fdi_decomp(const struct fdi_file *fi, int savemode, fdi_decomp_state
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* paste the path and filename together */
|
/* paste the path and filename together */
|
||||||
idx = 0;
|
fullpath[0] = '\0';
|
||||||
if (pathlen) {
|
if (pathlen) {
|
||||||
for (i = 0; i < pathlen; i++) fullpath[idx++] = userpath[i];
|
strcpy(fullpath, userpath);
|
||||||
if (fullpath[idx - 1] != '\\') fullpath[idx++] = '\\';
|
if (fullpath[pathlen - 1] != '\\')
|
||||||
|
strcat(fullpath, "\\");
|
||||||
}
|
}
|
||||||
if (filenamelen) for (i = 0; i < filenamelen; i++) fullpath[idx++] = cab->mii.nextname[i];
|
if (filenamelen)
|
||||||
fullpath[idx] = '\0';
|
strcat(fullpath, cab->mii.nextname);
|
||||||
|
|
||||||
TRACE("full cab path/file name: %s\n", debugstr_a(fullpath));
|
TRACE("full cab path/file name: %s\n", debugstr_a(fullpath));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user