mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-22 08:41:02 +00:00
fix file dumping
This commit is contained in:
@@ -108,8 +108,10 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
logger.info("Initializing Terra...");
|
logger.info("Initializing Terra...");
|
||||||
|
|
||||||
try(InputStream stream = getClass().getResourceAsStream("/config.yml")) {
|
try(InputStream stream = getClass().getResourceAsStream("/config.yml")) {
|
||||||
|
logger.info("Loading config.yml");
|
||||||
File configFile = new File(getDataFolder(), "config.yml");
|
File configFile = new File(getDataFolder(), "config.yml");
|
||||||
if(!configFile.exists()) {
|
if(!configFile.exists()) {
|
||||||
|
logger.info("Writing new config.yml...");
|
||||||
FileUtils.copyInputStreamToFile(stream, configFile);
|
FileUtils.copyInputStreamToFile(stream, configFile);
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
@@ -247,8 +249,7 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
if(resource.exists())
|
if(resource.exists())
|
||||||
return; // dont overwrite
|
return; // dont overwrite
|
||||||
|
|
||||||
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath);
|
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath)) {
|
||||||
OutputStream os = new FileOutputStream(resource)) {
|
|
||||||
if(is == null) {
|
if(is == null) {
|
||||||
logger.error("Resource {} doesn't exist on the classpath!", resourcePath);
|
logger.error("Resource {} doesn't exist on the classpath!", resourcePath);
|
||||||
return;
|
return;
|
||||||
@@ -283,8 +284,9 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
logger.info("Dumping resource {}...", resource.getAbsolutePath());
|
logger.info("Dumping resource {}...", resource.getAbsolutePath());
|
||||||
resource.getParentFile().mkdirs();
|
resource.getParentFile().mkdirs();
|
||||||
resource.createNewFile();
|
resource.createNewFile();
|
||||||
|
try(OutputStream os = new FileOutputStream(resource)) {
|
||||||
IOUtils.copy(is, os);
|
IOUtils.copy(is, os);
|
||||||
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user