* [Caml-list] stat of nonexistent file
@ 2016-07-25 12:55 Hendrik Boom
2016-07-25 13:23 ` Daniel Bünzli
0 siblings, 1 reply; 2+ messages in thread
From: Hendrik Boom @ 2016-07-25 12:55 UTC (permalink / raw)
To: caml-list
While reading section 2.3 of https://ocaml.github.io/ocamlunix/files.html
I noticed that it does not specify what stat and lstat returnsif
the named file does not exist.
(a) What do they do?
(b) Should this be specified in the documentation?
(c) Are these suitable functions to determine if a file exists?
-- hendrik
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] stat of nonexistent file
2016-07-25 12:55 [Caml-list] stat of nonexistent file Hendrik Boom
@ 2016-07-25 13:23 ` Daniel Bünzli
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Bünzli @ 2016-07-25 13:23 UTC (permalink / raw)
To: Hendrik Boom; +Cc: caml-list
Le lundi, 25 juillet 2016 à 14:55, Hendrik Boom a écrit :
> (a) What do they do?
The general design philosophy of the Unix library is to simply forward the call to the equivalent C function, turning errors in to a `Unix.Error` exception. So the question is usually resolved by looking at the documentation of the C function. In that particular case if the file doesn't exist you will get an exception with the NOENT error.
> (b) Should this be specified in the documentation?
I think it would be good if the documentation of the Unix module linked to the documentation of the C functions in the POSIX standard (you will notice the ocamlunix book usually does this when functions are introduced).
> (c) Are these suitable functions to determine if a file exists?
Yes. Don't forget to retry the call on EINTR though.
Best,
Daniel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-25 13:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25 12:55 [Caml-list] stat of nonexistent file Hendrik Boom
2016-07-25 13:23 ` Daniel Bünzli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox