[Haskell-beginners] Subject: Re: File I/O: reading from, writing to,
Doug McIlroy
doug at cs.dartmouth.edu
Thu Feb 5 23:28:46 UTC 2015
same file in one function
One more safety feature in the "proper way": in most systems it will
guarantee that a concurrent reader sees a coherent file image.
------------------------------------------------------------
> I strongly urge you to use the
proper way with temp file and renaming, even making it a function if you
need to repeat this several times
The "proper way" is fraught with pitfalls: potentially changes in
file ownership and permissions, loss of linkage when the file is
known by multiple names, and even total failure if you don't have
write permission on the directory.^C
The proper way does have one safety advantage. The original file
is highly likely to survive should the writing of the new contents
stop prematurely for some external reason.
Doug
More information about the Beginners
mailing list