![]() |
|
[Java] Java Multi Platform Save Directory - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Java Multi Platform Save Directory (/showthread.php?tid=4879295) |
Java Multi Platform Save Directory - +Haze - Jun 24, 2015 Okay so I'm currently creating a game and I've having a problem with the save feature. Currently I use WindowsOS and the Windows side of the code works a treat, but since I don't have other OS systems like mac or linux I don't know if this code would work on all platforms (the major ones) Here the code. Spoiler (Click to View) So, what do people suggest or what is the right way for obtaining like an AppData folder for other platforms like Mac and Linux? I would also appreciate replies from Mac & Linux users too Thanks * - JavaProfit - Jun 24, 2015 For mac use ~/Library/Application Support ... Not sure what people usually use for most distros of Linux, but somewhere in the home folder works. ninja: I don't think you can use backslashes for anything other than dos. File.separator or just "/" works. * - +Haze - Jun 24, 2015 So, for a mac and linux user. Will Code fullDirectory = Paths.get(System.getProperty("user.home") + "\\Library\\Application Support\\NoughtPlusPlus");Work? Also, seems you're right about the backslash thing, thanks :D * - JershDervis - Jun 25, 2015 I know the Minecraft Launcher uses the following method: Code public static final String APPLICATION_NAME = "minecraft";* - JavaProfit - Jun 25, 2015 (Jun 25, 2015 07:42 PM)JershDervis Wrote: I know the Minecraft Launcher uses the following method: That's decompiled from the launcher, right? I'm just assuming that because enum switches use ordinal() after being compiled and no one writes enum switches with ordinal * - DragonBook - Jun 26, 2015 If you truly want it to be multi-platform, save yourself the trouble and 1) allow the user to choose their own directory and 2) store all save profiles and settings files in a sub-directory. Don't worry about how Mojang does it. You can always make it more sophisticated later. * - +Haze - Jun 26, 2015 (Jun 26, 2015 04:51 AM)__isoc99_scanf Wrote: If you truly want it to be multi-platform, save yourself the trouble and 1) allow the user to choose their own directory and 2) store all save profiles and settings files in a sub-directory. Don't worry about how Mojang does it. You can always make it more sophisticated later. What sub directory should I save it to? |