objective-ccocoabundlensdocumentnsfilewrapper

Saving a "project"-type document (containing sub-documents)


I'm trying to create a "project"-like document, in that it contains subdocuments in a specified directory. I'd like a brand new save of a document to set up that directory with appropriate subdirectories. I'd like a "Save As" to copy all those subdirectories and any files within them to the new location. But I'd like a "Save" to only update certain data files and (of course) not overwrite all the subdocuments!

What's the "safe" way to do this? I tried keeping track of the file's location in my document, and checking to see if it was the same or different than the save location, but it feels messy, and I'm worried that Apple is doing something behind the scenes that will make this direct URL-to-URL comparison fail in some circumstances.

Is there a standard way to do something like this?


Solution

  • NSFileWrapper has incremental writing support in Snow Leopard, which will use hard links instead of copying. This seems like exactly what you're looking for.

    See this blog entry for more information.