Skip to content

Commit

Permalink
changed how the home folder is located on Windows
Browse files Browse the repository at this point in the history
per issue #5
  • Loading branch information
oxguy3 committed Jun 15, 2014
1 parent dcf53bb commit e79d456
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.oxguy3</groupId>
<artifactId>craftboot</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<name>CraftBoot</name>
<description>An open bootstrapper for a Minecraft modpack launcher, built on SKCraft Launcher</description>
<build>
Expand Down
2 changes: 1 addition & 1 deletion src/io/github/oxguy3/craftboot/Craftboot.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static void prepareUserUrl() {
* Directory should be <user home folder>/<LAUNCHER_SUBDIR>/<name of craftboot jar file>
*/
public static File makeDataDir() {
File homeDir = new File(System.getProperty("user.home"));
File homeDir = new File(CraftbootUtils.getUserHome());
File craftbootDir = new File(homeDir, LAUNCHER_SUBDIR);
String launcherFilename = new File(Craftboot.class.getProtectionDomain().getCodeSource().getLocation().getFile()).getName();
File instanceDir = new File(craftbootDir, launcherFilename);
Expand Down
18 changes: 18 additions & 0 deletions src/io/github/oxguy3/craftboot/CraftbootUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,22 @@ public static boolean downloadToFile(String url, File file) {
}
return true;
}

/**
* Gets the user's home directory in their OS
*
* Usually this will be equivalent to the system property user.home, but
* because Windows is such a special snowflake, it will return the
* USERPROFILE environment variable on Windows systems.
*/
public static String getUserHome() {

boolean isWindows = System.getProperty("os.name").startsWith("Windows");

if (isWindows) {
return System.getenv("USERPROFILE");
} else {
return System.getProperty("user.home");
}
}
}

0 comments on commit e79d456

Please sign in to comment.