On 21-Apr-07, at 9:46 AM, Norman Palardy wrote:

>
> On 21-Apr-07, at 9:33 AM, Jim Wagner wrote:
>
>> Greetings NUG -
>>
>> I have a file that I need to "update". Think preferences, though its
>> not. I can think of several ways to do it and I am unclear about the
>> tradeoffs. The contents of the file are all cached within the app. It
>> is a text file, probably less than 100k in size.
>>
>> 1. Delete the old file,  and write a new one with the same name.  
>> This,
>> however, would not appear to maintain the creation date. I think I
>> remember problems about the old file not being deleted if you  
>> tried to
>> create the new one too quickly.
>>
>> 2. Create a new file with a different name, then change file names  
>> and
>> delete the old one. This also raises the question about maintaining
>> the
>> creation date.
>
> If you use either of these look into Charles Yeomans code for
> swapping files.
> This is an OS level "swap" and happens atomically so you are less
> likely to run into problems.
> It also preserves the file attributes (if I recall correctly)

Sorry.
Swap Files is part of the Carbon Declare Library

I've posted and example of using SwapFile on my web site

           http://www.great-white-software.com/SwapFilesExample.zip

Norman Palardy
http://www.great-white-software.com/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to