|
@@ -10,6 +10,7 @@ import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Files;
|
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -114,9 +115,10 @@ public class LoadController {
|
|
File src = new File(path);
|
|
File src = new File(path);
|
|
File folder = readArchive(path, src);
|
|
File folder = readArchive(path, src);
|
|
folder.deleteOnExit();
|
|
folder.deleteOnExit();
|
|
- for (File file : Arrays.asList(folder.listFiles())) {
|
|
|
|
- System.out.println(file.getName());
|
|
|
|
- }
|
|
|
|
|
|
+ String trim = folder.getPath().substring(0,
|
|
|
|
+ folder.getPath().lastIndexOf(folder.getName()) + folder.getName().length());
|
|
|
|
+
|
|
|
|
+ forwardFiles(folder, trim);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -135,29 +137,28 @@ public class LoadController {
|
|
forwardEdges(edges, json, objDispatch);
|
|
forwardEdges(edges, json, objDispatch);
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- private File readArchive(String path, File src) throws IOException, ArchiveException {
|
|
|
|
- File tmp = Files.createTempDirectory("tmpHolon").toFile();
|
|
|
|
- tmp.deleteOnExit();
|
|
|
|
- InputStream input = new FileInputStream(src);
|
|
|
|
- ArchiveInputStream stream = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP,
|
|
|
|
- input);
|
|
|
|
-
|
|
|
|
- ArchiveEntry entry = stream.getNextEntry();
|
|
|
|
- while (entry != null) {
|
|
|
|
- File file = new File(tmp, entry.getName());
|
|
|
|
- file.getParentFile().mkdirs();
|
|
|
|
- OutputStream output = new FileOutputStream(file);
|
|
|
|
- IOUtils.copy(stream, output);
|
|
|
|
- output.close();
|
|
|
|
- // file.createNewFile();
|
|
|
|
- entry = stream.getNextEntry();
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Loads the Files from the Savefile
|
|
|
|
+ * @param folder
|
|
|
|
+ * @param trim
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ private void forwardFiles(File folder, String trim) throws IOException {
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
+ for (File file : folder.listFiles()) {
|
|
|
|
+ File dst = new File(System.getProperty("user.home") + "/HolonGUI/" + file.getPath().replace(trim, ""));
|
|
|
|
+
|
|
|
|
+ if (file.getName().contains(".json"))
|
|
|
|
+ readJson(file.getPath());
|
|
|
|
+ else if (file.isDirectory())
|
|
|
|
+ forwardFiles(file, trim);
|
|
|
|
+ else {
|
|
|
|
+ dst.getParentFile().mkdirs();
|
|
|
|
+ Files.copy(file.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
- stream.close();
|
|
|
|
- input.close();
|
|
|
|
-
|
|
|
|
- return tmp;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -448,6 +449,30 @@ public class LoadController {
|
|
this.parser = new JsonParser();
|
|
this.parser = new JsonParser();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private File readArchive(String path, File src) throws IOException, ArchiveException {
|
|
|
|
+ File tmp = Files.createTempDirectory("tmpHolon").toFile();
|
|
|
|
+ tmp.deleteOnExit();
|
|
|
|
+ InputStream input = new FileInputStream(src);
|
|
|
|
+ ArchiveInputStream stream = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP,
|
|
|
|
+ input);
|
|
|
|
+
|
|
|
|
+ ArchiveEntry entry = stream.getNextEntry();
|
|
|
|
+ while (entry != null) {
|
|
|
|
+ File file = new File(tmp, entry.getName());
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
|
+ OutputStream output = new FileOutputStream(file);
|
|
|
|
+ IOUtils.copy(stream, output);
|
|
|
|
+ output.close();
|
|
|
|
+ // file.createNewFile();
|
|
|
|
+ entry = stream.getNextEntry();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ stream.close();
|
|
|
|
+ input.close();
|
|
|
|
+
|
|
|
|
+ return tmp;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Init new Arrays which havent been serialized along the object
|
|
* Init new Arrays which havent been serialized along the object
|
|
*
|
|
*
|