Ejemplo n.º 1
0
static value stat_aux(int use_64, struct stat *buf)
{
  CAMLparam0();
  CAMLlocal5(atime, mtime, ctime, offset, v);

  atime = copy_double((double) buf->st_atime);
  mtime = copy_double((double) buf->st_mtime);
  ctime = copy_double((double) buf->st_ctime);
  offset = use_64 ? Val_file_offset(buf->st_size) : Val_int (buf->st_size);
  v = alloc_small(12, 0);
  Field (v, 0) = Val_int (buf->st_dev);
  Field (v, 1) = Val_int (buf->st_ino);
  Field (v, 2) = cst_to_constr(buf->st_mode & S_IFMT, file_kind_table,
                               sizeof(file_kind_table) / sizeof(int), 0);
  Field (v, 3) = Val_int (buf->st_mode & 07777);
  Field (v, 4) = Val_int (buf->st_nlink);
  Field (v, 5) = Val_int (buf->st_uid);
  Field (v, 6) = Val_int (buf->st_gid);
  Field (v, 7) = Val_int (buf->st_rdev);
  Field (v, 8) = offset;
  Field (v, 9) = atime;
  Field (v, 10) = mtime;
  Field (v, 11) = ctime;
  CAMLreturn(v);
}
Ejemplo n.º 2
0
static value stat_aux(int use_64, struct stat *buf)
{
  CAMLparam0();
  CAMLlocal5(atime, mtime, ctime, offset, v);

  #include "nanosecond_stat.h"
  atime = caml_copy_double((double) buf->st_atime + (NSEC(buf, a) / 1000000000.0));
  mtime = caml_copy_double((double) buf->st_mtime + (NSEC(buf, m) / 1000000000.0));
  ctime = caml_copy_double((double) buf->st_ctime + (NSEC(buf, c) / 1000000000.0));
  #undef NSEC
  offset = use_64 ? Val_file_offset(buf->st_size) : Val_int (buf->st_size);
  v = alloc_small(12, 0);
  Init_field(v, 0, Val_int (buf->st_dev));
  Init_field(v, 1, Val_int (buf->st_ino));
  Init_field(v, 2, cst_to_constr(buf->st_mode & S_IFMT, file_kind_table,
                                  sizeof(file_kind_table) / sizeof(int), 0));
  Init_field(v, 3, Val_int (buf->st_mode & 07777));
  Init_field(v, 4, Val_int (buf->st_nlink));
  Init_field(v, 5, Val_int (buf->st_uid));
  Init_field(v, 6, Val_int (buf->st_gid));
  Init_field(v, 7, Val_int (buf->st_rdev));
  Init_field(v, 8, offset);
  Init_field(v, 9, atime);
  Init_field(v, 10, mtime);
  Init_field(v, 11, ctime);
  CAMLreturn(v);
}
Ejemplo n.º 3
0
CAMLprim value unix_lseek_64(value fd, value ofs, value cmd)
{
  file_offset ret;
  /* [ofs] is an Int64, which is stored as a custom block; we must therefore
     extract its contents before dropping the runtime lock, or it might be
     moved. */
  file_offset ofs_c = File_offset_val(ofs);
  caml_enter_blocking_section();
  ret = lseek(Int_val(fd), ofs_c, seek_command_table[Int_val(cmd)]);
  caml_leave_blocking_section();
  if (ret == -1) uerror("lseek", Nothing);
  return Val_file_offset(ret);
}
Ejemplo n.º 4
0
Archivo: io.c Proyecto: bobzhang/ocaml
CAMLprim value caml_ml_pos_in_64(value vchannel)
{
  return Val_file_offset(caml_pos_in(Channel(vchannel)));
}
Ejemplo n.º 5
0
Archivo: io.c Proyecto: bobzhang/ocaml
CAMLprim value caml_ml_channel_size_64(value vchannel)
{
  return Val_file_offset(caml_channel_size(Channel(vchannel)));
}