1 ! (c)2012 Joe Groff bsd license
2 USING: alien.c-types alien.syntax cocoa.plists cocoa.runtime
3 cocoa.types core-foundation.strings io.directories io.files
4 io.files.temp io.pathnames kernel sequences system ;
5 IN: io.files.temp.macosx
9 FUNCTION: id NSTemporaryDirectory ( )
11 TYPEDEF: NSUInteger NSSearchPathDirectory
12 CONSTANT: NSCachesDirectory 13
14 TYPEDEF: NSUInteger NSSearchPathDomainMask
15 CONSTANT: NSUserDomainMask 1
17 FUNCTION: id NSSearchPathForDirectoriesInDomains (
18 NSSearchPathDirectory directory,
19 NSSearchPathDomainMask domainMask,
23 CONSTANT: factor-bundle-name "org.factorcode.Factor"
25 : factor-bundle-subdir ( path -- path )
26 factor-bundle-name append-path ;
28 : first-existing ( paths -- path )
30 [ "no user cache directory found" throw ] unless* ; inline
34 M: macosx default-temp-directory
35 NSTemporaryDirectory CF>string factor-bundle-subdir ;
37 M: macosx default-cache-directory
38 NSCachesDirectory NSUserDomainMask 1 NSSearchPathForDirectoriesInDomains
39 plist> first-existing factor-bundle-subdir ;