fix find HMCL directory (#1953)

This commit is contained in:
Glavo
2022-12-30 17:00:10 +08:00
committed by GitHub
parent ba196dcdf4
commit bed74dc66c
6 changed files with 50 additions and 57 deletions

View File

@@ -17,8 +17,6 @@
*/
package org.jackhuang.hmcl.util.platform;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -276,18 +274,14 @@ public enum OperatingSystem {
String home = System.getProperty("user.home", ".");
switch (OperatingSystem.CURRENT_OS) {
case LINUX:
String xdgData = System.getenv("XDG_DATA_HOME");
if (StringUtils.isNotBlank(xdgData)) {
return Paths.get(xdgData, folder);
}
return Paths.get(home, ".local", "share", folder);
return Paths.get(home, "." + folder).toAbsolutePath();
case WINDOWS:
String appdata = System.getenv("APPDATA");
return Paths.get(appdata == null ? home : appdata, "." + folder);
return Paths.get(appdata == null ? home : appdata, "." + folder).toAbsolutePath();
case OSX:
return Paths.get(home, "Library", "Application Support", folder);
return Paths.get(home, "Library", "Application Support", folder).toAbsolutePath();
default:
return Paths.get(home, folder);
return Paths.get(home, folder).toAbsolutePath();
}
}