]> gitweb.factorcode.org Git - factor.git/blob - basis/unix/stat/stat.factor
2164d89ac61c17e09f46a6febbfd94a3972efa74
[factor.git] / basis / unix / stat / stat.factor
1 USING: kernel system combinators alien.syntax alien.c-types
2 math io.backend.unix vocabs.loader unix constants ;
3 IN: unix.stat
4
5 ! File Types
6
7 CONSTANT: S_IFMT   OCT: 170000   ! These bits determine file type.
8
9 CONSTANT: S_IFDIR  OCT:  40000   ! Directory.
10 CONSTANT: S_IFCHR  OCT:  20000   ! Character device.
11 CONSTANT: S_IFBLK  OCT:  60000   ! Block device.
12 CONSTANT: S_IFREG  OCT: 100000   ! Regular file.
13 CONSTANT: S_IFIFO  OCT: 010000   ! FIFO.
14 CONSTANT: S_IFLNK  OCT: 120000   ! Symbolic link.
15 CONSTANT: S_IFSOCK OCT: 140000   ! Socket.
16 CONSTANT: S_IFWHT  OCT: 160000   ! Whiteout.
17
18 FUNCTION: int chmod ( char* path, mode_t mode ) ;
19 FUNCTION: int fchmod ( int fd, mode_t mode ) ;
20 FUNCTION: int mkdir ( char* path, mode_t mode ) ;
21
22 C-STRUCT: fsid
23     { { "int" 2 } "__val" } ;
24
25 TYPEDEF: fsid __fsid_t
26 TYPEDEF: fsid fsid_t
27
28 << os {
29     { linux   [ "unix.stat.linux"   require ] }
30     { macosx  [ "unix.stat.macosx"  require ] }
31     { freebsd [ "unix.stat.freebsd" require ] }
32     { netbsd  [ "unix.stat.netbsd"  require ] }
33     { openbsd [ "unix.stat.openbsd" require ] }
34 } case >>
35
36 : file-status ( pathname -- stat )
37     "stat" <c-object> [ [ stat ] unix-system-call drop ] keep ;
38
39 : link-status ( pathname -- stat )
40     "stat" <c-object> [ [ lstat ] unix-system-call drop ] keep ;