factor/basis/tools/files/files.factor

39 lines
1.0 KiB
Factor
Raw Normal View History

2008-11-14 01:25:00 -05:00
! 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 ;
IN: tools.files
2008-11-14 01:25:00 -05:00
2008-11-14 01:51:14 -05:00
<PRIVATE
2008-11-14 01:25:00 -05:00
: ls-time ( timestamp -- string )
[ hour>> ] [ minute>> ] bi
[ number>string 2 CHAR: 0 pad-left ] bi@ ":" swap 3append ;
: 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
2008-11-14 01:44:01 -05:00
: execute>string ( ? -- string ) "x" "-" ? ; inline
2008-11-14 01:25:00 -05:00
HOOK: (directory.) os ( path -- lines )
2008-11-14 01:51:14 -05:00
PRIVATE>
2008-11-14 01:25:00 -05:00
: directory. ( path -- )
[ (directory.) ] with-directory-files [ print ] each ;
{
{ [ os unix? ] [ "tools.files.unix" ] }
{ [ os windows? ] [ "tools.files.windows" ] }
2008-11-14 01:25:00 -05:00
} cond require