Wed, 20 Mar 2002 02:18:05 +0100
Just because many applications use this doesn't make it safe or good.
Presumably you are testing for the existence of the file to do something
to it (read, create, delete...). It's better to do the operation you want to
do and have it fail if the file is missing (or existing if you create). You
then just have to handle the exception (that part is already in H98) or
proceed with the normal path. I claim the code simpler this way and you
avoid any race conditions.
> Lennart Augustsson <email@example.com> writes:
> > > Diego Yanivello wrote:
> > >
> > > > hi, is there (in Haskell) a function like existFile :: FilePath ->
> > > > IO (Bool) ? Thanks!
> > Using such a function is generally a bad idea because of race conditions.
> however, real world programs use those tests since you don't need to care
> *everytime* about race conditions. (of course using this existFile before
> creating a temporary file is wrong, but existFile has *many* other
> Haskell mailing list