GP-0: Creating BundleHost cache directory in a more reliable fashion

This commit is contained in:
Ryan Kurtz
2023-03-20 12:48:41 -04:00
parent d76f59ee69
commit c377b245da

View File

@@ -15,9 +15,7 @@
*/ */
package ghidra.app.plugin.core.osgi; package ghidra.app.plugin.core.osgi;
import java.io.IOException; import java.io.*;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -42,6 +40,7 @@ import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.task.TaskLauncher; import ghidra.util.task.TaskLauncher;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
import utilities.util.FileUtilities;
/** /**
* Hosts the embedded OSGi framework and manages {@link GhidraBundle}s. * Hosts the embedded OSGi framework and manages {@link GhidraBundle}s.
@@ -373,9 +372,11 @@ public class BundleHost {
} }
private static String makeCacheDir() throws IOException { private static String makeCacheDir() throws IOException {
Path cacheDir = getCacheDir(); File cacheDir = getCacheDir().toFile();
Files.createDirectories(cacheDir); if (!FileUtilities.mkdirs(cacheDir)) {
return cacheDir.toAbsolutePath().toString(); throw new IOException("Failed to make cache directory: " + cacheDir);
}
return cacheDir.getAbsolutePath();
} }
private void createAndConfigureFramework() throws IOException { private void createAndConfigureFramework() throws IOException {