]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/temp/macosx/macosx.factor
Update some copyright headers to follow the current convention
[factor.git] / basis / io / files / temp / macosx / macosx.factor
1 ! Copyright (C) 2012 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types alien.syntax cocoa.plists cocoa.runtime
4 cocoa.types core-foundation.strings io.directories io.files
5 io.files.temp io.pathnames kernel sequences system ;
6 IN: io.files.temp.macosx
7
8 <PRIVATE
9
10 FUNCTION: id NSTemporaryDirectory ( )
11
12 TYPEDEF: NSUInteger NSSearchPathDirectory
13 CONSTANT: NSCachesDirectory 13
14
15 TYPEDEF: NSUInteger NSSearchPathDomainMask
16 CONSTANT: NSUserDomainMask 1
17
18 FUNCTION: id NSSearchPathForDirectoriesInDomains (
19    NSSearchPathDirectory directory,
20    NSSearchPathDomainMask domainMask,
21    char expandTilde
22 )
23
24 CONSTANT: factor-bundle-name "org.factorcode.Factor"
25
26 : factor-bundle-subdir ( path -- path )
27     factor-bundle-name append-path ;
28
29 : first-existing ( paths -- path )
30     [ exists? ] find nip
31     [ "no user cache directory found" throw ] unless* ; inline
32
33 PRIVATE>
34
35 M: macosx default-temp-directory
36     NSTemporaryDirectory CF>string factor-bundle-subdir ;
37
38 M: macosx default-cache-directory
39     NSCachesDirectory NSUserDomainMask 1 NSSearchPathForDirectoriesInDomains
40     plist> first-existing factor-bundle-subdir ;