Only write the icons if we did in fact have to freshly create the Trash directory. Should fix #5827 completely.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36522 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2010-04-28 20:17:30 +00:00
parent 0872569da9
commit ca34b4221c
+38 -30
View File
@@ -2362,7 +2362,13 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev)
return result; return result;
BPath path; BPath path;
result = find_directory(B_TRASH_DIRECTORY, &path, true, &volume); 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) if (result != B_OK)
return result; return result;
@@ -2370,38 +2376,40 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev)
if (result != B_OK) if (result != B_OK)
return result; return result;
// make trash invisible if (created)
StatStruct sbuf; {
trashDir->GetStat(&sbuf); // make trash invisible
StatStruct sbuf;
trashDir->GetStat(&sbuf);
PoseInfo poseInfo; PoseInfo poseInfo;
poseInfo.fInvisible = true; poseInfo.fInvisible = true;
poseInfo.fInitedDirectory = sbuf.st_ino; poseInfo.fInitedDirectory = sbuf.st_ino;
trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo,
sizeof(PoseInfo)); sizeof(PoseInfo));
size_t size; size_t size;
const void* data = GetTrackerResources()-> const void* data = GetTrackerResources()->
LoadResource('ICON', R_TrashIcon, &size); 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()-> data = GetTrackerResources()->
LoadResource('MICN', R_TrashIcon, &size); LoadResource('MICN', R_TrashIcon, &size);
if (data != NULL) { if (data != NULL) {
trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0,
data, size); data, size);
} }
// TODO: figure out why writing the vector icon seems broken. #ifdef __HAIKU__
#if 0 data = GetTrackerResources()->
data = GetTrackerResources()-> LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size);
LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size); if (data != NULL) {
if (data != NULL) { trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0,
trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, data, size);
data, size); }
}
#endif #endif
}
return B_OK; return B_OK;
} }