1 ! Copyright (C) 2010 Slava Pestov, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors formatting io.files.info io.pathnames kernel
4 mason.config math namespaces ;
7 : Gi ( n -- gibibits ) 30 2^ * ; inline
9 : sufficient-disk-space? ( -- ? )
10 current-directory get find-mount-point-info
11 file-system-info available-space>>
14 : check-disk-space ( -- )
15 sufficient-disk-space? [
16 "Less than 1 Gi free disk space." throw
19 : Gi-str ( n -- string ) 1 Gi /f ;
21 : path>disk-usage ( path -- string )
23 [ used-space>> ] [ available-space>> ] [ total-space>> ] tri
25 [ [ Gi-str ] tri@ ] dip
26 "%0.2fGi used, %0.2fGi avail, %0.2fGi total, %0.2f%% free" sprintf ;
28 : disk-usage ( -- string )
29 builds-dir get path>disk-usage ;