Skip to content

Commit 29a44b6

Browse files
authored
Merge pull request #162 from litwak913/fix-temp-dir
Fix temp dir missing when extracting font
2 parents d5346fd + 875e69a commit 29a44b6

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

core/src/cn/harryh/arkpets/ArkChar.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ private void adjustCanvas(AnimStage stage, int framePerSample, float coverage) {
373373
camera.getWidth() + insert.left + insert.right,
374374
camera.getHeight() + insert.top + insert.bottom,
375375
2);
376-
FileHandle dir = new FileHandle(tempDirPath);
377-
dir.mkdirs();
378-
FileHandle file = dir.child("acSnapshot-" + skeleton.toString() + "-" + stage.id() + ".png");
376+
FileHandle file = new FileHandle(tempDirPath).child("acSnapshot-" + skeleton.toString() + "-" + stage.id() + ".png");
379377
pw.savePixmap(file, true);
380378
Logger.debug("Character", "Saved acSnapshot to: " + file.path());
381379
}

core/src/cn/harryh/arkpets/ArkPets.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,7 @@ private void registerDebugger() {
500500
});
501501
registerKeyTyped('P', () -> Logger.debug("Debugger", "Showing plane info\n" + plane.getDebugMsg()));
502502
registerKeyTyped('S', () -> {
503-
FileHandle dir = new FileHandle(tempDirPath);
504-
dir.mkdirs();
505-
FileHandle file = dir.child("snapshot-" + System.currentTimeMillis() + ".png");
503+
FileHandle file = new FileHandle(tempDirPath).child("snapshot-" + System.currentTimeMillis() + ".png");
506504
PixmapWrapper pw = PixmapWrapper.fromCamera(cha.camera);
507505
pw.savePixmap(file, true);
508506
pw.dispose();

core/src/cn/harryh/arkpets/Const.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static class PathConfig {
101101
public static final String urlLicense = "https://github.com/isHarryh/Ark-Pets";
102102
public static final String urlMirrorChyan = "https://mirrorchyan.com/?source=" + appName + "Gui";
103103
public static final String urlWikiPrefix = "https://prts.wiki/w/";
104-
public static final String tempDirPath = "temp/";
104+
public static final String tempDirPath = "temp/";
105105
public static final String fileModelsZipName = "ArkModels";
106106
public static final String fileModelsDataPath = "models_data.json";
107107
public static final String tempModelsUnzipDirPath = tempDirPath + "models_unzipped/";

desktop/src/cn/harryh/arkpets/DesktopLauncher.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import cn.harryh.arkpets.utils.Logger;
88
import javafx.application.Application;
99

10+
import java.io.File;
1011
import java.nio.charset.Charset;
1112
import java.util.Objects;
1213

1314
import static cn.harryh.arkpets.Const.LogConfig;
15+
import static cn.harryh.arkpets.Const.PathConfig;
1416
import static cn.harryh.arkpets.Const.appVersion;
1517

1618

@@ -60,6 +62,12 @@ protected void process(String command, String addition) {
6062
}
6163
};
6264

65+
// Init temp folder
66+
File temp = new File(PathConfig.tempDirPath);
67+
if (!(temp.exists() || temp.mkdir())) {
68+
Logger.error("System", "Failed to create the temporary directory.");
69+
}
70+
6371
// Java FX bootstrap
6472
Application.launch(ArkHomeFX.class, args);
6573
Logger.info("System", "Exited from DesktopLauncher successfully");

0 commit comments

Comments
 (0)