3 classvar defaultStartupFile;
4 var <classLibraryDir, <helpDir, <>recordingsDir, features;
9 defaultStartupFile = this.userConfigDir +/+ "startup.scd"
13 classLibraryDir = thisMethod.filenameSymbol.asString.dirname.dirname;
14 helpDir = thisMethod.filenameSymbol.asString.dirname.dirname.dirname ++ "/Help";
15 features = IdentityDictionary.new;
16 recordingsDir = this.userAppSupportDir +/+ "Recordings";
19 name { ^this.subclassResponsibility }
21 recompile { ^this.subclassResponsibility }
23 ^thisProcess.platform.name.switch(*cases)
27 *classLibraryDir { ^thisProcess.platform.classLibraryDir }
28 *helpDir { ^thisProcess.platform.helpDir }
30 systemAppSupportDir { _Platform_systemAppSupportDir }
31 *systemAppSupportDir { ^thisProcess.platform.systemAppSupportDir }
33 userAppSupportDir { _Platform_userAppSupportDir }
34 *userAppSupportDir { ^thisProcess.platform.userAppSupportDir }
36 systemExtensionDir { _Platform_systemExtensionDir }
37 *systemExtensionDir { ^thisProcess.platform.systemExtensionDir }
39 userExtensionDir { _Platform_userExtensionDir }
40 *userExtensionDir { ^thisProcess.platform.userExtensionDir }
42 userConfigDir { _Platform_userConfigDir }
43 *userConfigDir { ^thisProcess.platform.userConfigDir }
45 defaultTempDir { ^this.subclassResponsibility() }
46 *defaultTempDir { ^thisProcess.platform.defaultTempDir }
48 // The "ideName" is for ide-dependent compilation.
49 // From SC.app, the value is "scapp" meaning "scide_scapp" folders will be compiled and other "scide_*" ignored.
50 ideName { _Platform_ideName }
51 *ideName { ^thisProcess.platform.ideName }
53 platformDir { ^this.name.asString }
54 *platformDir { ^thisProcess.platform.platformDir }
56 pathSeparator { ^this.subclassResponsibility }
57 *pathSeparator { ^thisProcess.platform.pathSeparator }
59 isPathSeparator { |char| ^this.subclassResponsibility }
60 *isPathSeparator { |char| ^thisProcess.platform.isPathSeparator(char) }
62 clearMetadata { |path| ^this.subclassResponsibility }
63 *clearMetadata { |path| ^thisProcess.platform.clearMetadata(path) }
65 getMouseCoords { ^this.subclassResponsibility }
66 *getMouseCoords { ^thisProcess.platform.getMouseCoords }
68 // startup/shutdown hooks
73 ^[defaultStartupFile];
76 *deprecatedStartupFiles {|paths|
77 var postWarning = false;
79 if (File.exists(path.standardizePath)) {
80 warn("Deprecated startup file found: %\n".format(path));
85 postln("Please use % as startup file.\nDeprecated startup files will be ignored in future versions.\n".format(defaultStartupFile));
89 loadStartupFiles { this.startupFiles.do{|afile|
90 afile = afile.standardizePath;
91 if(File.exists(afile), {afile.load})
96 declareFeature { | aFeature |
97 var str = aFeature.asString;
98 if (str.first.isUpper) {
99 Error("cannot declare class name features").throw;
101 if (str.first == $_) {
102 Error("cannot declare primitive name features").throw;
104 features.put(aFeature, true);
106 hasFeature { | symbol |
107 if (features.includesKey(symbol).not) {
110 symbol.asSymbol.asClass.notNil or: { symbol.isPrimitive }
115 when { | features, ifFunction, elseFunction |
116 ^features.asArray.inject(true, { |v,x|
117 v and: { this.hasFeature(x) }
118 }).if(ifFunction, elseFunction)
120 *when { | features, ifFunction, elseFunction |
121 ^thisProcess.platform.when(features, ifFunction, elseFunction)
124 // Prefer qt but fall back to swing if qt not installed.
125 defaultGUIScheme { if (GUI.get(\qt).notNil) {^\qt} {^\swing} }
126 defaultHIDScheme { ^\none }
128 isSleeping { ^false } // unless defined otherwise
130 // used on systems to deduce a svn directory path, if system wide location is used for installed version. (tested on Linux).
133 if ( devpath.isNil ){ ^inpath };
134 outpath = inpath.copyToEnd( inpath.find( "SuperCollider") );
135 outpath = outpath.replace( "SuperCollider", devpath );
139 // hook for clients to write frontend.css
142 killAll { |cmdLineArgs|
143 ^this.subclassResponsibility(\killAll)
147 UnixPlatform : Platform
149 pathSeparator { ^$/ }
151 isPathSeparator { |char|
152 ^(char === this.pathSeparator)
155 clearMetadata { |path|
156 "rm -f %\.*meta".format(path.splitext[0].escapeChar($ )).systemCmd;
161 pipe = Pipe("arch", "r");
167 killAll { |cmdLineArgs|
168 ("killall -9 " ++ cmdLineArgs).unixCmd;
172 // +/+ "" looks funny but ensures trailing slash
173 ^["/tmp/", this.userAppSupportDir +/+ ""].detect({ |path|