diff --git a/src/main/java/tabby/common/utils/FileUtils.java b/src/main/java/tabby/common/utils/FileUtils.java index 944afce..2002bc4 100644 --- a/src/main/java/tabby/common/utils/FileUtils.java +++ b/src/main/java/tabby/common/utils/FileUtils.java @@ -228,7 +228,7 @@ public static void putRawContent(String path, Collection data){ */ public static Path registerTempDirectory(String directory) throws IOException { - final Path tmpDir = Files.createTempDirectory("tabby_"+directory); + final Path tmpDir = createTempDirectory("tabby_"+directory); // Delete the temp directory at shutdown Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { @@ -241,6 +241,14 @@ public static Path registerTempDirectory(String directory) throws IOException { return tmpDir; } + public static Path createTempDirectory(String directory){ + String filepath = String.join(File.separator, GlobalConfiguration.TEMP_PATH, directory + UUID.randomUUID()); + if(!fileExists(filepath)){ + createDirectory(filepath); + } + return Paths.get(filepath); + } + /** * Recursively delete the directory root and all its contents * @param root Root directory to be deleted diff --git a/src/main/java/tabby/config/GlobalConfiguration.java b/src/main/java/tabby/config/GlobalConfiguration.java index 5765086..b376b6c 100644 --- a/src/main/java/tabby/config/GlobalConfiguration.java +++ b/src/main/java/tabby/config/GlobalConfiguration.java @@ -27,6 +27,7 @@ public class GlobalConfiguration { public static String CONFIG_FILE_PATH = String.join(File.separator, System.getProperty("user.dir"), "config", "settings.properties"); public static String LIBS_PATH = String.join(File.separator, System.getProperty("user.dir"), "libs"); public static String JRE_LIBS_PATH = String.join(File.separator, System.getProperty("user.dir"), "jre_libs"); + public static String TEMP_PATH = String.join(File.separator, System.getProperty("user.dir"), "temp"); public static String RULES_PATH; public static String SINK_RULE_PATH; public static String SYSTEM_RULE_PATH;