Re: Tracking files the right way
Re: Tracking files the right way
- Subject: Re: Tracking files the right way
- From: Chris Hanson <email@hidden>
- Date: Thu, 29 Aug 2002 19:47:08 -0500
At 5:47 PM -0400 8/29/02, Bill Bumgarner wrote:
It is occasionally very handy that an app like IB, TextEdit, emacs,
etc... saves the last version as a backup version (i.e. edit
'foo.txt', click 'save', TE moves the current file to foo~.txt and
saves the new content to foo.txt).
This is a bug in either TextEdit or Cocoa. TextEdit should save the
new content to foo~.txt, and then atomically swap the directory
entries for foo.txt and foo~.txt using FSExchangeObjects. This will
preserve the file ID of foo.txt, which is how the alias tracks it.
FSExchangeObjects won't work on all volume types, unfortunately, but
it will work on HFS+ and AppleShare mounts. On the other hand, on
those volume types where it doesn't work, file IDs also aren't
supported, so aliases to files on those volumes will probably wind up
using full paths and doing what you expect. (If they don't, it means
Carbon is probably synthesizing file IDs or something behind your
back.)
The correct process for a safe save on a volume that doesn't support
FSExchangeObjects is to write the new content to foo~.txt, rename the
old file to some temporary name, rename foo~.txt to foo.txt, and
rename the temporary name to foo.txt.
Of course, NSDocument should handle all of this transparently...
-- Chris
--
Chris Hanson | Email: email@hidden
bDistributed.com, Inc. | Phone: +1-847-372-3955
Making Business Distributed | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.