Load download Folder from ReplayFileIO in DownloadedFileHandler

DRY code in ReplayFileIO to retreive and create directories from config
This commit is contained in:
CrushedPixel
2015-07-16 14:01:46 +02:00
parent ddc9ff9bcc
commit d1ffa877b0
2 changed files with 11 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
import eu.crushedpixel.replaymod.utils.ReplayFile;
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
@@ -18,9 +19,8 @@ public class DownloadedFileHandler {
private File downloadFolder;
public DownloadedFileHandler() {
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
try {
FileUtils.forceMkdir(downloadFolder);
downloadFolder = ReplayFileIO.getReplayDownloadFolder();
for(File f : FileUtils.listFiles(downloadFolder, new String[]{"mcpr"}, false)) {
try {

View File

@@ -29,13 +29,18 @@ public class ReplayFileIO {
private static final byte[] uniqueBytes = new byte[]{0, 1, 1, 2, 3, 5, 8};
public static File getRenderFolder() throws IOException {
File folder = new File(ReplayMod.replaySettings.getRenderPath());
FileUtils.forceMkdir(folder);
return folder;
return makeFolderFromPath(ReplayMod.replaySettings.getRenderPath());
}
public static File getReplayFolder() throws IOException {
String path = ReplayMod.replaySettings.getRecordingPath();
return makeFolderFromPath(ReplayMod.replaySettings.getRecordingPath());
}
public static File getReplayDownloadFolder() throws IOException {
return makeFolderFromPath(ReplayMod.replaySettings.getDownloadPath());
}
private static File makeFolderFromPath(String path) throws IOException {
File folder = new File(path);
FileUtils.forceMkdir(folder);
return folder;