]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/temp/temp.factor
Update some copyright headers to follow the current convention
[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 ;
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 {
34     { [ os windows? ] [ "io.files.temp.windows" ] }
35     { [ os macosx? ] [ "io.files.temp.macosx" ] }
36     { [ os unix? ] [ "io.files.temp.unix" ] }
37 } cond require
38
39 [
40     default-temp-directory dup make-directories
41     current-temp-directory set-global
42
43     default-cache-directory dup make-directories
44     current-cache-directory set-global
45 ] "io.files.temp" add-startup-hook