Beispiel #1
0
CAMLprim value unix_closedir(value vd)
{
  DIR * d = DIR_Val(vd);
  if (d == (DIR *) NULL) unix_error(EBADF, "closedir", Nothing);
  closedir(d);
  DIR_Val(vd) = (DIR *) NULL;
  return Val_unit;
}
CAMLprim value unix_rewinddir(value vd)
{
  DIR * d = DIR_Val(vd);
  if (d == (DIR *) NULL) unix_error(EBADF, "rewinddir", Nothing);
  rewinddir(d);
  return Val_unit;
}
Beispiel #3
0
CAMLprim value unix_readdir_r(CAML_R, value vd)
{
  DIR * d;
  directory_entry * e;
  d = DIR_Val(vd);
  if (d == (DIR *) NULL) unix_error_r(ctx,EBADF, "readdir", Nothing);
  e = readdir((DIR *) d);
  if (e == (directory_entry *) NULL) caml_raise_end_of_file_r(ctx);
  return caml_copy_string_r(ctx,e->d_name);
}
Beispiel #4
0
CAMLprim value unix_opendir(value path)
{
  DIR * d;
  value res;
  d = opendir(String_val(path));
  if (d == (DIR *) NULL) uerror("opendir", path);
  res = alloc_small(1, Abstract_tag);
  DIR_Val(res) = d;
  return res;
}
Beispiel #5
0
CAMLprim value unix_readdir(value vd)
{
  DIR * d;
  directory_entry * e;
  d = DIR_Val(vd);
  if (d == (DIR *) NULL) unix_error(EBADF, "readdir", Nothing);
  e = readdir((DIR *) d);
  if (e == (directory_entry *) NULL) raise_end_of_file();
  return copy_string(e->d_name);
}
Beispiel #6
0
CAMLprim value netsys_fdopendir(value fd)
{
#ifdef HAVE_FDOPENDIR
  DIR * d;
  value res;
  d = fdopendir(Int_val(fd));
  if (d == (DIR *) NULL) uerror("fdopendir", Nothing);
  res = alloc_small(1, Abstract_tag);
  DIR_Val(res) = d;
  return res;
#else
  invalid_argument("Netsys_posix.fdopendir not available");
#endif
}
Beispiel #7
0
CAMLprim value unix_opendir(value path)
{
  CAMLparam1(path);
  DIR * d;
  value res;
  char * p;

  p = caml_strdup(String_val(path));
  caml_enter_blocking_section();
  d = opendir(p);
  caml_leave_blocking_section();
  caml_stat_free(p);
  if (d == (DIR *) NULL) uerror("opendir", path);
  res = alloc_small(1, Abstract_tag);
  DIR_Val(res) = d;
  CAMLreturn(res);
}
Beispiel #8
0
CAMLprim value lwt_unix_valid_dir(value dir)
{
    CAMLparam1(dir);
    int result = DIR_Val(dir) == NULL ? 0 : 1;
    CAMLreturn(Val_int(result));
}
Beispiel #9
0
CAMLprim value lwt_unix_invalidate_dir(value dir)
{
    CAMLparam1(dir);
    DIR_Val(dir) = NULL;
    CAMLreturn(Val_unit);
}