Skip to content

Commit 4708ece

Browse files
Anton Piontkovskiyparttimenerd
Anton Piontkovskiy
authored andcommitted
Use more consistent approach in library code
1 parent 2a37903 commit 4708ece

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/one/profiler/AsyncProfilerLoader.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static void deleteExtractionDirectory() throws IOException {
122122
/** Returns the directory used for storing the extracted libraries, binaries and JARs */
123123
public static Path getExtractionDirectory() throws IOException {
124124
if (extractionDir == null) {
125-
extractionDir = Paths.get(getApplicationsDir(), "me.bechberger.ap-loader", getVersion());
125+
extractionDir = getApplicationsDir().resolve(Paths.get("me.bechberger.ap-loader", getVersion()));
126126
if (Files.notExists(extractionDir)) {
127127
Files.createDirectories(extractionDir);
128128
}
@@ -133,16 +133,16 @@ public static Path getExtractionDirectory() throws IOException {
133133
/**
134134
* Returns directory where applications places their files. Specific to operating system
135135
*/
136-
private static String getApplicationsDir() {
136+
private static Path getApplicationsDir() {
137137
String os = System.getProperty("os.name").toLowerCase();
138-
if (os.contains("linux")) {
138+
if (os.startsWith("linux")) {
139139
String xdgDataHome = System.getenv("XDG_DATA_HOME");
140140
if (xdgDataHome != null && !xdgDataHome.isEmpty()) {
141-
return xdgDataHome;
141+
return Paths.get(xdgDataHome);
142142
}
143-
return Paths.get(System.getProperty("user.home"), ".local", "share").toString();
144-
} else if (os.contains("mac")) {
145-
return Paths.get(System.getProperty("user.home"), "Library", "Application Support").toString();
143+
return Paths.get(System.getProperty("user.home"), ".local", "share");
144+
} else if (os.startsWith("macosx") || os.startsWith("mac os x")) {
145+
return Paths.get(System.getProperty("user.home"), "Library", "Application Support");
146146
}
147147
throw new UnsupportedOperationException("Unsupported os " + os);
148148
}

0 commit comments

Comments
 (0)