1 ! (c)2012 Joe Groff bsd license
2 USING: combinators init io.directories io.pathnames kernel
3 namespaces system vocabs ;
6 HOOK: default-temp-directory os ( -- path )
8 SYMBOL: current-temp-directory
10 : temp-directory ( -- path )
11 current-temp-directory get ;
13 : temp-file ( name -- path )
14 temp-directory prepend-path ;
16 : with-temp-directory ( quot -- )
17 [ temp-directory ] dip with-directory ; inline
19 HOOK: default-cache-directory os ( -- path )
21 SYMBOL: current-cache-directory
23 : cache-directory ( -- path )
24 current-cache-directory get ;
26 : cache-file ( name -- path )
27 cache-directory prepend-path ;
29 : with-cache-directory ( quot -- )
30 [ cache-directory ] dip with-directory ; inline
33 { [ os windows? ] [ "io.files.temp.windows" ] }
34 { [ os macosx? ] [ "io.files.temp.macosx" ] }
35 { [ os unix? ] [ "io.files.temp.unix" ] }
39 default-temp-directory dup make-directories
40 current-temp-directory set-global
42 default-cache-directory dup make-directories
43 current-cache-directory set-global
44 ] "io.files.temp" add-startup-hook