Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[lang] Automatic creation of temp directory in batch compiler.
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed May 7, 2017
1 parent d486178 commit b55a799
Showing 1 changed file with 18 additions and 2 deletions.
Expand Up @@ -505,7 +505,7 @@ public void setBaseURI(org.eclipse.emf.common.util.URI basePath) {

/** Change the path where the Java files are generated.
*
* @param path the path.
* @param path the path, or <code>null</code> for using the default path in {@link SARLConfig#FOLDER_SOURCE_GENERATED}..
*/
public void setOutputPath(File path) {
this.outputPath = path;
Expand Down Expand Up @@ -636,11 +636,27 @@ public void setTempDirectory(String path) {
@Pure
public File getTempDirectory() {
if (this.tempPath == null) {
return new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
this.tempPath = createTempDirectory();
}
return this.tempPath;
}

/** Create the temp directory that should be used by the compiler.
*
* @return the temp directory, never {@code null}.
*/
@SuppressWarnings("static-method")
protected File createTempDirectory() {
final File tmpPath = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
int i = 0;
File tmp = new File(tmpPath, "sarlc" + i); //$NON-NLS-1$
while (tmp.exists()) {
++i;
tmp = new File(tmpPath, "sarlc" + i); //$NON-NLS-1$
}
return tmp;
}

/** Replies if the temp folder must be deleted at the end of the compilation.
*
* @return <code>true</code> if the temp folder is deleted.
Expand Down

0 comments on commit b55a799

Please sign in to comment.