Move CheckDevicesEqual into FSUtils so it can be used in more places.

Rework ContainerWindow's B_REFS_RECEIVED to use CheckDevicesEqual to decide move vs copy as is done elsewhere.

Fixes ticket #4850.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33803 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2009-10-28 03:04:42 +00:00
parent 145eef6021
commit d3b113282a
4 changed files with 20 additions and 35 deletions

View File

@ -1577,31 +1577,14 @@ BContainerWindow::MessageReceived(BMessage *message)
//
// compare the target and one of the drag items' parent
//
BEntry item(&dragref, true);
BEntry itemparent;
item.GetParent(&itemparent);
entry_ref parentref;
itemparent.GetRef(&parentref);
entry_ref targetref;
entry.GetRef(&targetref);
// if they don't match, move/copy
if (targetref != parentref) {
uint32 moveMode = kMoveSelectionTo;
node_ref targetNode;
node_ref parentNode;
if (entry.GetNodeRef(&targetNode) == B_OK
&& itemparent.GetNodeRef(&parentNode)
== B_OK) {
if (targetNode.device != parentNode.device)
moveMode = kCopySelectionTo;
}
// copy drag contents to target ref in message
FSMoveToFolder(list, new BEntry(entry),
uint32 moveMode = kMoveSelectionTo;
Model targetModel(&entry, true, false);
if (!CheckDevicesEqual(list->ItemAt(0), &targetModel))
moveMode = kCopySelectionTo;
// copy drag contents to target ref in message
FSMoveToFolder(list, new BEntry(entry),
moveMode);
}
targetModel.CloseNode();
} else {
// current message sent to apps is only B_REFS_RECEIVED
fDragMessage->what = B_REFS_RECEIVED;

View File

@ -290,6 +290,17 @@ GetWritableNode(BEntry *entry, StatStruct *statBuf = 0)
}
bool
CheckDevicesEqual(const entry_ref *srcRef, const Model *targetModel)
{
BDirectory destDir (targetModel->EntryRef());
struct stat deststat;
destDir.GetStat(&deststat);
return srcRef->device == deststat.st_dev;
}
status_t
FSSetPoseLocation(ino_t destDirInode, BNode *destNode, BPoint point)
{

View File

@ -229,6 +229,8 @@ bool FSIsDeskDir(const BEntry *, dev_t);
bool ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *action,
bool dontAsk = false, int32 *confirmedAlready = NULL);
bool CheckDevicesEqual(const entry_ref *entry, const Model *targetModel);
// Deprecated calls use newer calls above instead
_IMPEXP_TRACKER void FSLaunchItem(const entry_ref *, BMessage * = NULL, int32 workspace = -1);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref *, BMessage *,

View File

@ -4518,17 +4518,6 @@ CopySelectionListToBListAsEntryRefs(const PoseList *original, BObjectList<entry_
}
static bool
CheckDevicesEqual(const entry_ref *srcRef, Model *targetModel)
{
BDirectory destDir (targetModel->EntryRef());
struct stat deststat;
destDir.GetStat(&deststat);
return srcRef->device == deststat.st_dev;
}
void
BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
bool forceCopy, bool forceMove, bool createLink, bool relativeLink)