]> gitweb.factorcode.org Git - factor.git/blob - basis/unix/stat/stat.factor
use radix literals
[factor.git] / basis / unix / stat / stat.factor
1 USING: kernel system combinators alien.syntax alien.c-types
2 math vocabs vocabs.loader unix classes.struct ;
3 IN: unix.stat
4
5 ! File Types
6
7 CONSTANT: S_IFMT   0o170000   ! These bits determine file type.
8
9 CONSTANT: S_IFDIR  0o40000   ! Directory.
10 CONSTANT: S_IFCHR  0o20000   ! Character device.
11 CONSTANT: S_IFBLK  0o60000   ! Block device.
12 CONSTANT: S_IFREG  0o100000   ! Regular file.
13 CONSTANT: S_IFIFO  0o010000   ! FIFO.
14 CONSTANT: S_IFLNK  0o120000   ! Symbolic link.
15 CONSTANT: S_IFSOCK 0o140000   ! Socket.
16 CONSTANT: S_IFWHT  0o160000   ! Whiteout.
17
18 STRUCT: fsid
19     { __val int[2] } ;
20
21 TYPEDEF: fsid __fsid_t
22 TYPEDEF: fsid fsid_t
23
24 << os {
25     { linux   [ "unix.stat.linux"   require ] }
26     { macosx  [ "unix.stat.macosx"  require ] }
27 } case >>
28
29 : file-status ( pathname -- stat )
30     \ stat <struct> [ [ stat ] unix-system-call drop ] keep ;
31
32 : link-status ( pathname -- stat )
33     \ stat <struct> [ [ lstat ] unix-system-call drop ] keep ;