1 /***********************************************************************/
5 /* Pascal Cuoq and Xavier Leroy, projet Cristal, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
12 /***********************************************************************/
14 /* $Id: windir.c 5029 2002-07-23 14:12:03Z doligez $ */
21 #include "unixsupport.h"
23 CAMLprim value win_findfirst(name)
28 WIN32_FIND_DATA fileinfo;
29 value valname = Val_unit;
30 value valh = Val_unit;
32 Begin_roots2 (valname,valh);
33 h = FindFirstFile(String_val(name),&fileinfo);
34 if (h == INVALID_HANDLE_VALUE) {
35 DWORD err = GetLastError();
36 if (err == ERROR_NO_MORE_FILES)
40 uerror("opendir", Nothing);
43 valname = copy_string(fileinfo.cFileName);
44 valh = win_alloc_handle(h);
45 v = alloc_small(2, 0);
52 CAMLprim value win_findnext(valh)
55 WIN32_FIND_DATA fileinfo;
58 retcode = FindNextFile(Handle_val(valh), &fileinfo);
60 DWORD err = GetLastError();
61 if (err == ERROR_NO_MORE_FILES)
65 uerror("readdir", Nothing);
68 return copy_string(fileinfo.cFileName);
71 CAMLprim value win_findclose(valh)
74 if (! FindClose(Handle_val(valh))) {
75 win32_maperr(GetLastError());
76 uerror("closedir", Nothing);