LegacyPackageInstaller: Correct previous commit.

The test in the previous commit had a totally flawed invocation of strcmp().
I probably shouldn't attempt to write C code without consulting the manual.

Even if it had worked, it would have worked on too many cases, including
some volume paths. So I reordered the if statement and added it in there.
This commit is contained in:
Augustin Cavalier 2016-07-23 10:41:24 -04:00
parent 8cf0752f1b
commit af3057423c
1 changed files with 8 additions and 10 deletions

View File

@ -179,10 +179,14 @@ PackageItem::InitPath(const char* path, BPath* destination)
// If the path starts with /boot/, treat it as a P_SYSTEM_PATH.
// This may not be the correct way to handle such a case, but it fixes
// installation of the RefLine pkg.
if (strcmp("/boot/", path))
fPathType = P_SYSTEM_PATH;
if (fPathType == P_INSTALL_PATH) {
if (fPathType == P_SYSTEM_PATH || (fPathType == P_INSTALL_PATH
&& strncmp("/boot/", path, 6) == 0)) {
if (gVerbose)
printf("InitPath - absolute: %s\n", fPath.String());
if (fPath == "")
fPath = "/";
ret = destination->SetTo(fPath.String());
} else if (fPathType == P_INSTALL_PATH) {
if (gVerbose)
printf("InitPath - relative: %s + %s\n", path, fPath.String());
if (path == NULL) {
@ -190,12 +194,6 @@ PackageItem::InitPath(const char* path, BPath* destination)
return B_ERROR;
}
ret = destination->SetTo(path, fPath.String());
} else if (fPathType == P_SYSTEM_PATH) {
if (gVerbose)
printf("InitPath - absolute: %s\n", fPath.String());
if (fPath == "")
fPath = "/";
ret = destination->SetTo(fPath.String());
} else {
if (gVerbose)
printf("InitPath - volume: %s + %s\n", path, fPath.String());