On 3/2/14 12:06 AM, Quincey Morris wrote:
> I’ve never used this, but I *have* seen documents use hard linking anyway
> (though, on reflection, that might have been UIDocument, not NSDocument — I’m
> not sure now).

No, it is NSDocument/NSFileWrapper, UIDocument/NSFileWrapper doesn't know this kind of trick.

Not sure why it's not working for the OP it certainly works fine for my app. Works fine meaning it saves package files containing hundreds of megabytes of data with thousands of files and folders in a fraction of a second (depending on how much content changed, of course):

You basically need to overwrite:

- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError

for loading (and stashing the original wrapper reference) and

- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError 
**)outError

to return the original wrapper with all necessary changes to its subwrappers applied.

You also need to overwrite

- (void)setFileURL:(NSURL *)absoluteURL

in which you call super and then update your stored wrapper (if you have one already) using -[NSFileWrapper readFromURL:options:error:].

You need to do this because the filewrapper you return in -fileWrapperOfType:: gets written to a temp location and moved in place. That causes all references to all the files and folders the wrapper and its subwrappers point to to move and to become invalid as a result, once the save is complete. Updating ensures the references are valid for the next go.

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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]

Reply via email to