Re: Saving only required files in a file wrapper?
Re: Saving only required files in a file wrapper?
- Subject: Re: Saving only required files in a file wrapper?
- From: Ken Thomases <email@hidden>
- Date: Wed, 7 May 2008 16:46:39 -0500
Hi,
On May 7, 2008, at 3:08 PM, Keith Blount wrote:
Many thanks for your response...
Sure thing. I'm happy to flail in the dark and guess wildly with the
best of them. ;)
Hmm, I think you're right. I overrided -saveDocument: because it
looked as though -writeToURL: and all of the other -write... methods
expected you to write all the data at any one time. It's possible
for my file packages to run to hundreds of megabytes, so I only ever
want to write the changed files at any save point (usually only ever
one or two RTFD files within the package actually require saving at
any one time). There's not much in the docs about doing this -
everything I can find seems to assume that you will save everything,
even when it comes to packages (as file wrappers), at once, which is
why I took a screwy way.
Yeah, it's hard to see how one can accomplish what you're trying to do.
I wonder... what happens if you compose a directory NSFileWrapper
from an existing directory (which will recursively fill it with file
wrappers referencing the directory's contents), then remove the
wrappers for the individual items you want to replace, then add new
file wrappers for those items, then save that whole file wrapper to
the desired destination location? Are there any smarts in there to
avoid doing a full copy of all of the items which weren't changed,
perhaps using hard links or the like?
I still wonder what the best way of doing it is. -
writeToURL:ofType:forSaveOperation:originalContentsURL:error: perhaps?
Well, that seems to give you the greatest flexibility, and gives you
both the new and old URLs, but -- by the very fact that you're given
two URLs -- the explicit fact is that you are creating a new document
on disk rather than doing a minimal modification of the old one. So,
you'd have to perform the copy of all of the parts that are the same
between the two, which is what you're trying to avoid.
Also, is it possible that -writeToURL: is getting called behind the
back of -saveDocument:? I considered this but assumed (always a bad
mistake) that it would be safe as I thought that all of the -
write... methods did nothing unless you overrode them.
I don't know. That's certainly one of the possibilities I
considered. I think you have to assume it's possible. For instance,
I would not expect the auto-save features of NSDocument to go through -
saveDocument:. -saveDocument: is an action method, intended to be
triggered by the Save menu item (and similar GUI controls). So, I
would expect that it would have all sorts of high-level functionality
like running a save panel if the document hasn't been saved before.
Because of that, the framework wouldn't use it when it needs to do
something low-level.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden