Add default user data folder for mac

This commit is contained in:
Louis Royer 2020-01-15 21:58:11 +01:00
parent b4927e1994
commit bb1df85273
2 changed files with 11 additions and 2 deletions

View File

@ -23,7 +23,11 @@ public class ClientP2P {
d += ".";
}
}
} else {
} else if (os.equals("Mac")||os.equals("Mac OS X") {
/* Apple MacOS X User Data Directory
* https://developer.apple.com/library/archive/qa/qa1170/_index.html */
d = System.getProperty("user.home") + "/Library/";
} else {
d = ".";
}
d += "/P2P_JAVA_PROJECT_CLIENT/";

View File

@ -11,7 +11,8 @@ public class ServerP2P {
/* Follow XDG Base Directory Specification
* https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
*/
if (System.getProperty("os.name").equals("Linux")) {
String os = System.getProperty("os.name");
if (os.equals("Linux")) {
d = System.getenv().get("XDG_DATA_HOME");
if (d == null || d.equals("")) {
d = System.getenv().get("HOME");
@ -21,6 +22,10 @@ public class ServerP2P {
d += ".";
}
}
} else if (os.equals("Mac")||os.equals("Mac OS X") {
/* Apple MacOS X User Data Directory
* https://developer.apple.com/library/archive/qa/qa1170/_index.html */
d = System.getProperty("user.home") + "/Library/";
} else {
d = ".";
}