Started adding support for downloading online files

This commit is contained in:
CrushedPixel
2015-05-11 16:50:34 +02:00
parent 2fe3e2091b
commit 3ad765db6c
11 changed files with 153 additions and 25 deletions

View File

@@ -0,0 +1,43 @@
package eu.crushedpixel.replaymod.registry;
import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.util.HashMap;
public class DownloadedFileHandler {
private HashMap<Integer, File> downloadedFiles = new HashMap<Integer, File>();
private File downloadFolder;
public DownloadedFileHandler() {
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
downloadFolder.mkdirs();
for(File f : downloadFolder.listFiles()) {
try {
Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath()));
if(i != null) {
downloadedFiles.put(i, f);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
public void addToIndex(int id) {
try {
File f = new File(downloadFolder, id+"."+ConnectionEventHandler.ZIP_FILE_EXTENSION);
} catch(Exception e) {
e.printStackTrace();
}
}
public File getFileForID(int id) {
return downloadedFiles.get(id);
}
}