use smart combinators in tools.files.unix
parent
fe62bebb4b
commit
0ab8f11e1a
|
@ -3,12 +3,9 @@
|
||||||
USING: accessors combinators kernel system unicode.case io.files
|
USING: accessors combinators kernel system unicode.case io.files
|
||||||
io.files.info io.files.info.unix tools.files generalizations
|
io.files.info io.files.info.unix tools.files generalizations
|
||||||
strings arrays sequences math.parser unix.groups unix.users
|
strings arrays sequences math.parser unix.groups unix.users
|
||||||
tools.files.private unix.stat math fry macros ;
|
tools.files.private unix.stat math fry macros combinators.smart ;
|
||||||
IN: tools.files.unix
|
IN: tools.files.unix
|
||||||
|
|
||||||
MACRO: cleave>array ( array -- quot )
|
|
||||||
dup length '[ _ cleave _ narray ] ;
|
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: unix-execute>string ( str bools -- str' )
|
: unix-execute>string ( str bools -- str' )
|
||||||
|
@ -20,6 +17,7 @@ MACRO: cleave>array ( array -- quot )
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
: permissions-string ( permissions -- str )
|
: permissions-string ( permissions -- str )
|
||||||
|
[
|
||||||
{
|
{
|
||||||
[ type>> file-type>ch 1string ]
|
[ type>> file-type>ch 1string ]
|
||||||
[ user-read? read>string ]
|
[ user-read? read>string ]
|
||||||
|
@ -31,7 +29,8 @@ MACRO: cleave>array ( array -- quot )
|
||||||
[ other-read? read>string ]
|
[ other-read? read>string ]
|
||||||
[ other-write? write>string ]
|
[ other-write? write>string ]
|
||||||
[ [ sticky? ] [ other-execute? ] bi 2array "t" unix-execute>string ]
|
[ [ sticky? ] [ other-execute? ] bi 2array "t" unix-execute>string ]
|
||||||
} cleave>array concat ;
|
} cleave
|
||||||
|
] output>array concat ;
|
||||||
|
|
||||||
: mode>symbol ( mode -- ch )
|
: mode>symbol ( mode -- ch )
|
||||||
S_IFMT bitand
|
S_IFMT bitand
|
||||||
|
@ -48,7 +47,7 @@ MACRO: cleave>array ( array -- quot )
|
||||||
M: unix (directory.) ( path -- lines )
|
M: unix (directory.) ( path -- lines )
|
||||||
[ [
|
[ [
|
||||||
[
|
[
|
||||||
dup file-info
|
dup file-info [
|
||||||
{
|
{
|
||||||
[ permissions-string ]
|
[ permissions-string ]
|
||||||
[ nlink>> number>string 3 CHAR: \s pad-left ]
|
[ nlink>> number>string 3 CHAR: \s pad-left ]
|
||||||
|
@ -56,7 +55,8 @@ M: unix (directory.) ( path -- lines )
|
||||||
[ gid>> group-name ]
|
[ gid>> group-name ]
|
||||||
[ size>> number>string 15 CHAR: \s pad-left ]
|
[ size>> number>string 15 CHAR: \s pad-left ]
|
||||||
[ modified>> ls-timestamp ]
|
[ modified>> ls-timestamp ]
|
||||||
} cleave>array swap suffix " " join
|
} cleave
|
||||||
|
] output>array swap suffix " " join
|
||||||
] map
|
] map
|
||||||
] with-group-cache ] with-user-cache ;
|
] with-group-cache ] with-user-cache ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue