From 5187da4c7671853c62272598b56fc1f1a7519acb Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 17 Mar 2026 19:51:06 -0400 Subject: [PATCH] Tracker: trash_dir to trashDir and call FSSetPoseLocation() Set status_t appropriately in FSSetPoseLocation() Change-Id: I7cadc4ff1727906ec44992c74d2f3c057ab1cc5f Reviewed-on: https://review.haiku-os.org/c/haiku/+/10632 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/kits/tracker/FSUtils.cpp | 44 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index fe7112422a..77c169917f 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -465,13 +465,15 @@ FSSetPoseLocation(ino_t destDirInode, BNode* destNode, BPoint point) poseInfo.fInitedDirectory = destDirInode; poseInfo.fLocation = point; - status_t result = destNode->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, + ssize_t bytesWritten = destNode->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, sizeof(poseInfo)); - if (result == sizeof(poseInfo)) + if (bytesWritten == sizeof(poseInfo)) return B_OK; - - return result; + else if (bytesWritten < 0) + return (status_t)bytesWritten; + else + return B_ERROR; } @@ -1190,14 +1192,8 @@ MoveTask(BObjectList* srcList, BEntry* destEntry, BList* pointL loc = (BPoint*)pointList->ItemAt(i); BNode* sourceNode = GetWritableNode(&sourceEntry); - if (sourceNode && sourceNode->InitCheck() == B_OK) { - PoseInfo poseInfo; - poseInfo.fInvisible = false; - poseInfo.fInitedDirectory = deststat.st_ino; - poseInfo.fLocation = *loc; - sourceNode->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, - sizeof(poseInfo)); - } + if (sourceNode != NULL && sourceNode->InitCheck() == B_OK) + FSSetPoseLocation(deststat.st_ino, sourceNode, *loc); delete sourceNode; } @@ -2028,7 +2024,7 @@ FSCopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir, static status_t MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) { - BDirectory trash_dir; + BDirectory trashDir; entry_ref ref; status_t result = entry->GetRef(&ref); if (result != B_OK) @@ -2074,15 +2070,15 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) } // get trash directory on same volume as item being moved - result = FSGetTrashDir(&trash_dir, nodeRef.device); + result = FSGetTrashDir(&trashDir, nodeRef.device); if (result != B_OK) return result; // check hierarchy before moving BEntry trashEntry; - trash_dir.GetEntry(&trashEntry); + trashDir.GetEntry(&trashEntry); - if (dir == trash_dir || dir.Contains(&trashEntry)) { + if (dir == trashDir || dir.Contains(&trashEntry)) { BAlert* alert = new BAlert("", B_TRANSLATE("You cannot put the selected item(s) " "into the trash."), @@ -2104,7 +2100,7 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) be_app->PostMessage(&message); } else { // get trash directory on same volume as item being moved - result = FSGetTrashDir(&trash_dir, nodeRef.device); + result = FSGetTrashDir(&trashDir, nodeRef.device); if (result != B_OK) return result; } @@ -2112,21 +2108,17 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) // make sure name doesn't conflict with anything in trash already char name[B_FILE_NAME_LENGTH]; strlcpy(name, ref.name, sizeof(name)); - if (trash_dir.Contains(name)) { + if (trashDir.Contains(name)) { BString suffix(" "); suffix << B_TRANSLATE_COMMENT("copy", "filename copy"), - FSMakeOriginalName(name, &trash_dir, suffix.String()); + FSMakeOriginalName(name, &trashDir, suffix.String()); undo.UpdateEntry(entry, name); } BNode* sourceNode = 0; if (loc && loc != (BPoint*)-1 && (sourceNode = GetWritableNode(entry, &statbuf)) != 0) { - trash_dir.GetStat(&statbuf); - PoseInfo poseInfo; - poseInfo.fInvisible = false; - poseInfo.fInitedDirectory = statbuf.st_ino; - poseInfo.fLocation = *loc; - sourceNode->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, sizeof(poseInfo)); + trashDir.GetStat(&statbuf); + FSSetPoseLocation(statbuf.st_ino, sourceNode, *loc); delete sourceNode; } @@ -2140,7 +2132,7 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) } TrackerCopyLoopControl loopControl; - MoveItem(entry, &trash_dir, loc, kMoveSelectionTo, name, undo, &loopControl); + MoveItem(entry, &trashDir, loc, kMoveSelectionTo, name, undo, &loopControl); return B_OK; }