Platform.icl 1.37 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1
2
implementation module Platform

Diederik van Arkel's avatar
Diederik van Arkel committed
3
import StdInt, StdMisc, StdFile
4
import StdTuple,StdOverloaded,StdArray
Diederik van Arkel's avatar
Diederik van Arkel committed
5
import StdSystem
Diederik van Arkel's avatar
Diederik van Arkel committed
6

Diederik van Arkel's avatar
Diederik van Arkel committed
7
8
PlatformDependant win mac
	:== mac
Diederik van Arkel's avatar
Diederik van Arkel committed
9

10
// FIXME: should be IdePlatform
Diederik van Arkel's avatar
Diederik van Arkel committed
11
12
13
14
15
16
17
18
batchOptions	:: !*World -> (!Bool,Bool,String,*File,!*World)
batchOptions world
	# interact		= True
	  force_update	= undef
	  prj_name		= undef
	  logfile		= undef
	= (interact,force_update,prj_name,logfile,world)

19
// FIXME: should be IdePlatform
Diederik van Arkel's avatar
Diederik van Arkel committed
20
21
22
23
24
25
wAbort			:: !String !*World -> *World
wAbort message world
	# stderr	= fwrites message stderr
	# (_,world)	= fclose stderr world
	= world

Diederik van Arkel's avatar
Diederik van Arkel committed
26
27
TempDir	:: String
TempDir = applicationpath "Temp"
Diederik van Arkel's avatar
Diederik van Arkel committed
28
29
30
31
32
33

EnvsDir		:: String
EnvsDir = applicationpath "Config"

PrefsDir	:: String
PrefsDir = applicationpath "Config"
Diederik van Arkel's avatar
Diederik van Arkel committed
34
35
36

BitmapDir	:: String
BitmapDir = applicationpath "Bitmaps"
Diederik van Arkel's avatar
Diederik van Arkel committed
37
38
39
40

//////////////

:: OSStatus	:== Int
41
42

onOSX :: Bool
43
onOSX =: fst (runningCarbonOSX 0/*OSNewToolbox*/)
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

runningCarbonOSX tb
	# (err,res,tb)	= Gestalt "sysv" tb
	| err <> 0 = abort "Gestalt failed.\n"
	= (res >= 0x01000, tb)

Gestalt :: !String !*Int -> (!Int,!Int,!*Int)
Gestalt sSel tb
	| size sSel <> 4 = abort "Gestalt not called with four-char selector.\n"
	# iSel	= ((toInt sSel.[0]) << 24) bitor ((toInt sSel.[1]) << 16) bitor ((toInt sSel.[2]) << 8) bitor ((toInt sSel.[3]) << 0)
	= Gestalt iSel tb
where
	Gestalt :: !Int !*Int -> (!Int,!Int,!*Int)
	Gestalt _ _ = code {
		ccall Gestalt "PI:II:I"
		}