Database::Delete() now supports deleting super types as well (by deleting all

sub types first).
Also, if removing the type from the supporting application lists fails, this
is no longer propagated to the user - the MIME type got deleted after all,
and that's the purpose of this function.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16651 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-03-08 15:54:51 +00:00
parent c8b86e7067
commit bf2657c5d7

View File

@ -143,20 +143,45 @@ Database::Delete(const char *type)
// Open the type
BEntry entry;
status_t err = entry.SetTo(type_to_filename(type).c_str());
status_t status = entry.SetTo(type_to_filename(type).c_str());
if (status != B_OK)
return status;
// Remove it
if (!err)
err = entry.Remove();
if (entry.IsDirectory()) {
// We need to remove all files in this directory
BDirectory directory(&entry);
if (directory.InitCheck() == B_OK) {
size_t length = strlen(type);
char subType[B_PATH_NAME_LENGTH];
memcpy(subType, type, length);
subType[length++] = '/';
BEntry subEntry;
while (directory.GetNextEntry(&subEntry) == B_OK) {
// Construct MIME type and remove it
if (subEntry.GetName(subType + length) == B_OK) {
status = Delete(subType);
if (status != B_OK)
return status;
}
}
}
}
status = entry.Remove();
// Notify the installed types database
if (!err)
if (status != B_OK)
fInstalledTypes.RemoveType(type);
// Notify the supporting apps database
if (!err)
err = fSupportingApps.DeleteSupportedTypes(type, true);
if (status != B_OK)
fSupportingApps.DeleteSupportedTypes(type, true);
// Notify the monitor service
if (!err)
if (status != B_OK)
_SendDeleteNotification(type);
return err;
return status;
}