eclipse plugin: Take in account the fact that the...

...directories already exist so they won't be created again
This commit is contained in:
Timotei Dolean 2011-04-10 11:21:40 +00:00
parent f03b43e17a
commit 896bea2269
2 changed files with 6 additions and 5 deletions

View file

@ -56,8 +56,7 @@ public class Logger {
if (WorkspaceUtils.getTemporaryFolder() == null)
throw new IOException(Messages.Logger_6);
if (new File(WorkspaceUtils.getTemporaryFolder() + "/logs/").mkdirs() == false) //$NON-NLS-1$
throw new IOException(Messages.Logger_4);
new File(WorkspaceUtils.getTemporaryFolder() + "/logs/").mkdirs(); //$NON-NLS-1$
logWriter_ = new BufferedWriter(new FileWriter(logFilePath));
log(Messages.Logger_2);

View file

@ -55,7 +55,7 @@ import org.wesnoth.product.WMLPerspective;
public class WorkspaceUtils
{
private static String temporaryFolder_ = ""; //$NON-NLS-1$
private static String temporaryFolder_ = null; //$NON-NLS-1$
/**
* Gets the selected project or or null if none selected
@ -270,15 +270,17 @@ public class WorkspaceUtils
*/
public static String getTemporaryFolder()
{
if (temporaryFolder_.isEmpty())
if (temporaryFolder_ == null || temporaryFolder_.isEmpty())
{
temporaryFolder_ = System.getProperty("java.io.tmpdir") + //$NON-NLS-1$
Path.SEPARATOR + "wesnoth_plugin" + Path.SEPARATOR; //$NON-NLS-1$
File tmpFile = new File(temporaryFolder_);
if (!tmpFile.exists() || !tmpFile.mkdirs())
if (!tmpFile.exists())
temporaryFolder_ = null;
else
tmpFile.mkdirs();
}
return temporaryFolder_;
}