diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 4f15a3a7..a4b84447 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -140,8 +140,8 @@ public class Options { rootPath = String.format("%s/%s", home, fallback); } File dir = new File(rootPath, "opsu"); - if (!dir.isDirectory()) - dir.mkdir(); + if (!dir.isDirectory() && !dir.mkdir()) + ErrorHandler.error(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath), null, false); return dir; } else return new File("./"); @@ -357,7 +357,7 @@ public class Options { public String getValueString() { return String.format("%dms", val); } }, DISABLE_SOUNDS ("Disable All Sound Effects", "DisableSound", "May resolve Linux sound driver issues. Requires a restart.", - (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1)), + (System.getProperty("os.name").toLowerCase().contains("linux"))), KEY_LEFT ("Left Game Key", "keyOsuLeft", "Select this option to input a key.") { @Override public String getValueString() { return Keyboard.getKeyName(getGameKeyLeft()); } @@ -1094,7 +1094,10 @@ public class Options { if (beatmapDir.isDirectory()) return beatmapDir; } - beatmapDir.mkdir(); // none found, create new directory + + // none found, create new directory + if (!beatmapDir.mkdir()) + ErrorHandler.error(String.format("Failed to create beatmap directory at '%s'.", beatmapDir.getAbsolutePath()), null, false); return beatmapDir; } @@ -1108,7 +1111,8 @@ public class Options { return oszDir; oszDir = new File(DATA_DIR, "SongPacks/"); - oszDir.mkdir(); + if (!oszDir.isDirectory() && !oszDir.mkdir()) + ErrorHandler.error(String.format("Failed to create song packs directory at '%s'.", oszDir.getAbsolutePath()), null, false); return oszDir; } @@ -1122,7 +1126,8 @@ public class Options { return replayImportDir; replayImportDir = new File(DATA_DIR, "ReplayImport/"); - replayImportDir.mkdir(); + if (!replayImportDir.isDirectory() && !replayImportDir.mkdir()) + ErrorHandler.error(String.format("Failed to create replay import directory at '%s'.", replayImportDir.getAbsolutePath()), null, false); return replayImportDir; } @@ -1167,7 +1172,10 @@ public class Options { if (skinRootDir.isDirectory()) return skinRootDir; } - skinRootDir.mkdir(); // none found, create new directory + + // none found, create new directory + if (!skinRootDir.mkdir()) + ErrorHandler.error(String.format("Failed to create skins directory at '%s'.", skinRootDir.getAbsolutePath()), null, false); return skinRootDir; } diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index feb24d44..9e24be47 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -289,11 +289,9 @@ public class Utils { public static void takeScreenShot() { // create the screenshot directory File dir = Options.getScreenshotDir(); - if (!dir.isDirectory()) { - if (!dir.mkdir()) { - ErrorHandler.error("Failed to create screenshot directory.", null, false); - return; - } + if (!dir.isDirectory() && !dir.mkdir()) { + ErrorHandler.error(String.format("Failed to create screenshot directory at '%s'.", dir.getAbsolutePath()), null, false); + return; } // create file name