fix listing on unix
parent
a6b894b8c5
commit
867669f208
|
@ -22,11 +22,7 @@ IN: io.files.listing
|
|||
|
||||
: write>string ( ? -- string ) "w" "-" ? ; inline
|
||||
|
||||
HOOK: execute>string os ( ? -- string )
|
||||
|
||||
M: object execute>string ( ? -- string ) "x" "-" ? ; inline
|
||||
|
||||
HOOK: permissions-string os ( -- str )
|
||||
: execute>string ( ? -- string ) "x" "-" ? ; inline
|
||||
|
||||
HOOK: (directory.) os ( path -- lines )
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors combinators kernel system unicode.case
|
||||
io.unix.files io.files.listing generalizations ;
|
||||
io.unix.files io.files.listing generalizations strings
|
||||
arrays sequences io.files math.parser unix.groups unix.users ;
|
||||
IN: io.files.listing.unix
|
||||
|
||||
M: unix execute-string ( str bools -- str' )
|
||||
: unix-execute>string ( str bools -- str' )
|
||||
swap {
|
||||
{ { t t } [ >lower ] }
|
||||
{ { t f } [ >upper ] }
|
||||
|
@ -12,22 +13,23 @@ M: unix execute-string ( str bools -- str' )
|
|||
[ 2drop "-" ]
|
||||
} case ;
|
||||
|
||||
M: unix permissions-string ( permissions -- str )
|
||||
: permissions-string ( permissions -- str )
|
||||
{
|
||||
[ type>> file-type>ch 1string ]
|
||||
[ user-read? read>string ]
|
||||
[ user-write? write>string ]
|
||||
[ [ uid? ] [ user-execute? ] bi 2array "s" execute-string ]
|
||||
[ [ uid? ] [ user-execute? ] bi 2array "s" unix-execute>string ]
|
||||
[ group-read? read>string ]
|
||||
[ group-write? write>string ]
|
||||
[ [ gid? ] [ group-execute? ] bi 2array "s" execute-string ]
|
||||
[ [ gid? ] [ group-execute? ] bi 2array "s" unix-execute>string ]
|
||||
[ other-read? read>string ]
|
||||
[ other-write? write>string ]
|
||||
[ [ sticky? ] [ other-execute? ] bi 2array "t" execute-string ]
|
||||
[ [ sticky? ] [ other-execute? ] bi 2array "t" unix-execute>string ]
|
||||
} cleave 10 narray concat ;
|
||||
|
||||
M: unix ls ( path -- lines )
|
||||
[ [
|
||||
M: unix (directory.) ( path -- lines )
|
||||
[ [
|
||||
[
|
||||
dup file-info
|
||||
{
|
||||
[ permissions-string ]
|
||||
|
|
Loading…
Reference in New Issue