]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/temp/temp.factor
factor: more top level forms.
[factor.git] / basis / io / files / temp / temp.factor
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 vocabs.platforms ;
5 IN: io.files.temp
6
7 HOOK: default-temp-directory os ( -- path )
8
9 SYMBOL: current-temp-directory
10
11 : temp-directory ( -- path )
12     current-temp-directory get ;
13
14 : temp-file ( name -- path )
15     temp-directory prepend-path ;
16
17 : with-temp-directory ( quot -- )
18     [ temp-directory ] dip with-directory ; inline
19
20 HOOK: default-cache-directory os ( -- path )
21
22 SYMBOL: current-cache-directory
23
24 : cache-directory ( -- path )
25     current-cache-directory get ;
26
27 : cache-file ( name -- path )
28     cache-directory prepend-path ;
29
30 : with-cache-directory ( quot -- )
31     [ cache-directory ] dip with-directory ; inline
32
33 USE-MACOSX: io.files.temp.macosx
34 USE-UNIX: io.files.temp.unix
35 USE-WINDOWS: io.files.temp.windows
36
37 STARTUP-HOOK: [
38     default-temp-directory dup make-directories
39     current-temp-directory set-global
40
41     default-cache-directory dup make-directories
42     current-cache-directory set-global
43 ]