diff options
Diffstat (limited to 'otherlibs/win32unix/stat.c')
-rw-r--r-- | otherlibs/win32unix/stat.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/otherlibs/win32unix/stat.c b/otherlibs/win32unix/stat.c index 6a1259acd..a0ba3ca8d 100644 --- a/otherlibs/win32unix/stat.c +++ b/otherlibs/win32unix/stat.c @@ -42,30 +42,25 @@ static int file_kind_table[] = { static value stat_aux(int use_64, struct _stati64 *buf) { - value v; - value atime = Val_unit, mtime = Val_unit, ctime = Val_unit; + CAMLparam0 (); + CAMLlocal1 (v); - Begin_roots3(atime,mtime,ctime) - atime = copy_double((double) buf->st_atime); - mtime = copy_double((double) buf->st_mtime); - ctime = copy_double((double) buf->st_ctime); - 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) = - use_64 ? copy_int64(buf->st_size) : Val_int (buf->st_size); - Field (v, 9) = atime; - Field (v, 10) = mtime; - Field (v, 11) = ctime; - End_roots(); - return v; + v = caml_alloc (12, 0); + Store_field (v, 0, Val_int (buf->st_dev)); + Store_field (v, 1, Val_int (buf->st_ino)); + Store_field (v, 2, cst_to_constr (buf->st_mode & S_IFMT, file_kind_table, + sizeof(file_kind_table) / sizeof(int), 0)); + Store_field (v, 3, Val_int(buf->st_mode & 07777)); + Store_field (v, 4, Val_int (buf->st_nlink)); + Store_field (v, 5, Val_int (buf->st_uid)); + Store_field (v, 6, Val_int (buf->st_gid)); + Store_field (v, 7, Val_int (buf->st_rdev)); + Store_field (v, 8, + use_64 ? copy_int64(buf->st_size) : Val_int (buf->st_size)); + Store_field (v, 9, copy_double((double) buf->st_atime)); + Store_field (v, 10, copy_double((double) buf->st_mtime)); + Store_field (v, 11, copy_double((double) buf->st_ctime)); + CAMLreturn (v); } CAMLprim value unix_stat(value path) |