! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays calendar combinators fry io io.directories
io.files.info kernel math math.parser prettyprint sequences system
-vocabs.loader sorting.slots ;
+vocabs.loader sorting.slots calendar.format ;
IN: tools.files
<PRIVATE
[ hour>> ] [ minute>> ] bi
[ number>string 2 CHAR: 0 pad-left ] bi@ ":" glue ;
-: listing-timestamp ( timestamp -- string )
+: listing-date ( timestamp -- string )
[ month>> month-abbreviation ]
[ day>> number>string 2 CHAR: \s pad-left ]
[
PRIVATE>
SYMBOLS: file-name file-name/type permissions file-type nlinks file-size
-file-datetime file-time uid gid user group link-target unix-datetime
+file-date file-time file-datetime uid gid user group link-target unix-datetime
directory-or-size ;
TUPLE: listing-tool path specs sort ;
{
{ file-name [ directory-entry>> name>> ] }
{ directory-or-size [ file-info>> dir-or-size ] }
+ { file-size [ file-info>> size>> number>string ] }
+ { file-date [ file-info>> modified>> listing-date ] }
+ { file-time [ file-info>> modified>> listing-time ] }
+ { file-datetime [ file-info>> modified>> timestamp>ymdhms ] }
[ unknown-file-spec ]
} case ;
{
{ [ os unix? ] [ "tools.files.unix" ] }
{ [ os windows? ] [ "tools.files.windows" ] }
-} cond require
\ No newline at end of file
+} cond require
M: unix (directory.) ( path -- lines )
<listing-tool>
- { permissions nlinks user group file-size file-datetime file-name } >>specs
+ { permissions nlinks user group file-size file-date file-name } >>specs
{ { directory-entry>> name>> <=> } } >>sort
[ [ list-files ] with-group-cache ] with-user-cache ;
] }
{ permissions [ file-info>> permissions-string ] }
{ nlinks [ file-info>> nlink>> number>string ] }
- { file-size [ file-info>> size>> number>string ] }
{ user [ file-info>> uid>> user-name ] }
{ group [ file-info>> gid>> group-name ] }
{ uid [ file-info>> uid>> number>string ] }
{ gid [ file-info>> gid>> number>string ] }
- { file-datetime [ file-info>> modified>> listing-timestamp ] }
- { file-time [ file-info>> modified>> listing-time ] }
[ call-next-method ]
} case ;
-PRIVATE>
\ No newline at end of file
+PRIVATE>
! See http://factorcode.org/license.txt for BSD license.
USING: accessors calendar.format combinators io.files
kernel math.parser sequences splitting system tools.files
-generalizations tools.files.private io.files.info ;
+generalizations tools.files.private io.files.info math.order ;
IN: tools.files.windows
<PRIVATE
-M: windows file-spec>string ( file-listing spec -- string )
- {
- { listing-datetime [ modified>> timestamp>ymdhms ] }
- [ call-next-method ]
- } case ;
-
M: windows (directory.) ( entries -- lines )
<listing-tool>
- { file-size file-datetime file-name } >>specs
+ { file-datetime directory-or-size file-name } >>specs
{ { directory-entry>> name>> <=> } } >>sort
list-files ;