Improved data file zipping
This commit is contained in:
@@ -453,11 +453,24 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||||||
files.addAll(schematicDirectory.list());
|
files.addAll(schematicDirectory.list());
|
||||||
String base = Core.settings.getDataDirectory().path();
|
String base = Core.settings.getDataDirectory().path();
|
||||||
|
|
||||||
|
//add directories
|
||||||
|
for(Fi other : files.copy()){
|
||||||
|
Fi parent = other.parent();
|
||||||
|
while(!files.contains(parent) && !parent.equals(settings.getDataDirectory())){
|
||||||
|
files.add(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try(OutputStream fos = file.write(false, 2048); ZipOutputStream zos = new ZipOutputStream(fos)){
|
try(OutputStream fos = file.write(false, 2048); ZipOutputStream zos = new ZipOutputStream(fos)){
|
||||||
for(Fi add : files){
|
for(Fi add : files){
|
||||||
if(add.isDirectory()) continue;
|
String path = add.path().substring(base.length());
|
||||||
zos.putNextEntry(new ZipEntry(add.path().substring(base.length())));
|
if(add.isDirectory()) path += "/";
|
||||||
|
//fix trailing / in path
|
||||||
|
path = path.startsWith("/") ? path.substring(1) : path;
|
||||||
|
zos.putNextEntry(new ZipEntry(path));
|
||||||
|
if(!add.isDirectory()){
|
||||||
Streams.copy(add.read(), zos);
|
Streams.copy(add.read(), zos);
|
||||||
|
}
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=2f044212b72385c64f4f1a1e488e8c5ee62c5740
|
archash=733430e6bc8bf4d997f43e30a7009b9b84d3e0f0
|
||||||
|
|||||||
Reference in New Issue
Block a user