]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/info/unix/macosx/macosx.factor
Remove usages of <void*> and *void*
[factor.git] / basis / io / files / info / unix / macosx / macosx.factor
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 system
5 unix io.files.unix arrays unix.statfs.macosx unix.statvfs.macosx
6 unix.getfsstat.macosx io.files.info.unix io.files.info
7 classes.struct specialized-arrays ;
8 SPECIALIZED-ARRAY: uint
9 SPECIALIZED-ARRAY: statfs64
10 IN: io.files.info.unix.macosx
11
12 TUPLE: macosx-file-system-info < unix-file-system-info
13 io-size owner type-id filesystem-subtype ;
14
15 M: macosx file-systems ( -- array )
16     f void* <ref> dup 0 getmntinfo64 dup io-error
17     [ void* deref ] dip <direct-statfs64-array>
18     [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ;
19
20 M: macosx new-file-system-info macosx-file-system-info new ;
21
22 M: macosx file-system-statfs ( normalized-path -- statfs )
23     \ statfs64 <struct> [ statfs64 io-error ] keep ;
24
25 M: macosx file-system-statvfs ( normalized-path -- statvfs )
26     \ statvfs <struct> [ statvfs io-error ] keep ;
27
28 M: macosx statfs>file-system-info ( file-system-info byte-array -- file-system-info' )
29     {
30         [ f_bsize>> >>block-size ]
31         [ f_iosize>> >>io-size ]
32         [ f_blocks>> >>blocks ]
33         [ f_bfree>> >>blocks-free ]
34         [ f_bavail>> >>blocks-available ]
35         [ f_files>> >>files ]
36         [ f_ffree>> >>files-free ]
37         [ f_fsid>> >>id ]
38         [ f_owner>> >>owner ]
39         [ f_type>> >>type-id ]
40         [ f_flags>> >>flags ]
41         [ f_fssubtype>> >>filesystem-subtype ]
42         [ f_fstypename>> utf8 alien>string >>type ]
43         [ f_mntonname>> utf8 alien>string >>mount-point ]
44         [ f_mntfromname>> utf8 alien>string >>device-name ]
45     } cleave ;
46
47 M: macosx statvfs>file-system-info ( file-system-info byte-array -- file-system-info' )
48     {
49         [ f_frsize>> >>preferred-block-size ]
50         [ f_favail>> >>files-available ]
51         [ f_namemax>> >>name-max ]
52     } cleave ;