eclipse plugin: Handle the cases when the temporary folder...
...or the log could not be created Issue found by "FindBugs"
This commit is contained in:
parent
613f765ab6
commit
a9b1eed73c
4 changed files with 10 additions and 3 deletions
|
@ -53,7 +53,11 @@ public class Logger {
|
|||
String logFilePath = String.format("%s/logs/log%s.txt", //$NON-NLS-1$
|
||||
WorkspaceUtils.getTemporaryFolder(), WorkspaceUtils.getRandomFileName());
|
||||
|
||||
new File(WorkspaceUtils.getTemporaryFolder() + "/logs/").mkdirs(); //$NON-NLS-1$
|
||||
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);
|
||||
|
||||
logWriter_ = new BufferedWriter(new FileWriter(logFilePath));
|
||||
log(Messages.Logger_2);
|
||||
|
|
|
@ -184,6 +184,7 @@ public class Messages extends NLS
|
|||
public static String Logger_3;
|
||||
public static String Logger_4;
|
||||
public static String Logger_5;
|
||||
public static String Logger_6;
|
||||
public static String MapUtils_0;
|
||||
public static String MapUtils_1;
|
||||
public static String MapUtils_2;
|
||||
|
|
|
@ -169,6 +169,7 @@ Logger_2=Logging started.
|
|||
Logger_3=Error codes: 1 - INFO, 2 - WARNING, 4 - ERROR
|
||||
Logger_4=There was an error trying to open the log.
|
||||
Logger_5=Logging ended.
|
||||
Logger_6=Could not create the temporary folder.
|
||||
MapUtils_0=no directory selected (importMap)
|
||||
MapUtils_1=Please select a directory before importing a map
|
||||
MapUtils_2=Import wesnoth map
|
||||
|
|
|
@ -276,8 +276,9 @@ public class WorkspaceUtils
|
|||
Path.SEPARATOR + "wesnoth_plugin" + Path.SEPARATOR; //$NON-NLS-1$
|
||||
|
||||
File tmpFile = new File(temporaryFolder_);
|
||||
if (!tmpFile.exists())
|
||||
tmpFile.mkdirs();
|
||||
|
||||
if (!tmpFile.exists() || !tmpFile.mkdirs())
|
||||
temporaryFolder_ = null;
|
||||
}
|
||||
return temporaryFolder_;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue