The Finder uses some kind of rules to determine if an Item can be moved or will be copied. After dragging an Item, in certain cases Finder shows a drag-copy-cursor. Are these rules in an API available? Checked with Spotlight-Metadata, NSURL and NSFileManager: no result.
Here's what i came up with:
- if a Folder contains a ".localized" File: the folder is copied
- if a Folder is listed anywhere in a NSSearchPathDirectory
Is my assumption right? or has it to do with NSURLIsSystemImmutableKey or NSURLIsUserImmutableKey which i thought is the "Locked" flag?
Furthermore depending on various other Metadata like write-permissions and locked-flag:
ON SOURCE:
- moving a readonly file: move is possible
moving a readonly folder needs login from an admin
moving a locked file creates a copy
- moving a locked folder creates a copy
- moving a folder with a locked file inside: move is possible
moving a selection with both locked and unlocked items creates a copy
moving a dropbox writeonly folder: move is possible
writeonly files do not exist in Finder
moving a file without any permissions: move is possible (as the move rights depend on the enclosing folder)
moving a folder with a file without any permission: move is possible (as long its a move, for copy it asks for login)
if a Folder contains a ".localized" File: the folder is copied
if a Folder is listed anywhere in开发者_如何学运维 a NSSearchPathDirectory (home directory, ...) it is copied
if a folder contains another book: move is possible
ON TARGET:
- moving an item into a dropbox creates a copy
- moving an item into a locked folder: not possible
- moving an item into a read-only folder: asks for login
*) Regarding the Finder: if a file or directory is being dragged from one volume to another, it will (by default) be copied. If the action is being performed on the same volume the file or folder will (by default) be moved. As a side note to file operations on volumes: 'moving' things across different filesystemes behaves differently, again. Normally, moving a file or directory doesn't mean 'copying' and 'deleting' the original afterwards - only their links within the filesystem usually become modified but here and then, it actually behaves exactly like that.
*) Furthermore, take care of the objects permissions: if filesystem permissions to that source file or a directory (and it's content within) doesn't allow write operations to it, it will be copied again.
精彩评论