remove ls

db4
Doug Coleman 2008-11-14 00:37:56 -06:00
parent 739f02d7c0
commit bc97c989c9
10 changed files with 0 additions and 113 deletions

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -1,6 +0,0 @@
! Copyright (C) 2008 Your name.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.test ls strings kernel ;
IN: ls.tests
[ ] [ "" ls drop ] unit-test

View File

@ -1,40 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays combinators io io.files kernel
math.parser sequences system vocabs.loader calendar
sequences.lib ;
IN: ls
: ls-time ( timestamp -- string )
[ hour>> ] [ minute>> ] bi
[ number>string 2 CHAR: 0 pad-left ] bi@ ":" splice ;
: ls-timestamp ( timestamp -- string )
[ month>> month-abbreviation ]
[ day>> number>string 2 CHAR: \s pad-left ]
[
dup year>> dup now year>> =
[ drop ls-time ] [ nip number>string ] if
5 CHAR: \s pad-left
] tri 3array " " join ;
: read>string ( ? -- string ) "r" "-" ? ; inline
: write>string ( ? -- string ) "w" "-" ? ; inline
HOOK: execute>string os ( ? -- string )
M: object execute>string ( ? -- string ) "x" "-" ? ; inline
HOOK: permissions-string os ( -- str )
HOOK: (directory.) os ( path -- lines )
: directory. ( path -- )
[ (directory.) ] with-directory-files [ print ] each ;
{
{ [ os unix? ] [ "ls.unix" ] }
{ [ os windows? ] [ "ls.windows" ] }
} cond require

View File

@ -1 +0,0 @@
unportable

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -1 +0,0 @@
unportable

View File

@ -1,41 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators combinators.cleave kernel system unicode.case
io.unix.files ls ;
IN: ls.unix
M: unix execute-string ( str bools -- str' )
swap {
{ { t t } [ >lower ] }
{ { t f } [ >upper ] }
{ { f t } [ drop "x" ] }
[ 2drop "-" ]
} case ;
M: unix 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 ]
[ group-read? read>string ]
[ group-write? write>string ]
[ [ gid? ] [ group-execute? ] bi 2array "s" execute-string ]
[ other-read? read>string ]
[ other-write? write>string ]
[ [ sticky? ] [ other-execute? ] bi 2array "t" execute-string ]
} <arr> concat ;
M: unix ls ( path -- lines )
[ [
dup file-info
{
[ permissions-string ]
[ nlink>> number>string 3 CHAR: \s pad-left ]
! [ uid>> ]
! [ gid>> ]
[ size>> number>string 15 CHAR: \s pad-left ]
[ modified>> ls-timestamp ]
} <arr> swap suffix " " join
] map
] with-group-cache ] with-user-cache ;

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -1 +0,0 @@
unportable

View File

@ -1,20 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors calendar.format combinators combinators.cleave
io.files kernel math.parser sequences splitting system ls sequences.lib ;
IN: ls.windows
: directory-or-size ( file-info -- str )
dup directory? [
drop "<DIR>" 20 CHAR: \s pad-right
] [
size>> number>string 20 CHAR: \s pad-left
] if ;
M: windows (directory.) ( entries -- lines )
[
dup file-info {
[ modified>> timestamp>ymdhms " " split1 " " splice ]
[ directory-or-size ]
} <arr> swap suffix " " join
] map ;