factor/basis/unix/stat/stat.factor

34 lines
1.1 KiB
Factor
Raw Normal View History

2008-02-29 00:46:27 -05:00
USING: kernel system combinators alien.syntax alien.c-types
2008-10-07 08:43:49 -04:00
math io.unix.backend vocabs.loader unix ;
2008-02-27 02:55:49 -05:00
IN: unix.stat
! File Types
: S_IFMT OCT: 170000 ; ! These bits determine file type.
2008-04-11 13:57:43 -04:00
: S_IFDIR OCT: 40000 ; inline ! Directory.
: S_IFCHR OCT: 20000 ; inline ! Character device.
: S_IFBLK OCT: 60000 ; inline ! Block device.
: S_IFREG OCT: 100000 ; inline ! Regular file.
: S_IFIFO OCT: 010000 ; inline ! FIFO.
: S_IFLNK OCT: 120000 ; inline ! Symbolic link.
: S_IFSOCK OCT: 140000 ; inline ! Socket.
FUNCTION: int chmod ( char* path, mode_t mode ) ;
FUNCTION: int fchmod ( int fd, mode_t mode ) ;
FUNCTION: int mkdir ( char* path, mode_t mode ) ;
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 ] }
{ freebsd [ "unix.stat.freebsd" require ] }
{ netbsd [ "unix.stat.netbsd" require ] }
{ openbsd [ "unix.stat.openbsd" require ] }
2008-10-07 08:43:49 -04:00
} case >>
: file-status ( pathname -- stat )
2008-10-19 14:10:28 -04:00
"stat" <c-object> [ [ stat ] unix-system-call drop ] keep ;
2008-02-27 02:55:49 -05:00
: link-status ( pathname -- stat )
2008-10-19 14:10:28 -04:00
"stat" <c-object> [ [ lstat ] unix-system-call drop ] keep ;