This commit is contained in:
Anthony Calosa
2024-06-09 18:43:14 +08:00
parent 27ff643acc
commit 66f5704a8b
2 changed files with 6 additions and 10 deletions

View File

@@ -156,9 +156,9 @@ public class StartScene extends UIScene {
try {
File source = new FileHandle(ForgeProfileProperties.getUserDir() + "/adventure/Shandalar").file();
File target = new FileHandle(Forge.getDeviceAdapter().getDownloadsDir()).file();
ZipUtil.zip(source, target);
ZipUtil.zip(source, target, ZipUtil.backupAdvFile);
zipDialog = createGenericDialog("",
Forge.getLocalizer().getMessage("lblSaveLocation") + "\n" + target.getAbsolutePath() + File.separator + ZipUtil.backupFile,
Forge.getLocalizer().getMessage("lblSaveLocation") + "\n" + target.getAbsolutePath() + File.separator + ZipUtil.backupAdvFile,
Forge.getLocalizer().getMessage("lblOK"), null, this::removeDialog, null);
} catch (IOException e) {
zipDialog = createGenericDialog("",
@@ -170,7 +170,7 @@ public class StartScene extends UIScene {
return true;
}
public boolean restoreBackup() {
File source = new FileHandle(Forge.getDeviceAdapter().getDownloadsDir() + ZipUtil.backupFile).file();
File source = new FileHandle(Forge.getDeviceAdapter().getDownloadsDir() + ZipUtil.backupAdvFile).file();
File target = new FileHandle(ForgeProfileProperties.getUserDir() + "/adventure/Shandalar").file().getParentFile();
if (unzipDialog == null) {
unzipDialog = createGenericDialog("",

View File

@@ -1,7 +1,6 @@
package forge.util;
import java.io.*;
//import java.time.Instant;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -10,13 +9,10 @@ import java.util.zip.ZipOutputStream;
* https://www.baeldung.com/java-compress-and-uncompress
*/
public class ZipUtil {
public static String backupFile = "forge.adv";
public static void zip(File source, File dest) throws IOException {
//String now = Instant.now().toString() + "-";
FileOutputStream fos = new FileOutputStream(dest.getAbsolutePath() + File.separator /*+ now*/ + backupFile);
public static String backupAdvFile = "forge.adv";
public static void zip(File source, File dest, String name) throws IOException {
FileOutputStream fos = new FileOutputStream(dest.getAbsolutePath() + File.separator + name);
ZipOutputStream zipOut = new ZipOutputStream(fos);
//File fileToZip = new File(sourceFile);
zipFile(source, source.getName(), zipOut);
zipOut.close();
fos.close();