diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1996-09-04 14:17:43 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1996-09-04 14:17:43 +0000 |
commit | a0c8d7373311facda78d250751203371cc0487b2 (patch) | |
tree | cfb65b4d0bff35f71cede7ae09e647433845236f /otherlibs/win32unix/windir.c | |
parent | ac9f8e8094ea19199a24fd5c67053718198ed172 (diff) |
Merge du stage de Pascal Cuoq
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@952 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/windir.c')
-rw-r--r-- | otherlibs/win32unix/windir.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/otherlibs/win32unix/windir.c b/otherlibs/win32unix/windir.c new file mode 100644 index 000000000..532cd6643 --- /dev/null +++ b/otherlibs/win32unix/windir.c @@ -0,0 +1,59 @@ +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Pascal Cuoq, projet Cristal, INRIA Rocquencourt */ +/* */ +/* Copyright 1996 Institut National de Recherche en Informatique et */ +/* Automatique. Distributed only by permission. */ +/* */ +/***********************************************************************/ + +/* $Id$ */ + +#include <mlvalues.h> +#include <memory.h> +#include <windows.h> +#include <alloc.h> +#include "unixsupport.h" + +value win_findfirst(name) /* ML */ + value name; +{ + HANDLE h; + value v; + struct _finddata_t fileinfo; + Push_roots(r,1); +#define valname r[0] + h = _findfirst(String_val(name),&fileinfo); + if (h == -1) { + if (errno == ENOENT) + raise_end_of_file(); + else + uerror("opendir", Nothing); + } + valname = copy_string(fileinfo.name); + v = alloc_tuple(2); + Field(v,0) = valname; + Field(v,1) = Val_int(h); + return v; +} + +value win_findnext(valh) + value valh; +{ + int retcode; + struct _finddata_t fileinfo; + + retcode = _findnext(Int_val(valh), &fileinfo); + if (retcode != 0) raise_end_of_file(); + return copy_string(fileinfo.name); +} + +value win_findclose(valh) + value valh; +{ + if (_findclose(Int_val(valh)) != 0) uerror("closedir", Nothing); + return Val_unit; +} + |