factor/basis/unix/statfs/statfs.factor

33 lines
1.0 KiB
Factor
Raw Normal View History

2008-10-20 01:47:51 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: sequences system vocabs.loader combinators accessors
kernel math.order sorting ;
IN: unix.statfs
TUPLE: mounted block-size io-size blocks blocks-free
blocks-available files files-free file-system-id owner type
flags filesystem-subtype file-system-type-name mount-on
mount-from ;
HOOK: mounted* os ( -- array )
2008-10-22 19:46:24 -04:00
HOOK: >mounted os ( byte-array -- mounted )
2008-10-20 01:47:51 -04:00
TUPLE: file-system-info root-directory total-free-size total-size ;
2008-10-22 00:43:36 -04:00
HOOK: >file-system-info os ( struct -- statfs )
2008-10-22 20:01:45 -04:00
: mounted ( -- array ) mounted* [ >file-system-info ] map ;
2008-10-20 01:47:51 -04:00
: mounted-drive ( path -- mounted/f )
mounted
[ [ mount-on>> ] bi@ <=> ] sort <reversed>
[ mount-on>> head? ] with find nip ;
os {
{ linux [ "unix.statfs.linux" require ] }
{ macosx [ "unix.statfs.macosx" require ] }
{ freebsd [ "unix.statfs.freebsd" require ] }
{ netbsd [ "unix.statfs.netbsd" require ] }
{ openbsd [ "unix.statfs.openbsd" require ] }
2008-10-20 01:47:51 -04:00
} case