chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Portably overwriting files


From: Thomas Christian Chust
Subject: Re: [Chicken-users] Portably overwriting files
Date: Sun, 24 Feb 2008 17:49:46 +0100
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

Matt Gushee schrieb:

[...] it appears that for all the R5RS I/O procedures, the behavior
is unspecified whenever you open an output port on an existing file. So, do I need to explicitly delete the existing file in order to
have portable code?

Hello,

the best solution would probably be to:

 - Write the new data to a new file in the same directory as the old
   one. The name of the new file could be randomly generated.

 - Replace the old file by renaming the new one to the old name.

As the rename operation between files in the same directory is usually atomic, this has the advantage of having transactional semantics.

cu,
Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]