diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2003-03-03 17:16:15 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2003-03-03 17:16:15 +0000 |
commit | 859efb84a8160e694b35a90fd60fcb3606ca8ef9 (patch) | |
tree | d09e19f7742c3914e33e92e56451a5021ba1740a /byterun/win32.c | |
parent | dc64ea8cc7ed73b7b67f8554f29b95575883b81b (diff) |
Ajout de Sys.readdir
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5415 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/win32.c')
-rw-r--r-- | byterun/win32.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/byterun/win32.c b/byterun/win32.c index 013a8dbff..f4349f2b9 100644 --- a/byterun/win32.c +++ b/byterun/win32.c @@ -371,6 +371,29 @@ int win32_system(char * cmdline) } } +/* Add to [contents] the (short) names of the files contained in + the directory named [dirname]. No entries are added for [.] and [..]. + Return 0 on success, -1 on error; set errno in the case of error. */ + +int caml_read_directory(char * dirname, struct ext_table * contents) +{ + int d; + struct _finddata_t fileinfo; + char * p; + + h = _findfirst(dirname, &fileinfo); + if (h == -1) return errno == ENOENT ? 0 : -1; + do { + if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) { + p = stat_alloc(strlen(fileinfo.name) + 1); + strcpy(p, fileinfo.name); + ext_table_add(contents, p); + } + } while (_findnext(h, &fileinfo) == 0); + _findclose(h); + return 0; +} + #ifndef NATIVE_CODE /* Set up a new thread for control-C emulation and termination */ |