Apologies for so soon a follow up, but I've just been experimenting with 
-writeToURL:ofType:forSaveOperation:originalContentsURL:error: and the results 
are disastrous. It turns out that *every single time* it is invoked, 
absoluteURL is a temporary location and *not* the original URL. So to use this 
method successfully I would need to copy the whole file package across to that 
location every time, which is exactly what I _don't_ want to do. This seems a 
little insane to me. There must be a mechanism in place that just lets you save 
into a package folder without having to write the whole thing out every time...

Thanks again and all the best,
Keith

----- Original Message ----
From: Ken Thomases <[EMAIL PROTECTED]>
To: Graham Cox <[EMAIL PROTECTED]>
Cc: Keith Blount <[EMAIL PROTECTED]>; Cocoa-Dev List <cocoa-dev@lists.apple.com>
Sent: Thursday, May 8, 2008 3:36:05 AM
Subject: Re: Saving only required files in a file wrapper?

On May 7, 2008, at 9:06 PM, Graham Cox wrote:

> On 8 May 2008, at 10:26 am, Keith Blount wrote:
>
>> The trouble with all of these methods is that they tell you not to  
>> rely on fileURL
>
> My interpretation of that advice is that at the time the read... and  
> write... methods are called, the document hasn't set up -fileURL, so  
> in that sense you can't rely on it (i.e. don't call -fileURL from  
> within these methods). But the URL passed to the methods themselves  
> as a parameter is definitely reliable. So provided you use the  
> parameter you'll be fine.

I think it means more than that.  NSDocument tries to be smart about  
atomic writes and backups.  The URL passed into the write... methods  
is not expected to be the same as the document's current location on  
disk.  You are to write the document, in whole, to the temporary  
location provided to you (about which no assumptions should be made),  
and then NSDocument will take care of swapping the newly-written  
document with the old document and deleting the old document.

Obviously, this runs directly counter to Keith's desires.  
Unfortunately, I don't know how to override these smarts in  
NSDocument, other than perhaps what I described earlier with  
NSFileWrapper.

-Ken



      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to