Interpret a file name without extension as a directory, if not existent.

This commit is contained in:
asofold 2014-12-04 15:04:11 +01:00
parent 5f9764dabc
commit a41b7a6329

View File

@ -70,9 +70,13 @@ public class FileLogger {
logger = Logger.getAnonymousLogger(); logger = Logger.getAnonymousLogger();
detachLogger(); detachLogger();
final File container; final File container;
if (!file.exists() && file.getName().indexOf('.') == -1) {
// Make it a directory, if no extension is given.
file.mkdirs();
}
if (file.isDirectory()) { if (file.isDirectory()) {
container = file; container = file;
// Find a file name. // File-name by date within the given folder.
SimpleDateFormat dateFormat = new SimpleDateFormat("yy-MM-dd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yy-MM-dd");
String prefix = dateFormat.format(System.currentTimeMillis()); String prefix = dateFormat.format(System.currentTimeMillis());
int n = 1; int n = 1;
@ -84,6 +88,7 @@ public class FileLogger {
n ++; n ++;
} }
} else { } else {
// Directly use the given file.
container = file.getParentFile(); container = file.getParentFile();
} }
// Ensure the container exists. // Ensure the container exists.