use +foo+ as symbol names
parent
b3e3c74561
commit
cbe99c4bed
|
@ -35,9 +35,10 @@ IN: tools.files
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
SYMBOLS: file-name file-name/type permissions file-type nlinks file-size
|
SYMBOLS: +file-name+ +file-name/type+ +permissions+ +file-type+
|
||||||
file-date file-time file-datetime uid gid user group link-target unix-datetime
|
+nlinks+ +file-size+ +file-date+ +file-time+ +file-datetime+
|
||||||
directory-or-size ;
|
+uid+ +gid+ +user+ +group+ +link-target+ +unix-datetime+
|
||||||
|
+directory-or-size+ ;
|
||||||
|
|
||||||
TUPLE: listing-tool path specs sort ;
|
TUPLE: listing-tool path specs sort ;
|
||||||
|
|
||||||
|
@ -48,10 +49,10 @@ C: <file-listing> file-listing
|
||||||
: <listing-tool> ( path -- listing-tool )
|
: <listing-tool> ( path -- listing-tool )
|
||||||
listing-tool new
|
listing-tool new
|
||||||
swap >>path
|
swap >>path
|
||||||
{ file-name } >>specs ;
|
{ +file-name+ } >>specs ;
|
||||||
|
|
||||||
: list-slow? ( listing-tool -- ? )
|
: list-slow? ( listing-tool -- ? )
|
||||||
specs>> { file-name } sequence= not ;
|
specs>> { +file-name+ } sequence= not ;
|
||||||
|
|
||||||
ERROR: unknown-file-spec symbol ;
|
ERROR: unknown-file-spec symbol ;
|
||||||
|
|
||||||
|
@ -59,12 +60,12 @@ HOOK: file-spec>string os ( file-listing spec -- string )
|
||||||
|
|
||||||
M: object file-spec>string ( file-listing spec -- string )
|
M: object file-spec>string ( file-listing spec -- string )
|
||||||
{
|
{
|
||||||
{ file-name [ directory-entry>> name>> ] }
|
{ +file-name+ [ directory-entry>> name>> ] }
|
||||||
{ directory-or-size [ file-info>> dir-or-size ] }
|
{ +directory-or-size+ [ file-info>> dir-or-size ] }
|
||||||
{ file-size [ file-info>> size>> number>string ] }
|
{ +file-size+ [ file-info>> size>> number>string ] }
|
||||||
{ file-date [ file-info>> modified>> listing-date ] }
|
{ +file-date+ [ file-info>> modified>> listing-date ] }
|
||||||
{ file-time [ file-info>> modified>> listing-time ] }
|
{ +file-time+ [ file-info>> modified>> listing-time ] }
|
||||||
{ file-datetime [ file-info>> modified>> timestamp>ymdhms ] }
|
{ +file-datetime+ [ file-info>> modified>> timestamp>ymdhms ] }
|
||||||
[ unknown-file-spec ]
|
[ unknown-file-spec ]
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
|
@ -85,22 +86,22 @@ HOOK: (directory.) os ( path -- lines )
|
||||||
|
|
||||||
: directory. ( path -- ) (directory.) simple-table. ;
|
: directory. ( path -- ) (directory.) simple-table. ;
|
||||||
|
|
||||||
SYMBOLS: device-name mount-point type
|
SYMBOLS: +device-name+ +mount-point+ +type+
|
||||||
available-space free-space used-space total-space
|
+available-space+ +free-space+ +used-space+ +total-space+
|
||||||
percent-used percent-free ;
|
+percent-used+ +percent-free+ ;
|
||||||
|
|
||||||
: percent ( real -- integer ) 100 * >integer ; inline
|
: percent ( real -- integer ) 100 * >integer ; inline
|
||||||
|
|
||||||
: file-system-spec ( file-system-info obj -- str )
|
: file-system-spec ( file-system-info obj -- str )
|
||||||
{
|
{
|
||||||
{ device-name [ device-name>> "" or ] }
|
{ +device-name+ [ device-name>> "" or ] }
|
||||||
{ mount-point [ mount-point>> "" or ] }
|
{ +mount-point+ [ mount-point>> "" or ] }
|
||||||
{ type [ type>> "" or ] }
|
{ +type+ [ type>> "" or ] }
|
||||||
{ available-space [ available-space>> 0 or ] }
|
{ +available-space+ [ available-space>> 0 or ] }
|
||||||
{ free-space [ free-space>> 0 or ] }
|
{ +free-space+ [ free-space>> 0 or ] }
|
||||||
{ used-space [ used-space>> 0 or ] }
|
{ +used-space+ [ used-space>> 0 or ] }
|
||||||
{ total-space [ total-space>> 0 or ] }
|
{ +total-space+ [ total-space>> 0 or ] }
|
||||||
{ percent-used [
|
{ +percent-used+ [
|
||||||
[ used-space>> ] [ total-space>> ] bi
|
[ used-space>> ] [ total-space>> ] bi
|
||||||
[ 0 or ] bi@ dup 0 =
|
[ 0 or ] bi@ dup 0 =
|
||||||
[ 2drop 0 ] [ / percent ] if
|
[ 2drop 0 ] [ / percent ] if
|
||||||
|
@ -116,8 +117,8 @@ percent-used percent-free ;
|
||||||
|
|
||||||
: file-systems. ( -- )
|
: file-systems. ( -- )
|
||||||
{
|
{
|
||||||
device-name available-space free-space used-space
|
+device-name+ +available-space+ +free-space+ +used-space+
|
||||||
total-space percent-used mount-point
|
+total-space+ +percent-used+ +mount-point+
|
||||||
} print-file-systems ;
|
} print-file-systems ;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,21 +47,24 @@ IN: tools.files.unix
|
||||||
|
|
||||||
M: unix (directory.) ( path -- lines )
|
M: unix (directory.) ( path -- lines )
|
||||||
<listing-tool>
|
<listing-tool>
|
||||||
{ permissions nlinks user group file-size file-date file-name } >>specs
|
{
|
||||||
|
+permissions+ +nlinks+ +user+ +group+
|
||||||
|
+file-size+ +file-date+ +file-name+
|
||||||
|
} >>specs
|
||||||
{ { directory-entry>> name>> <=> } } >>sort
|
{ { directory-entry>> name>> <=> } } >>sort
|
||||||
[ [ list-files ] with-group-cache ] with-user-cache ;
|
[ [ list-files ] with-group-cache ] with-user-cache ;
|
||||||
|
|
||||||
M: unix file-spec>string ( file-listing spec -- string )
|
M: unix file-spec>string ( file-listing spec -- string )
|
||||||
{
|
{
|
||||||
{ file-name/type [
|
{ +file-name/type+ [
|
||||||
directory-entry>> [ name>> ] [ file-type>trailing ] bi append
|
directory-entry>> [ name>> ] [ file-type>trailing ] bi append
|
||||||
] }
|
] }
|
||||||
{ permissions [ file-info>> permissions-string ] }
|
{ +permissions+ [ file-info>> permissions-string ] }
|
||||||
{ nlinks [ file-info>> nlink>> number>string ] }
|
{ +nlinks+ [ file-info>> nlink>> number>string ] }
|
||||||
{ user [ file-info>> uid>> user-name ] }
|
{ +user+ [ file-info>> uid>> user-name ] }
|
||||||
{ group [ file-info>> gid>> group-name ] }
|
{ +group+ [ file-info>> gid>> group-name ] }
|
||||||
{ uid [ file-info>> uid>> number>string ] }
|
{ +uid+ [ file-info>> uid>> number>string ] }
|
||||||
{ gid [ file-info>> gid>> number>string ] }
|
{ +gid+ [ file-info>> gid>> number>string ] }
|
||||||
[ call-next-method ]
|
[ call-next-method ]
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ IN: tools.files.windows
|
||||||
|
|
||||||
M: windows (directory.) ( entries -- lines )
|
M: windows (directory.) ( entries -- lines )
|
||||||
<listing-tool>
|
<listing-tool>
|
||||||
{ file-datetime directory-or-size file-name } >>specs
|
{ +file-datetime+ +directory-or-size+ +file-name+ } >>specs
|
||||||
{ { directory-entry>> name>> <=> } } >>sort
|
{ { directory-entry>> name>> <=> } } >>sort
|
||||||
list-files ;
|
list-files ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue