Made the directory build happen at write instead of read

This commit is contained in:
jsrobson10 2019-07-07 19:50:51 +10:00
parent 087b75fffe
commit 09ecdb27e4
1 changed files with 15 additions and 5 deletions

View File

@ -14,14 +14,18 @@ public class BdfFileManager extends BdfObject
private static BdfDatabase init(String path)
{
// Get the file handler
// Get the file
File file = new File(path);
// Create the parent directories
file.getParentFile().mkdirs();
// Does the file have read access
if(file.canRead())
{
// Return the files contents as a database
return new BdfDatabase(FileHelpers.readAllIgnoreErrors(path));
}
// Return the files contents as a database
return new BdfDatabase(FileHelpers.readAllIgnoreErrors(path));
// Return an empty database if there is no read access
return new BdfDatabase();
}
public BdfFileManager(String path) {
@ -33,6 +37,12 @@ public class BdfFileManager extends BdfObject
{
try
{
// Get the file handler
File file = new File(path);
// Create the parent directories
file.getParentFile().mkdirs();
// Get the database file for output
FileOutputStream out = new FileOutputStream(path);