diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index c10c9e7521..1fc569d8e2 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -2362,13 +2362,19 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev) return result; BPath path; - bool created = false; result = find_directory(B_TRASH_DIRECTORY, &path, false, &volume); - if (result != B_OK) { - result = find_directory(B_TRASH_DIRECTORY, &path, true, - &volume); - created = true; + if (result != B_OK) + return result; + + result = trashDir->SetTo(path.Path()); + if (result == B_OK) { + // Directory already exists, we're done + return B_OK; } + + // The trash directory does not exist yet - change that! + + result = create_directory(path.Path(), 0755); if (result != B_OK) return result; @@ -2376,40 +2382,31 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev) if (result != B_OK) return result; - if (created) - { - // make trash invisible - StatStruct sbuf; - trashDir->GetStat(&sbuf); + // make trash invisible + StatStruct sbuf; + trashDir->GetStat(&sbuf); - PoseInfo poseInfo; - poseInfo.fInvisible = true; - poseInfo.fInitedDirectory = sbuf.st_ino; - trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, - sizeof(PoseInfo)); + PoseInfo poseInfo; + poseInfo.fInvisible = true; + poseInfo.fInitedDirectory = sbuf.st_ino; + trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, + sizeof(PoseInfo)); - size_t size; - const void* data = GetTrackerResources()-> - LoadResource('ICON', R_TrashIcon, &size); - if (data != NULL) { - trashDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, - data, size); - } - data = GetTrackerResources()-> - LoadResource('MICN', R_TrashIcon, &size); - if (data != NULL) { - trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, - data, size); - } -#ifdef __HAIKU__ - data = GetTrackerResources()-> - LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size); - if (data != NULL) { - trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, - data, size); - } -#endif - } + // set trash icon + size_t size; + const void* data + = GetTrackerResources()->LoadResource('ICON', R_TrashIcon, &size); + if (data != NULL) + trashDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, data, size); + + data = GetTrackerResources()->LoadResource('MICN', R_TrashIcon, &size); + if (data != NULL) + trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size); + + data = GetTrackerResources()->LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, + &size); + if (data != NULL) + trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, data, size); return B_OK; }