diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor index 65b40543af..fcde1ccedf 100644 --- a/basis/help/cookbook/cookbook.factor +++ b/basis/help/cookbook/cookbook.factor @@ -269,7 +269,7 @@ $nl { $heading "Example: ls" } "Here is an example implementing a simplified version of the Unix " { $snippet "ls" } " command in Factor:" { $code - <" USING: command-line namespaces io io.files io.files.listing + <" USING: command-line namespaces io io.files tools.files sequences kernel ; command-line get [ diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 05bab8c654..6f542361ee 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -80,7 +80,7 @@ TUPLE: unix-file-system-info < file-system-info block-size preferred-block-size blocks blocks-free blocks-available files files-free files-available -name-max flags id ; +name-max flags id id0 id1 ; HOOK: new-file-system-info os ( -- file-system-info ) @@ -108,6 +108,8 @@ M: unix statvfs>file-system-info drop ; [ dup [ blocks-free>> ] [ block-size>> ] bi * >>free-space drop ] [ dup [ blocks>> ] [ block-size>> ] bi * >>total-space drop ] [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ] + [ dup id>> 2 c-uint-array> first2 [ >>id0 ] [ >>id1 ] bi* drop ] + [ f >>id drop ] [ ] } cleave ; diff --git a/basis/io/unix/files/freebsd/freebsd.factor b/basis/io/unix/files/freebsd/freebsd.factor index 2c8f4bb438..3786a82b55 100644 --- a/basis/io/unix/files/freebsd/freebsd.factor +++ b/basis/io/unix/files/freebsd/freebsd.factor @@ -2,23 +2,53 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators io.backend io.files io.unix.files kernel math system unix -unix.statvfs.freebsd ; +unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd +sequences grouping alien.strings io.encodings.utf8 ; IN: io.unix.files.freebsd +TUPLE: freebsd-file-system-info < unix-file-system-info +version io-size owner syncreads syncwrites asyncreads asyncwrites ; + +M: freebsd new-file-system-info freebsd-file-system-info new ; + +M: freebsd file-system-statfs ( path -- byte-array ) + "statfs" tuck statfs io-error ; + +M: freebsd statfs>file-system-info ( file-system-info statvfs -- file-system-info ) + { + [ statfs-f_version >>version ] + [ statfs-f_type >>type ] + [ statfs-f_flags >>flags ] + [ statfs-f_bsize >>block-size ] + [ statfs-f_iosize >>io-size ] + [ statfs-f_blocks >>blocks ] + [ statfs-f_bfree >>blocks-free ] + [ statfs-f_bavail >>blocks-available ] + [ statfs-f_files >>files ] + [ statfs-f_ffree >>files-free ] + [ statfs-f_syncwrites >>syncwrites ] + [ statfs-f_asyncwrites >>asyncwrites ] + [ statfs-f_syncreads >>syncreads ] + [ statfs-f_asyncreads >>asyncreads ] + [ statfs-f_namemax >>name-max ] + [ statfs-f_owner >>owner ] + [ statfs-f_fsid >>id ] + [ statfs-f_fstypename utf8 alien>string >>type ] + [ statfs-f_mntfromname utf8 alien>string >>device-name ] + [ statfs-f_mntonname utf8 alien>string >>mount-point ] + } cleave ; + M: freebsd file-system-statvfs ( path -- byte-array ) "statvfs" tuck statvfs io-error ; M: freebsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info ) { - [ statvfs-f_bavail >>blocks-available ] - [ statvfs-f_bfree >>blocks-free ] - [ statvfs-f_blocks >>blocks ] [ statvfs-f_favail >>files-available ] - [ statvfs-f_ffree >>files-free ] - [ statvfs-f_files >>files ] - [ statvfs-f_bsize >>block-size ] - [ statvfs-f_flag >>flags ] [ statvfs-f_frsize >>preferred-block-size ] - [ statvfs-f_fsid >>id ] - [ statvfs-f_namemax >>name-max ] } cleave ; + +M: freebsd file-systems ( -- array ) + f 0 0 getfsstat dup io-error + "statfs" dup dup length 0 getfsstat io-error + "statfs" heap-size group + [ statfs-f_mntonname alien>native-string file-system-info ] map ; diff --git a/basis/io/unix/files/macosx/macosx.factor b/basis/io/unix/files/macosx/macosx.factor index 8a1eb9c89b..5b128143d9 100644 --- a/basis/io/unix/files/macosx/macosx.factor +++ b/basis/io/unix/files/macosx/macosx.factor @@ -10,10 +10,10 @@ TUPLE: macosx-file-system-info < unix-file-system-info io-size owner type-id filesystem-subtype ; M: macosx file-systems ( -- array ) - f 0 0 getfsstat64 dup io-error - "statfs" dup dup length 0 getfsstat64 io-error - "statfs" heap-size group - [ statfs64-f_mntonname alien>native-string file-system-info ] map ; + f dup 0 getmntinfo64 dup io-error + [ *void* ] dip + "statfs64" heap-size [ * memory>byte-array ] keep group + [ [ new-file-system-info ] dip statfs>file-system-info ] map ; M: macosx new-file-system-info macosx-file-system-info new ; diff --git a/basis/io/unix/files/netbsd/netbsd.factor b/basis/io/unix/files/netbsd/netbsd.factor index 7140847f9a..c200331db5 100644 --- a/basis/io/unix/files/netbsd/netbsd.factor +++ b/basis/io/unix/files/netbsd/netbsd.factor @@ -3,15 +3,14 @@ USING: alien.syntax kernel unix.stat math unix combinators system io.backend accessors alien.c-types io.encodings.utf8 alien.strings unix.types io.unix.files -io.files unix.statvfs.netbsd ; +io.files unix.statvfs.netbsd unix.getfsstat.netbsd +grouping sequences ; IN: io.unix.files.netbsd TUPLE: netbsd-file-system-info < unix-file-system-info blocks-reserved files-reserved -owner io-size -sync-reads sync-writes -async-reads async-writes -idx mount-from spare ; +owner io-size sync-reads sync-writes async-reads async-writes +idx mount-from ; M: netbsd new-file-system-info netbsd-file-system-info new ; @@ -40,10 +39,14 @@ M: netbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-inf [ statvfs-f_fsid >>id ] [ statvfs-f_namemax >>name-max ] [ statvfs-f_owner >>owner ] - [ statvfs-f_spare >>spare ] + ! [ statvfs-f_spare >>spare ] [ statvfs-f_fstypename alien>native-string >>type ] [ statvfs-f_mntonname alien>native-string >>mount-point ] [ statvfs-f_mntfromname alien>native-string >>device-name ] } cleave ; -FUNCTION: int statvfs ( char* path, statvfs* buf ) ; +M: netbsd file-systems ( -- array ) + f 0 0 getvfsstat dup io-error + "statvfs" dup dup length 0 getvfsstat io-error + "statvfs" heap-size group + [ statvfs-f_mntonname alien>native-string file-system-info ] map ; diff --git a/basis/io/files/listing/authors.txt b/basis/tools/files/authors.txt similarity index 100% rename from basis/io/files/listing/authors.txt rename to basis/tools/files/authors.txt diff --git a/basis/io/files/listing/listing-docs.factor b/basis/tools/files/files-docs.factor similarity index 67% rename from basis/io/files/listing/listing-docs.factor rename to basis/tools/files/files-docs.factor index 6b19e9bfa7..c5c5b44c1b 100644 --- a/basis/io/files/listing/listing-docs.factor +++ b/basis/tools/files/files-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: help.markup help.syntax io.streams.string strings ; -IN: io.files.listing +IN: tools.files HELP: directory. { $values @@ -9,9 +9,9 @@ HELP: directory. } { $description "Prints information about all files in a directory to the output stream in a cross-platform way similar to the Unix " { $snippet "ls" } " command." } ; -ARTICLE: "io.files.listing" "Listing files" -"The " { $vocab-link "io.files.listing" } " vocabulary implements directory file listing in a cross-platform way." $nl +ARTICLE: "tools.files" "Files tools" +"The " { $vocab-link "tools.files" } " vocabulary implements directory files and file-systems listing in a cross-platform way." $nl "Listing a directory:" { $subsection directory. } ; -ABOUT: "io.files.listing" +ABOUT: "tools.files" diff --git a/basis/io/files/listing/listing-tests.factor b/basis/tools/files/files-tests.factor similarity index 65% rename from basis/io/files/listing/listing-tests.factor rename to basis/tools/files/files-tests.factor index 8c2dc28559..6aa68d8127 100644 --- a/basis/io/files/listing/listing-tests.factor +++ b/basis/tools/files/files-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Your name. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test io.files.listing strings kernel ; -IN: io.files.listing.tests +USING: tools.test tools.files strings kernel ; +IN: tools.files.tests \ directory. must-infer diff --git a/basis/io/files/listing/listing.factor b/basis/tools/files/files.factor similarity index 87% rename from basis/io/files/listing/listing.factor rename to basis/tools/files/files.factor index f88fcec3a1..58c24ef6ca 100755 --- a/basis/io/files/listing/listing.factor +++ b/basis/tools/files/files.factor @@ -2,8 +2,7 @@ ! 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: io.files.listing +IN: tools.files [ (directory.) ] with-directory-files [ print ] each ; { - { [ os unix? ] [ "io.files.listing.unix" ] } - { [ os windows? ] [ "io.files.listing.windows" ] } + { [ os unix? ] [ "tools.files.unix" ] } + { [ os windows? ] [ "tools.files.windows" ] } } cond require diff --git a/basis/io/files/listing/tags.txt b/basis/tools/files/tags.txt similarity index 100% rename from basis/io/files/listing/tags.txt rename to basis/tools/files/tags.txt diff --git a/basis/io/files/listing/unix/authors.txt b/basis/tools/files/unix/authors.txt similarity index 100% rename from basis/io/files/listing/unix/authors.txt rename to basis/tools/files/unix/authors.txt diff --git a/basis/io/files/listing/unix/tags.txt b/basis/tools/files/unix/tags.txt similarity index 100% rename from basis/io/files/listing/unix/tags.txt rename to basis/tools/files/unix/tags.txt diff --git a/basis/io/files/listing/unix/unix.factor b/basis/tools/files/unix/unix.factor similarity index 93% rename from basis/io/files/listing/unix/unix.factor rename to basis/tools/files/unix/unix.factor index bef8d3dc56..184f371b1c 100755 --- a/basis/io/files/listing/unix/unix.factor +++ b/basis/tools/files/unix/unix.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators kernel system unicode.case -io.unix.files io.files.listing generalizations strings +io.unix.files tools.files generalizations strings arrays sequences io.files math.parser unix.groups unix.users -io.files.listing.private unix.stat math ; -IN: io.files.listing.unix +tools.files.private unix.stat math ; +IN: tools.files.unix