Update Installer's empty volume check to work with the new trash
directory locations. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35109 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -242,7 +242,7 @@ WorkerThread::_PerformInstall(BMenu* srcMenu, BMenu* targetMenu)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
BPath targetDirectory, srcDirectory;
|
BPath targetDirectory, srcDirectory, trashPath, testPath;
|
||||||
BDirectory targetDir;
|
BDirectory targetDir;
|
||||||
BDiskDevice device;
|
BDiskDevice device;
|
||||||
BPartition* partition;
|
BPartition* partition;
|
||||||
@@ -342,49 +342,26 @@ WorkerThread::_PerformInstall(BMenu* srcMenu, BMenu* targetMenu)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if target volume's trash dir has anything in it
|
||||||
|
// (target volume w/ only an empty trash dir is considered
|
||||||
|
// an empty volume)
|
||||||
|
if (find_directory(B_TRASH_DIRECTORY, &trashPath, false,
|
||||||
|
&targetVolume) == B_OK && targetDir.SetTo(trashPath.Path()) == B_OK) {
|
||||||
|
while (targetDir.GetNextRef(&testRef) == B_OK) {
|
||||||
|
// Something in the Trash
|
||||||
|
entries++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
targetDir.SetTo(targetDirectory.Path());
|
targetDir.SetTo(targetDirectory.Path());
|
||||||
|
|
||||||
// check target volume not empty
|
// check if target volume otherwise has any entries
|
||||||
// NOTE: It's ok if exactly this path exists: home/Desktop/Trash
|
while (entries == 0 && targetDir.GetNextRef(&testRef) == B_OK) {
|
||||||
// and nothing else.
|
if (testPath.SetTo(&testRef) == B_OK && testPath != trashPath)
|
||||||
while (targetDir.GetNextRef(&testRef) == B_OK) {
|
|
||||||
if (strcmp(testRef.name, "home") == 0) {
|
|
||||||
BDirectory homeDir(&testRef);
|
|
||||||
while (homeDir.GetNextRef(&testRef) == B_OK) {
|
|
||||||
if (strcmp(testRef.name, "Desktop") == 0) {
|
|
||||||
BDirectory desktopDir(&testRef);
|
|
||||||
while (desktopDir.GetNextRef(&testRef) == B_OK) {
|
|
||||||
if (strcmp(testRef.name, "Trash") == 0) {
|
|
||||||
BDirectory trashDir(&testRef);
|
|
||||||
while (trashDir.GetNextRef(&testRef) == B_OK) {
|
|
||||||
// Something in the Trash
|
|
||||||
entries++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Something besides Trash
|
|
||||||
entries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entries > 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Something besides Desktop
|
|
||||||
entries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entries > 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Something besides home
|
|
||||||
entries++;
|
entries++;
|
||||||
}
|
|
||||||
|
|
||||||
if (entries > 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries != 0
|
if (entries != 0
|
||||||
&& ((new BAlert("", "The target volume is not empty. Are you sure you "
|
&& ((new BAlert("", "The target volume is not empty. Are you sure you "
|
||||||
"want to install anyway?\n\nNote: The 'system' folder will be a "
|
"want to install anyway?\n\nNote: The 'system' folder will be a "
|
||||||
|
|||||||
Reference in New Issue
Block a user