factor/basis/unix/stat/stat.factor

34 lines
945 B
Factor
Raw Normal View History

2008-02-29 00:46:27 -05:00
USING: kernel system combinators alien.syntax alien.c-types
math vocabs vocabs.loader unix classes.struct ;
2008-02-27 02:55:49 -05:00
IN: unix.stat
! File Types
2011-11-23 21:49:33 -05:00
CONSTANT: S_IFMT 0o170000 ! These bits determine file type.
CONSTANT: S_IFDIR 0o40000 ! Directory.
CONSTANT: S_IFCHR 0o20000 ! Character device.
CONSTANT: S_IFBLK 0o60000 ! Block device.
CONSTANT: S_IFREG 0o100000 ! Regular file.
CONSTANT: S_IFIFO 0o010000 ! FIFO.
CONSTANT: S_IFLNK 0o120000 ! Symbolic link.
CONSTANT: S_IFSOCK 0o140000 ! Socket.
CONSTANT: S_IFWHT 0o160000 ! Whiteout.
STRUCT: fsid
{ __val int[2] } ;
2008-10-20 03:08:33 -04:00
2008-12-16 03:32:57 -05:00
TYPEDEF: fsid __fsid_t
TYPEDEF: fsid fsid_t
2008-10-20 03:08:33 -04:00
2008-10-07 08:43:49 -04:00
<< os {
2008-04-02 19:25:33 -04:00
{ linux [ "unix.stat.linux" require ] }
{ macosx [ "unix.stat.macosx" require ] }
2008-10-07 08:43:49 -04:00
} case >>
: file-status ( pathname -- stat )
\ stat <struct> [ [ stat ] unix-system-call drop ] keep ;
2008-02-27 02:55:49 -05:00
: link-status ( pathname -- stat )
\ stat <struct> [ [ lstat ] unix-system-call drop ] keep ;