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
10 FUNCTION: id NSTemporaryDirectory ( )
12 TYPEDEF: NSUInteger NSSearchPathDirectory
13 CONSTANT: NSCachesDirectory 13
15 TYPEDEF: NSUInteger NSSearchPathDomainMask
16 CONSTANT: NSUserDomainMask 1
18 FUNCTION: id NSSearchPathForDirectoriesInDomains (
19 NSSearchPathDirectory directory,
20 NSSearchPathDomainMask domainMask,
24 CONSTANT: factor-bundle-name "org.factorcode.Factor"
26 : factor-bundle-subdir ( path -- path )
27 factor-bundle-name append-path ;
29 : first-existing ( paths -- path )
31 [ "no user cache directory found" throw ] unless* ; inline
35 M: macosx default-temp-directory
36 NSTemporaryDirectory CF>string factor-bundle-subdir ;
38 M: macosx default-cache-directory
39 NSCachesDirectory NSUserDomainMask 1 NSSearchPathForDirectoriesInDomains
40 plist> first-existing factor-bundle-subdir ;