Skip to content

Commit

Permalink
(3.4) PathName now sets tmp directory using Platform
Browse files Browse the repository at this point in the history
This fixes a bug where we were writing temp files into
c:\program files\supercollider, which is an absolute no-no in win7/vista.
  • Loading branch information
James Harkins committed Sep 4, 2011
1 parent d3898df commit fe9d5d8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
4 changes: 1 addition & 3 deletions common/build/SCClassLibrary/Common/Files/PathName.sc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ PathName {
}
*initClass {
scroot = File.getcwd;
tmp = ["/tmp/", scroot ++ "\\sounds\\", "sounds/"].detect({ |path|
File.exists(path);
});
tmp = Platform.defaultTempDir;
tmp.isNil.if(
{"No valid temp directory found. Please set this manually using PathName.tmp_".warn});
}
Expand Down
10 changes: 10 additions & 0 deletions common/build/SCClassLibrary/Platform/Platform.sc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Platform
userExtensionDir { _Platform_userExtensionDir }
*userExtensionDir { ^thisProcess.platform.userExtensionDir }

defaultTempDir { ^this.subclassResponsibility(\defaultTempDir) }
*defaultTempDir { ^thisProcess.platform.defaultTempDir }

// The "ideName" is for ide-dependent compilation.
// From SC.app, the value is "scapp" meaning "scide_scapp" folders will be compiled and other "scide_*" ignored.
ideName { _Platform_ideName }
Expand Down Expand Up @@ -130,4 +133,11 @@ UnixPlatform : Platform
pipe.close;
^arch.asSymbol;
}

defaultTempDir {
// +/+ "" looks funny but ensures trailing slash
^["/tmp/", this.userAppSupportDir +/+ ""].detect({ |path|
File.exists(path);
});
}
}
44 changes: 25 additions & 19 deletions common/build/SCClassLibrary/Platform/windows/WindowsPlatform.sc
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
WindowsPlatform : Platform
{
name { ^\windows }
startupFiles { ^["startup.sc", "~\\SuperCollider\\startup.sc".standardizePath] }
startup {
// Server setup
Server.program = "scsynth.exe";

// Score setup
Score.program = Server.program;

// load user startup file
this.loadStartupFiles;
}

defaultGUIScheme { ^\swing }
defaultHIDScheme { ^nil }
pathSeparator { ^$\\ }
WindowsPlatform : Platform
{
name { ^\windows }
startupFiles { ^["startup.sc", "~\\SuperCollider\\startup.sc".standardizePath] }
startup {
// Server setup
Server.program = "scsynth.exe";

// Score setup
Score.program = Server.program;

// load user startup file
this.loadStartupFiles;
}

defaultGUIScheme { ^\swing }
defaultHIDScheme { ^nil }
pathSeparator { ^$\\ }
isPathSeparator { |char|
^#[$\\, $/].includes(char)
}
clearMetadata { |path|
path = path.splitext[0].do({ |chr, i| if(chr == $/) { path[i] = $\\.asAscii } });
"del %%.*meta%".format(34.asAscii, path, 34.asAscii).systemCmd;
}
}

defaultTempDir {
// +/+ "" looks funny but ensures trailing slash
var tmp = this.userAppSupportDir +/+ "";
^if(File.exists(tmp)) { tmp }
}
}

0 comments on commit fe9d5d8

Please sign in to comment.