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 <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
2d172c081f
commit
5187da4c76
@@ -465,13 +465,15 @@ FSSetPoseLocation(ino_t destDirInode, BNode* destNode, BPoint point)
|
|||||||
poseInfo.fInitedDirectory = destDirInode;
|
poseInfo.fInitedDirectory = destDirInode;
|
||||||
poseInfo.fLocation = point;
|
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));
|
&poseInfo, sizeof(poseInfo));
|
||||||
|
|
||||||
if (result == sizeof(poseInfo))
|
if (bytesWritten == sizeof(poseInfo))
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
else if (bytesWritten < 0)
|
||||||
return result;
|
return (status_t)bytesWritten;
|
||||||
|
else
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1190,14 +1192,8 @@ MoveTask(BObjectList<entry_ref, true>* srcList, BEntry* destEntry, BList* pointL
|
|||||||
loc = (BPoint*)pointList->ItemAt(i);
|
loc = (BPoint*)pointList->ItemAt(i);
|
||||||
|
|
||||||
BNode* sourceNode = GetWritableNode(&sourceEntry);
|
BNode* sourceNode = GetWritableNode(&sourceEntry);
|
||||||
if (sourceNode && sourceNode->InitCheck() == B_OK) {
|
if (sourceNode != NULL && sourceNode->InitCheck() == B_OK)
|
||||||
PoseInfo poseInfo;
|
FSSetPoseLocation(deststat.st_ino, sourceNode, *loc);
|
||||||
poseInfo.fInvisible = false;
|
|
||||||
poseInfo.fInitedDirectory = deststat.st_ino;
|
|
||||||
poseInfo.fLocation = *loc;
|
|
||||||
sourceNode->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo,
|
|
||||||
sizeof(poseInfo));
|
|
||||||
}
|
|
||||||
delete sourceNode;
|
delete sourceNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2028,7 +2024,7 @@ FSCopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
static status_t
|
static status_t
|
||||||
MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
||||||
{
|
{
|
||||||
BDirectory trash_dir;
|
BDirectory trashDir;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
status_t result = entry->GetRef(&ref);
|
status_t result = entry->GetRef(&ref);
|
||||||
if (result != B_OK)
|
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
|
// 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)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// check hierarchy before moving
|
// check hierarchy before moving
|
||||||
BEntry trashEntry;
|
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("",
|
BAlert* alert = new BAlert("",
|
||||||
B_TRANSLATE("You cannot put the selected item(s) "
|
B_TRANSLATE("You cannot put the selected item(s) "
|
||||||
"into the trash."),
|
"into the trash."),
|
||||||
@@ -2104,7 +2100,7 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
|||||||
be_app->PostMessage(&message);
|
be_app->PostMessage(&message);
|
||||||
} else {
|
} else {
|
||||||
// get trash directory on same volume as item being moved
|
// 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)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -2112,21 +2108,17 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
|||||||
// make sure name doesn't conflict with anything in trash already
|
// make sure name doesn't conflict with anything in trash already
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
strlcpy(name, ref.name, sizeof(name));
|
strlcpy(name, ref.name, sizeof(name));
|
||||||
if (trash_dir.Contains(name)) {
|
if (trashDir.Contains(name)) {
|
||||||
BString suffix(" ");
|
BString suffix(" ");
|
||||||
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
||||||
FSMakeOriginalName(name, &trash_dir, suffix.String());
|
FSMakeOriginalName(name, &trashDir, suffix.String());
|
||||||
undo.UpdateEntry(entry, name);
|
undo.UpdateEntry(entry, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
BNode* sourceNode = 0;
|
BNode* sourceNode = 0;
|
||||||
if (loc && loc != (BPoint*)-1 && (sourceNode = GetWritableNode(entry, &statbuf)) != 0) {
|
if (loc && loc != (BPoint*)-1 && (sourceNode = GetWritableNode(entry, &statbuf)) != 0) {
|
||||||
trash_dir.GetStat(&statbuf);
|
trashDir.GetStat(&statbuf);
|
||||||
PoseInfo poseInfo;
|
FSSetPoseLocation(statbuf.st_ino, sourceNode, *loc);
|
||||||
poseInfo.fInvisible = false;
|
|
||||||
poseInfo.fInitedDirectory = statbuf.st_ino;
|
|
||||||
poseInfo.fLocation = *loc;
|
|
||||||
sourceNode->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, sizeof(poseInfo));
|
|
||||||
delete sourceNode;
|
delete sourceNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2140,7 +2132,7 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrackerCopyLoopControl loopControl;
|
TrackerCopyLoopControl loopControl;
|
||||||
MoveItem(entry, &trash_dir, loc, kMoveSelectionTo, name, undo, &loopControl);
|
MoveItem(entry, &trashDir, loc, kMoveSelectionTo, name, undo, &loopControl);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user