* Neither ours nor BeOS' find_directory() will return an error if the directory

does not exist yet.
* Therefore, only BDirectory::SetTo() will fail if the trash does not exist
  yet. Changed the code to actually work as expected, now.
* Fixed old and new style violations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-04-29 07:37:06 +00:00
parent d62afe7ab0
commit 0230fc14ea
+25 -28
View File
@@ -2362,13 +2362,19 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev)
return result; return result;
BPath path; BPath path;
bool created = false;
result = find_directory(B_TRASH_DIRECTORY, &path, false, &volume); result = find_directory(B_TRASH_DIRECTORY, &path, false, &volume);
if (result != B_OK) { if (result != B_OK)
result = find_directory(B_TRASH_DIRECTORY, &path, true, return result;
&volume);
created = true; 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) if (result != B_OK)
return result; return result;
@@ -2376,8 +2382,6 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev)
if (result != B_OK) if (result != B_OK)
return result; return result;
if (created)
{
// make trash invisible // make trash invisible
StatStruct sbuf; StatStruct sbuf;
trashDir->GetStat(&sbuf); trashDir->GetStat(&sbuf);
@@ -2388,28 +2392,21 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev)
trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo,
sizeof(PoseInfo)); sizeof(PoseInfo));
// set trash icon
size_t size; size_t size;
const void* data = GetTrackerResources()-> const void* data
LoadResource('ICON', R_TrashIcon, &size); = GetTrackerResources()->LoadResource('ICON', R_TrashIcon, &size);
if (data != NULL) { if (data != NULL)
trashDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, trashDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, data, size);
data, size);
} data = GetTrackerResources()->LoadResource('MICN', R_TrashIcon, &size);
data = GetTrackerResources()-> if (data != NULL)
LoadResource('MICN', R_TrashIcon, &size); trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size);
if (data != NULL) {
trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data = GetTrackerResources()->LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon,
data, size); &size);
} if (data != NULL)
#ifdef __HAIKU__ trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 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);
}
#endif
}
return B_OK; return B_OK;
} }