translate directory-type flags to our factor symbols
parent
3ea773fa80
commit
25d9fd68fc
|
@ -117,8 +117,8 @@ M: unix stat>file-info ( stat -- file-info )
|
||||||
[ stat-st_blksize >>blocksize ]
|
[ stat-st_blksize >>blocksize ]
|
||||||
} cleave ;
|
} cleave ;
|
||||||
|
|
||||||
M: unix stat>type ( stat -- type )
|
: n>file-type ( n -- type )
|
||||||
stat-st_mode S_IFMT bitand {
|
S_IFMT bitand {
|
||||||
{ S_IFREG [ +regular-file+ ] }
|
{ S_IFREG [ +regular-file+ ] }
|
||||||
{ S_IFDIR [ +directory+ ] }
|
{ S_IFDIR [ +directory+ ] }
|
||||||
{ S_IFCHR [ +character-device+ ] }
|
{ S_IFCHR [ +character-device+ ] }
|
||||||
|
@ -129,6 +129,9 @@ M: unix stat>type ( stat -- type )
|
||||||
[ drop +unknown+ ]
|
[ drop +unknown+ ]
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
|
M: unix stat>type ( stat -- type )
|
||||||
|
stat-st_mode n>file-type ;
|
||||||
|
|
||||||
! Linux has no extra fields in its stat struct
|
! Linux has no extra fields in its stat struct
|
||||||
os {
|
os {
|
||||||
{ macosx [ "io.unix.files.bsd" require ] }
|
{ macosx [ "io.unix.files.bsd" require ] }
|
||||||
|
@ -150,7 +153,7 @@ os {
|
||||||
|
|
||||||
M: unix >directory-entry ( byte-array -- directory-entry )
|
M: unix >directory-entry ( byte-array -- directory-entry )
|
||||||
[ dirent-d_name utf8 alien>string ]
|
[ dirent-d_name utf8 alien>string ]
|
||||||
[ dirent-d_type ] bi directory-entry boa ;
|
[ dirent-d_type dirent-type>file-type ] bi directory-entry boa ;
|
||||||
|
|
||||||
M: unix (directory-entries) ( path -- seq )
|
M: unix (directory-entries) ( path -- seq )
|
||||||
[
|
[
|
||||||
|
|
|
@ -83,16 +83,6 @@ C-STRUCT: passwd
|
||||||
: SEEK_CUR 1 ; inline
|
: SEEK_CUR 1 ; inline
|
||||||
: SEEK_END 2 ; inline
|
: SEEK_END 2 ; inline
|
||||||
|
|
||||||
: DT_UNKNOWN 0 ; inline
|
|
||||||
: DT_FIFO 1 ; inline
|
|
||||||
: DT_CHR 2 ; inline
|
|
||||||
: DT_DIR 4 ; inline
|
|
||||||
: DT_BLK 6 ; inline
|
|
||||||
: DT_REG 8 ; inline
|
|
||||||
: DT_LNK 10 ; inline
|
|
||||||
: DT_SOCK 12 ; inline
|
|
||||||
: DT_WHT 14 ; inline
|
|
||||||
|
|
||||||
os {
|
os {
|
||||||
{ macosx [ "unix.bsd.macosx" require ] }
|
{ macosx [ "unix.bsd.macosx" require ] }
|
||||||
{ freebsd [ "unix.bsd.freebsd" require ] }
|
{ freebsd [ "unix.bsd.freebsd" require ] }
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: alien alien.c-types alien.syntax kernel libc
|
||||||
sequences continuations byte-arrays strings math namespaces
|
sequences continuations byte-arrays strings math namespaces
|
||||||
system combinators vocabs.loader qualified accessors
|
system combinators vocabs.loader qualified accessors
|
||||||
stack-checker macros locals generalizations unix.types
|
stack-checker macros locals generalizations unix.types
|
||||||
debugger io prettyprint ;
|
debugger io prettyprint io.files ;
|
||||||
IN: unix
|
IN: unix
|
||||||
|
|
||||||
: PROT_NONE 0 ; inline
|
: PROT_NONE 0 ; inline
|
||||||
|
@ -20,6 +20,29 @@ IN: unix
|
||||||
|
|
||||||
: NGROUPS_MAX 16 ; inline
|
: NGROUPS_MAX 16 ; inline
|
||||||
|
|
||||||
|
: DT_UNKNOWN 0 ; inline
|
||||||
|
: DT_FIFO 1 ; inline
|
||||||
|
: DT_CHR 2 ; inline
|
||||||
|
: DT_DIR 4 ; inline
|
||||||
|
: DT_BLK 6 ; inline
|
||||||
|
: DT_REG 8 ; inline
|
||||||
|
: DT_LNK 10 ; inline
|
||||||
|
: DT_SOCK 12 ; inline
|
||||||
|
: DT_WHT 14 ; inline
|
||||||
|
|
||||||
|
: dirent-type>file-type ( ch -- type )
|
||||||
|
{
|
||||||
|
{ DT_BLK [ +block-device+ ] }
|
||||||
|
{ DT_CHR [ +character-device+ ] }
|
||||||
|
{ DT_DIR [ +directory+ ] }
|
||||||
|
{ DT_LNK [ +symbolic-link+ ] }
|
||||||
|
{ DT_SOCK [ +socket+ ] }
|
||||||
|
{ DT_FIFO [ +fifo+ ] }
|
||||||
|
{ DT_REG [ +regular-file+ ] }
|
||||||
|
{ DT_WHT [ +whiteout+ ] }
|
||||||
|
[ drop +unknown+ ]
|
||||||
|
} case ;
|
||||||
|
|
||||||
C-STRUCT: group
|
C-STRUCT: group
|
||||||
{ "char*" "gr_name" }
|
{ "char*" "gr_name" }
|
||||||
{ "char*" "gr_passwd" }
|
{ "char*" "gr_passwd" }
|
||||||
|
|
|
@ -175,6 +175,7 @@ SYMBOL: +character-device+
|
||||||
SYMBOL: +block-device+
|
SYMBOL: +block-device+
|
||||||
SYMBOL: +fifo+
|
SYMBOL: +fifo+
|
||||||
SYMBOL: +socket+
|
SYMBOL: +socket+
|
||||||
|
SYMBOL: +whiteout+
|
||||||
SYMBOL: +unknown+
|
SYMBOL: +unknown+
|
||||||
|
|
||||||
! File metadata
|
! File metadata
|
||||||
|
|
Loading…
Reference in New Issue