You can use extended attributes to attach information to a file. Maybe
serialize your session state as a plist and use setxattr/getxattr to
manipulate it. Follows the file as it's moved around.

PS: it's recommended that names for your attribute following the java
style reverse DNS. For example, Apple uses com.apple.FinderInfo

On Mon, Jun 4, 2012 at 5:50 PM, Antonio Nunes <[email protected]> wrote:
> I have implemented window state restauration in an app. This works fine for 
> re-opening documents that were open when the app was last quit. What I now 
> want to do is extend that functionality to files that were not necessarily 
> open when the app was last quit, but simply that have been opened at any time 
> before. I can't put state information into the files themselves, since they 
> are files that need to remain clean and that are not "owned" by my app.
>
> From what I've researched so far the window state restoration feature won't 
> extend the way I need it.
>
> I think NSURL's bookmarks feature could help out. I could create bookmark 
> data, and save it, and then later, when a file is opened, check the cached 
> bookmarkdata to see if one resolves to a URL that is equal to the url of the 
> just opened file. That should even work if the file is moved between 
> sessions. Is this the best way to do it though?
>
> The next question is, what is a handy way to keep track of the restoration 
> data that goes with the URL, since that will have to be saved separately from 
> the bookmark data. Using only the file name won't do, I need some kind of 
> unique ID, or a unique URL that can be derived from the bookmark data.  I 
> know I can think up a scheme, but I wonder if there is a proper way to do 
> this, like obtaining a unique file ID.
>
> -António
>
> ----------------------------------------------------
> A merry heart does good like medicine
> ----------------------------------------------------
>
>
>
> _______________________________________________
>
> 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/stephen.butler%40gmail.com
>
> This email sent to [email protected]

_______________________________________________

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