Throw an Exception when WorldSettings fail to create the required directory structure.

This commit is contained in:
AlgorithmX2
2014-08-23 17:55:55 -05:00
parent d917ae7765
commit 4b83c804cf
2 changed files with 33 additions and 15 deletions
+27 -14
View File
@@ -47,10 +47,6 @@ public class WorldSettings extends Configuration
compass = new CompassService( AEFolder ); compass = new CompassService( AEFolder );
File spawnData = new File( AEFolder, "spawndata" );
if ( !spawnData.exists() || !spawnData.isDirectory() )
spawnData.mkdir();
for (int dimID : get( "DimensionManager", "StorageCells", new int[0] ).getIntList()) for (int dimID : get( "DimensionManager", "StorageCells", new int[0] ).getIntList())
{ {
storageCellDims.add( dimID ); storageCellDims.add( dimID );
@@ -85,7 +81,7 @@ public class WorldSettings extends Configuration
fis = new FileInputStream( f ); fis = new FileInputStream( f );
NBTTagCompound data = null; NBTTagCompound data = null;
try try
{ {
data = CompressedStreamTools.readCompressed( fis ); data = CompressedStreamTools.readCompressed( fis );
@@ -95,9 +91,9 @@ public class WorldSettings extends Configuration
data = new NBTTagCompound(); data = new NBTTagCompound();
AELog.error( e ); AELog.error( e );
} }
fis.close(); fis.close();
return data; return data;
} }
catch (Throwable e) catch (Throwable e)
@@ -121,16 +117,16 @@ public class WorldSettings extends Configuration
{ {
// save // save
FileOutputStream fos = new FileOutputStream( f ); FileOutputStream fos = new FileOutputStream( f );
try try
{ {
CompressedStreamTools.writeCompressed( data, fos ); CompressedStreamTools.writeCompressed( data, fos );
} }
catch( Throwable e ) catch (Throwable e)
{ {
AELog.error( e ); AELog.error( e );
} }
fos.close(); fos.close();
} }
catch (Throwable e) catch (Throwable e)
@@ -256,12 +252,29 @@ public class WorldSettings extends Configuration
{ {
File world = DimensionManager.getCurrentSaveRootDirectory(); File world = DimensionManager.getCurrentSaveRootDirectory();
File f = new File( world.getPath() + File.separatorChar + "AE2" ); File aeBaseFolder = new File( world.getPath() + File.separatorChar + "AE2" );
if ( !f.exists() || !f.isDirectory() ) if ( !aeBaseFolder.exists() || !aeBaseFolder.isDirectory() )
f.mkdir(); if ( !aeBaseFolder.mkdir() )
{
throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
}
instance = new WorldSettings( f ); File compass = new File( aeBaseFolder, "compass" );
if ( !compass.exists() || !compass.isDirectory() )
if ( !compass.mkdir() )
{
throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() );
}
File spawnData = new File( aeBaseFolder, "spawndata" );
if ( !spawnData.exists() || !spawnData.isDirectory() )
if ( !spawnData.mkdir() )
{
throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() );
}
instance = new WorldSettings( aeBaseFolder );
} }
return instance; return instance;
+6 -1
View File
@@ -5,6 +5,8 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import appeng.core.AELog;
public class CompassRegion public class CompassRegion
{ {
@@ -159,7 +161,10 @@ public class CompassRegion
File folderFile = new File( folder ); File folderFile = new File( folder );
if ( !folderFile.exists() || !folderFile.isDirectory() ) if ( !folderFile.exists() || !folderFile.isDirectory() )
folderFile.mkdir(); {
if ( !folderFile.mkdir() )
AELog.info( "Failed to created AE2/compass/" );
}
return new File( folder + File.separatorChar + world + "_" + low_x + "_" + low_z + ".dat" ); return new File( folder + File.separatorChar + world + "_" + low_x + "_" + low_z + ".dat" );
} }