开发者

Cocoa: is it safe to assume that the destination URL for delivering on an NSFilesPromisePboardType is a file URL?

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 开发者_C百科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. )


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜