diff --git a/pom.xml b/pom.xml index 25fc290..f788893 100644 --- a/pom.xml +++ b/pom.xml @@ -233,13 +233,6 @@ - - - dev.dirs - directories - 26 - - ossrh diff --git a/pom_all.xml b/pom_all.xml index 808df80..05fc333 100644 --- a/pom_all.xml +++ b/pom_all.xml @@ -222,13 +222,6 @@ - - - dev.dirs - directories - 26 - - ossrh diff --git a/src/main/java/one/profiler/AsyncProfilerLoader.java b/src/main/java/one/profiler/AsyncProfilerLoader.java index 4f8ca25..1ad59ec 100644 --- a/src/main/java/one/profiler/AsyncProfilerLoader.java +++ b/src/main/java/one/profiler/AsyncProfilerLoader.java @@ -17,8 +17,6 @@ package one.profiler; -import dev.dirs.ProjectDirectories; - import java.io.*; import java.lang.instrument.Instrumentation; import java.lang.management.ManagementFactory; @@ -124,9 +122,7 @@ public static void deleteExtractionDirectory() throws IOException { /** Returns the directory used for storing the extracted libraries, binaries and JARs */ public static Path getExtractionDirectory() throws IOException { if (extractionDir == null) { - extractionDir = - Paths.get( - ProjectDirectories.from("me", "bechberger", "ap-loader-" + getVersion()).dataDir); + extractionDir = getApplicationsDir().resolve(Paths.get("me.bechberger.ap-loader", getVersion())); if (Files.notExists(extractionDir)) { Files.createDirectories(extractionDir); } @@ -134,6 +130,23 @@ public static Path getExtractionDirectory() throws IOException { return extractionDir; } + /** + * Returns directory where applications places their files. Specific to operating system + */ + private static Path getApplicationsDir() { + String os = System.getProperty("os.name").toLowerCase(); + if (os.startsWith("linux")) { + String xdgDataHome = System.getenv("XDG_DATA_HOME"); + if (xdgDataHome != null && !xdgDataHome.isEmpty()) { + return Paths.get(xdgDataHome); + } + return Paths.get(System.getProperty("user.home"), ".local", "share"); + } else if (os.startsWith("macosx") || os.startsWith("mac os x")) { + return Paths.get(System.getProperty("user.home"), "Library", "Application Support"); + } + throw new UnsupportedOperationException("Unsupported os " + os); + } + /** * @throws IllegalStateException if OS or Arch not supported */