Am I missing something obvious here?
I'm trying to create an empty file (prior to using a NSFileHandle to write its
contents), and I have a URL for the place to create it, and I want to avoid
path-based API where possible, and I'm targeting 10.6. The only URL-based file
creation API I know of is in NSData (NSFileManager can create directories from
a URL, not files AFAICT.)
If the file can't be created (e.g. I tried to create it on a DVD that happened
to show up in the Save panel), -[NSData writeToURL:error:] correctly fails, but
it returns an error that looks like this:
> Error Domain=NSCocoaErrorDomain Code=4 "The file “[…]” doesn’t exist."
> UserInfo=0x400f252c0 {NSFilePath=/Volumes/[…], NSUnderlyingError=0x400f25140
> "The operation couldn’t be completed. No such file or directory"}
IOW, NSData is reporting the "wrong" error, as this message isn't helpful to
present to the user.
Is there another API I should be using that will producing an error saying that
the file couldn't be created -- or better still saying *why* the file couldn't
be created? Does the misleading error message count as a bug in -[NSData
writeToURL:error:]?
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]