]> gitweb.factorcode.org Git - factor.git/commitdiff
fix file listing on windows, refactor tools.files cross-platform code
authorU-FROGGER\erg <erg@frogger.(none)>
Wed, 14 Jan 2009 00:44:47 +0000 (18:44 -0600)
committerU-FROGGER\erg <erg@frogger.(none)>
Wed, 14 Jan 2009 00:44:47 +0000 (18:44 -0600)
basis/tools/files/files.factor
basis/tools/files/unix/unix.factor
basis/tools/files/windows/windows.factor

index 47c7d57c0958883712e655a08e5aceaa9fe93c39..936c68232248b8babc645db6f0e324613303b3ad 100755 (executable)
@@ -2,7 +2,7 @@
 ! 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
@@ -18,7 +18,7 @@ IN: tools.files
     [ 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 ]
     [
@@ -36,7 +36,7 @@ IN: tools.files
 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 ;
@@ -61,6 +61,10 @@ M: object file-spec>string ( file-listing spec -- string )
     {
         { 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 ;
 
@@ -119,4 +123,4 @@ percent-used percent-free ;
 {
     { [ os unix? ] [ "tools.files.unix" ] }
     { [ os windows? ] [ "tools.files.windows" ] }
-} cond require
\ No newline at end of file
+} cond require
index c6bc7fc2c123a073ccc438b9b0d70729922f6176..e63ab09076fdd1f99cec080effa7705f09812851 100755 (executable)
@@ -47,7 +47,7 @@ IN: tools.files.unix
 
 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 ;
 
@@ -58,14 +58,11 @@ M: unix file-spec>string ( file-listing spec -- string )
         ] }
         { 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>
index 3284ec8d8b33696a9ee546ae45b04c000cedb060..f321c2fc7f4507ffa2807c4777bff49e99a9fb60 100755 (executable)
@@ -2,20 +2,14 @@
 ! 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 ;