Load download Folder from ReplayFileIO in DownloadedFileHandler
DRY code in ReplayFileIO to retreive and create directories from config
This commit is contained in:
@@ -4,6 +4,7 @@ import eu.crushedpixel.replaymod.ReplayMod;
|
|||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
||||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||||
|
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
@@ -18,9 +19,8 @@ public class DownloadedFileHandler {
|
|||||||
private File downloadFolder;
|
private File downloadFolder;
|
||||||
|
|
||||||
public DownloadedFileHandler() {
|
public DownloadedFileHandler() {
|
||||||
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
|
|
||||||
try {
|
try {
|
||||||
FileUtils.forceMkdir(downloadFolder);
|
downloadFolder = ReplayFileIO.getReplayDownloadFolder();
|
||||||
|
|
||||||
for(File f : FileUtils.listFiles(downloadFolder, new String[]{"mcpr"}, false)) {
|
for(File f : FileUtils.listFiles(downloadFolder, new String[]{"mcpr"}, false)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -29,13 +29,18 @@ public class ReplayFileIO {
|
|||||||
private static final byte[] uniqueBytes = new byte[]{0, 1, 1, 2, 3, 5, 8};
|
private static final byte[] uniqueBytes = new byte[]{0, 1, 1, 2, 3, 5, 8};
|
||||||
|
|
||||||
public static File getRenderFolder() throws IOException {
|
public static File getRenderFolder() throws IOException {
|
||||||
File folder = new File(ReplayMod.replaySettings.getRenderPath());
|
return makeFolderFromPath(ReplayMod.replaySettings.getRenderPath());
|
||||||
FileUtils.forceMkdir(folder);
|
|
||||||
return folder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getReplayFolder() throws IOException {
|
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);
|
File folder = new File(path);
|
||||||
FileUtils.forceMkdir(folder);
|
FileUtils.forceMkdir(folder);
|
||||||
return folder;
|
return folder;
|
||||||
|
|||||||
Reference in New Issue
Block a user