diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1995-05-04 12:48:07 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1995-05-04 12:48:07 +0000 |
commit | 623e2fbc005eec3bc79bbd81b8cff39ad5458f32 (patch) | |
tree | 93fe20d291da158bd38dbfe76c7388ef50088142 /byterun/sys.c | |
parent | 1953de21ef74e21a814e5ea6323e25aae1ade520 (diff) |
Ajout de Sys.file_exists
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/sys.c')
-rw-r--r-- | byterun/sys.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/byterun/sys.c b/byterun/sys.c index 10f05e256..61f1cad05 100644 --- a/byterun/sys.c +++ b/byterun/sys.c @@ -3,6 +3,7 @@ #include <errno.h> #include <fcntl.h> #include <signal.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include "config.h" @@ -88,11 +89,10 @@ value sys_open(path, flags, perm) /* ML */ return Val_long(ret); } -value sys_close(fd) /* ML */ - value fd; +value sys_file_exists(name) /* ML */ + value name; { - if (close(Int_val(fd)) != 0) sys_error(NULL); - return Atom(0); + return Val_bool(access(String_val(name), F_OK) == 0); } value sys_remove(name) /* ML */ @@ -119,8 +119,6 @@ value sys_chdir(dirname) /* ML */ return Atom(0); } -extern char * getenv(); - value sys_getenv(var) /* ML */ value var; { @@ -179,7 +177,7 @@ char * searchpath(name) *p++ = *q++; } *p = 0; - if (access(fullname, 1) == 0) return fullname; + if (access(fullname, F_OK) == 0) return fullname; if (*path == 0) return 0; path++; } |