finding ....
Lennart Augustsson
lennart@augustsson.net
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
Pixel wrote:
> Lennart Augustsson <lennart@augustsson.net> 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
> applications)
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell