views:

49

answers:

1

Is it safe to assume that the destination URL passed to an outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems: method (as specified by the NSOutlineViewDataSource protocol) is always a file URL?

In the implementation of such a method I'm making use of NSDictionary's writeToURL:atomically: to write out a ".webloc" property list. I'd like to ensure that no existing file is overwritten by using a file name that is not already used. I know this can be checked for file URLs with NSFileManager's fileExistsAtPath: but I'm not sure how to handle the case where one is not dealing with a file URL. Then again, does that situation ever occur?

I'm guessing that YES, the URL will always be a file URL, since remote volumes etc. are always provided through a mount point in the local filesystem; but perhaps I'm overlooking something ...

And if no, how then to choose a file name so that no existing file at the destination URL is being overwritten?

( Note: I'm writing an application that targets Mac OS X 10.4 as the minimum OS version requirement. )

+1  A: 

Assuming the dropDestination will always be a file URL seems reasonable, but if you want to be certain you can send it an isFileURL message.

In the strange case where it's not a file URL: Before writing your property list, try downloading from the URL you're about to write to and change your destination filename if the download succeeds.

tedge