1996-09-04 07:17:43 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* 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>
|
1996-09-05 06:32:25 -07:00
|
|
|
#include <errno.h>
|
1996-09-04 07:17:43 -07:00
|
|
|
#include <alloc.h>
|
|
|
|
#include "unixsupport.h"
|
|
|
|
|
|
|
|
value win_findfirst(name) /* ML */
|
|
|
|
value name;
|
|
|
|
{
|
1996-09-05 06:32:25 -07:00
|
|
|
int h;
|
1996-09-04 07:17:43 -07:00
|
|
|
value v;
|
|
|
|
struct _finddata_t fileinfo;
|
|
|
|
Push_roots(r,1);
|
1996-09-05 06:32:25 -07:00
|
|
|
|
1996-09-04 07:17:43 -07:00
|
|
|
#define valname r[0]
|
1996-09-05 06:32:25 -07:00
|
|
|
|
1996-09-04 07:17:43 -07:00
|
|
|
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);
|
1997-03-21 02:46:09 -08:00
|
|
|
Pop_roots();
|
1996-09-04 07:17:43 -07:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
1997-03-11 02:38:06 -08:00
|
|
|
value win_findnext(valh) /* ML */
|
1996-09-04 07:17:43 -07:00
|
|
|
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);
|
1997-05-19 08:42:21 -07:00
|
|
|
}
|
1996-09-04 07:17:43 -07:00
|
|
|
|
1997-03-11 02:38:06 -08:00
|
|
|
value win_findclose(valh) /* ML */
|
1997-05-19 08:42:21 -07:00
|
|
|
value valh;
|
1996-09-04 07:17:43 -07:00
|
|
|
{
|
|
|
|
if (_findclose(Int_val(valh)) != 0) uerror("closedir", Nothing);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|