factor/basis/unix/stat/stat.factor

72 lines
2.3 KiB
Factor
Raw Normal View History

2008-02-27 02:55:49 -05:00
2008-02-29 00:46:27 -05:00
USING: kernel system combinators alien.syntax alien.c-types
2008-05-13 15:14:27 -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.
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! File Access Permissions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Read, write, execute/search by owner
: S_IRWXU OCT: 0000700 ; inline ! rwx mask owner
: S_IRUSR OCT: 0000400 ; inline ! r owner
: S_IWUSR OCT: 0000200 ; inline ! w owner
: S_IXUSR OCT: 0000100 ; inline ! x owner
! Read, write, execute/search by group
: S_IRWXG OCT: 0000070 ; inline ! rwx mask group
: S_IRGRP OCT: 0000040 ; inline ! r group
: S_IWGRP OCT: 0000020 ; inline ! w group
: S_IXGRP OCT: 0000010 ; inline ! x group
! Read, write, execute/search by others
: S_IRWXO OCT: 0000007 ; inline ! rwx mask other
: S_IROTH OCT: 0000004 ; inline ! r other
: S_IWOTH OCT: 0000002 ; inline ! w other
: S_IXOTH OCT: 0000001 ; inline ! x other
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
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-02-29 00:46:27 -05: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-02-29 00:46:27 -05:00
}
case
>>
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: file-status ( pathname -- stat )
"stat" <c-object> dup >r
[ stat ] unix-system-call drop
r> ;
2008-02-27 02:55:49 -05:00
: link-status ( pathname -- stat )
"stat" <c-object> dup >r
2008-05-13 15:14:27 -04:00
[ lstat ] unix-system-call drop
r> ;