@@ -43,6 +43,8 @@ public class BaseNoGui {
4343 /** Set true if this a proper release rather than a numbered revision. */
4444 static public boolean RELEASE = false ;
4545
46+ static File buildFolder ;
47+
4648 // Current directory to use for relative paths specified on the
4749 // commandline
4850 static String currentDirectory = System .getProperty ("user.dir" );
@@ -97,6 +99,28 @@ static public int countLines(String what) {
9799 return count ;
98100 }
99101
102+ /**
103+ * Get the path to the platform's temporary folder, by creating
104+ * a temporary temporary file and getting its parent folder.
105+ * <br/>
106+ * Modified for revision 0094 to actually make the folder randomized
107+ * to avoid conflicts in multi-user environments. (Bug 177)
108+ */
109+ static public File createTempFolder (String name ) {
110+ try {
111+ File folder = File .createTempFile (name , null );
112+ //String tempPath = ignored.getParent();
113+ //return new File(tempPath);
114+ folder .delete ();
115+ folder .mkdirs ();
116+ return folder ;
117+
118+ } catch (Exception e ) {
119+ e .printStackTrace ();
120+ }
121+ return null ;
122+ }
123+
100124 static public String getAvrBasePath () {
101125 String path = getHardwarePath () + File .separator + "tools" +
102126 File .separator + "avr" + File .separator + "bin" + File .separator ;
@@ -106,6 +130,23 @@ static public String getAvrBasePath() {
106130 return path ;
107131 }
108132
133+ static public File getBuildFolder () {
134+ if (buildFolder == null ) {
135+ String buildPath = Preferences .get ("build.path" );
136+ if (buildPath != null ) {
137+ buildFolder = absoluteFile (buildPath );
138+ if (!buildFolder .exists ())
139+ buildFolder .mkdirs ();
140+ } else {
141+ //File folder = new File(getTempFolder(), "build");
142+ //if (!folder.exists()) folder.mkdirs();
143+ buildFolder = createTempFolder ("build" );
144+ buildFolder .deleteOnExit ();
145+ }
146+ }
147+ return buildFolder ;
148+ }
149+
109150 static public PreferencesMap getBoardPreferences () {
110151 TargetBoard board = getTargetBoard ();
111152
0 commit comments