Re: flushing HFS cache to disk
Re: flushing HFS cache to disk
- Subject: Re: flushing HFS cache to disk
- From: Steve Sisak <email@hidden>
- Date: Wed, 30 Nov 2005 22:16:46 -0500
At 6:27 PM -0800 11/30/05, Dave Yost wrote:
I suppose you could write the file as a temp file, do a synchronous
flush of the file, then move it into place. This is of course, a
hack on top of an API that was never designed to be transactional.
And of course, this is exactly how an HFS "safe save" works on
"traditional" MacOS:
FindFolder() to get the dirID of the invisible "Temporary Items"
folder on the same volume as the destination file
Create and write to a temporary file
FSpExchangeFiles() to atomically swap the contents of the files (by
swapping their directory entries) -- this preserves the fileID so
aliases still work.
Delete the temp file (which is now the old file)
And you could still end up with a temp file lying around after a crash.
On reboot, any files left in "Temporary Items" are moved to "Rescued
Items", located in the Trash.
Years ago there was a Cromemco unix clone that let you create a file
descriptor, write to it, then link it into a directory. That was a
good idea that was rejected as unorthodox.
Gotta love religion.
Cheers,
-Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden