1 ! Copyright (C) 2012 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators init io.directories io.pathnames kernel
4 namespaces system vocabs ;
7 HOOK: default-temp-directory os ( -- path )
9 SYMBOL: current-temp-directory
11 : temp-directory ( -- path )
12 current-temp-directory get ;
14 : temp-file ( name -- path )
15 temp-directory prepend-path ;
17 : with-temp-directory ( quot -- )
18 [ temp-directory ] dip with-directory ; inline
20 HOOK: default-cache-directory os ( -- path )
22 SYMBOL: current-cache-directory
24 : cache-directory ( -- path )
25 current-cache-directory get ;
27 : cache-file ( name -- path )
28 cache-directory prepend-path ;
30 : with-cache-directory ( quot -- )
31 [ cache-directory ] dip with-directory ; inline
34 { [ os windows? ] [ "io.files.temp.windows" ] }
35 { [ os macosx? ] [ "io.files.temp.macosx" ] }
36 { [ os unix? ] [ "io.files.temp.unix" ] }
40 default-temp-directory dup make-directories
41 current-temp-directory set-global
43 default-cache-directory dup make-directories
44 current-cache-directory set-global
45 ] "io.files.temp" add-startup-hook