• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDocument save incremental file package in-place
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument save incremental file package in-place


  • Subject: Re: NSDocument save incremental file package in-place
  • From: Markus Spoettl <email@hidden>
  • Date: Sun, 02 Mar 2014 10:13:47 +0100

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@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


  • Follow-Ups:
    • Re: NSDocument save incremental file package in-place
      • From: Trygve Inda <email@hidden>
References: 
 >Re: NSDocument save incremental file package in-place (From: Trygve Inda <email@hidden>)
 >Re: NSDocument save incremental file package in-place (From: Mike Abdullah <email@hidden>)
 >Re: NSDocument save incremental file package in-place (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: NSDocument save incremental file package in-place
  • Next by Date: Re: NSDocument save incremental file package in-place
  • Previous by thread: Re: NSDocument save incremental file package in-place
  • Next by thread: Re: NSDocument save incremental file package in-place
  • Index(es):
    • Date
    • Thread