1 ! Copyright (C) 2010 Slava Pestov, Doug Coleman.
2 ! See https://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 mount-point>>
11 file-system-info available-space>> 1 Gi > ;
13 : check-disk-space ( -- )
14 sufficient-disk-space? [
15 "Less than 1 Gi free disk space." throw
18 : Gi-str ( n -- string ) 1 Gi /f ;
20 : path>disk-usage ( path -- string )
21 find-mount-point mount-point>> file-system-info
22 [ used-space>> ] [ available-space>> ] [ total-space>> ] tri
24 [ [ Gi-str ] tri@ ] dip
25 "%0.2fGi used, %0.2fGi avail, %0.2fGi total, %0.2f%% free" sprintf ;
27 : disk-usage ( -- string )
28 builds-dir get path>disk-usage ;