1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types alien.strings combinators
4 grouping io.encodings.utf8 io.files kernel math sequences
5 system unix io.files.unix specialized-arrays.direct.uint arrays
6 unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx
7 io.files.info.unix io.files.info ;
8 IN: io.files.info.unix.macosx
10 TUPLE: macosx-file-system-info < unix-file-system-info
11 io-size owner type-id filesystem-subtype ;
13 M: macosx file-systems ( -- array )
14 f <void*> dup 0 getmntinfo64 dup io-error
16 "statfs64" heap-size [ * memory>byte-array ] keep group
17 [ statfs64-f_mntonname utf8 alien>string file-system-info ] map ;
18 ! [ [ new-file-system-info ] dip statfs>file-system-info ] map ;
20 M: macosx new-file-system-info macosx-file-system-info new ;
22 M: macosx file-system-statfs ( normalized-path -- statfs )
23 "statfs64" <c-object> [ statfs64 io-error ] keep ;
25 M: macosx file-system-statvfs ( normalized-path -- statvfs )
26 "statvfs" <c-object> [ statvfs io-error ] keep ;
28 M: macosx statfs>file-system-info ( file-system-info byte-array -- file-system-info' )
30 [ statfs64-f_bsize >>block-size ]
31 [ statfs64-f_iosize >>io-size ]
32 [ statfs64-f_blocks >>blocks ]
33 [ statfs64-f_bfree >>blocks-free ]
34 [ statfs64-f_bavail >>blocks-available ]
35 [ statfs64-f_files >>files ]
36 [ statfs64-f_ffree >>files-free ]
37 [ statfs64-f_fsid 2 <direct-uint-array> >array >>id ]
38 [ statfs64-f_owner >>owner ]
39 [ statfs64-f_type >>type-id ]
40 [ statfs64-f_flags >>flags ]
41 [ statfs64-f_fssubtype >>filesystem-subtype ]
42 [ statfs64-f_fstypename utf8 alien>string >>type ]
43 [ statfs64-f_mntonname utf8 alien>string >>mount-point ]
44 [ statfs64-f_mntfromname utf8 alien>string >>device-name ]
47 M: macosx statvfs>file-system-info ( file-system-info byte-array -- file-system-info' )
49 [ statvfs-f_frsize >>preferred-block-size ]
50 [ statvfs-f_favail >>files-available ]
51 [ statvfs-f_namemax >>name-max ]