fix listing on unix

db4
Doug Coleman 2008-11-14 00:44:01 -06:00
parent a6b894b8c5
commit 867669f208
2 changed files with 11 additions and 13 deletions

View File

@ -22,11 +22,7 @@ IN: io.files.listing
: write>string ( ? -- string ) "w" "-" ? ; inline : write>string ( ? -- string ) "w" "-" ? ; inline
HOOK: execute>string os ( ? -- string ) : execute>string ( ? -- string ) "x" "-" ? ; inline
M: object execute>string ( ? -- string ) "x" "-" ? ; inline
HOOK: permissions-string os ( -- str )
HOOK: (directory.) os ( path -- lines ) HOOK: (directory.) os ( path -- lines )

View File

@ -1,10 +1,11 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators kernel system unicode.case 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 IN: io.files.listing.unix
M: unix execute-string ( str bools -- str' ) : unix-execute>string ( str bools -- str' )
swap { swap {
{ { t t } [ >lower ] } { { t t } [ >lower ] }
{ { t f } [ >upper ] } { { t f } [ >upper ] }
@ -12,22 +13,23 @@ M: unix execute-string ( str bools -- str' )
[ 2drop "-" ] [ 2drop "-" ]
} case ; } case ;
M: unix 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 ]
[ user-write? write>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-read? read>string ]
[ group-write? write>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-read? read>string ]
[ other-write? write>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 ; } cleave 10 narray concat ;
M: unix ls ( path -- lines ) M: unix (directory.) ( path -- lines )
[ [ [ [
[
dup file-info dup file-info
{ {
[ permissions-string ] [ permissions-string ]