* 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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user