1 ! Copyright (C) 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors io.files.info io.pathnames kernel mason.config
4 math math.parser namespaces sequences ;
7 : gb ( -- n ) 30 2^ ; inline
9 : sufficient-disk-space? ( -- ? )
10 ! We want at least 300Mb to be available before starting
12 current-directory get file-system-info available-space>>
15 : check-disk-space ( -- )
16 sufficient-disk-space? [
17 "Less than 1 Gb free disk space." throw
20 : mb-str ( n -- string ) gb /i number>string ;
22 : disk-usage ( -- string )
23 builds-dir get file-system-info
24 [ used-space>> ] [ total-space>> ] bi
25 [ [ mb-str ] bi@ " / " glue " Gb used" append ]
26 [ [ 100 * ] dip /i number>string "(" "%)" surround ] 2bi