Merge branch 'slimconfigure'
[m6w6/ext-psi] / psi.d / stat.psi
1 #include <sys/stat.h>
2 // extern int stat(char *path, struct stat *buf);
3 function psi\stat(string $path, array &$buf = NULL) : int {
4 let path = strval($path);
5 let buf = calloc(1, sizeof(struct stat));
6 return stat(path, buf) as to_int(stat);
7 set $buf = to_array(*buf,
8 to_int(st_dev),
9 to_int(st_ino),
10 to_int(st_mode),
11 to_int(st_nlink),
12 to_int(st_uid),
13 to_int(st_gid),
14 to_int(st_rdev),
15 to_int(st_size),
16 to_array(st_atim,
17 to_int(tv_sec),
18 to_int(tv_nsec)
19 ),
20 to_array(st_atimespec,
21 to_int(tv_sec),
22 to_int(tv_nsec)
23 ),
24 to_array(st_mtim,
25 to_int(tv_sec),
26 to_int(tv_nsec)
27 ),
28 to_array(st_mtimespec,
29 to_int(tv_sec),
30 to_int(tv_nsec)
31 ),
32 to_array(st_ctim,
33 to_int(tv_sec),
34 to_int(tv_nsec)
35 ),
36 to_array(st_ctimespec,
37 to_int(tv_sec),
38 to_int(tv_nsec)
39 ),
40 to_array(st_birthtim,
41 to_int(tv_sec),
42 to_int(tv_nsec)
43 ),
44 to_array(st_birthtimespec,
45 to_int(tv_sec),
46 to_int(tv_nsec)
47 ),
48 to_int(st_blksize),
49 to_int(st_blocks),
50 to_int(st_flags),
51 to_int(st_gen)
52 );
53 }