In light of Vista's restrictions on who can write where, and in order to provide a consistent interface across platforms (including older versions of Windows), I think it would be helpful to add two new methods to the Sys class:
The user directory is the place to store saved games, profiles and anything related to a specific user. The shared directory is the place to store hi-score tables or anything else that is shared between users. This thread
at IndieGamer made me realize that there's really no good way to do this in Java. In a thread here
, Matzon said that getting the path to "My Documents" doesn't make sense on Mac or Linux, basically implying that such functionality doesn't belong in LWJGL. But I think the functionality above does make sense across all platforms.
getSaveDir would return "C:\Users\<user>\Saved Games\" on Vista (the preferred path), and either "My Documents\My Games" or CSIDL_APPDATA ("C:\Documents and Settings\username\Application Data\") on older versions of Windows. getSharedDir would return the path for CSIDL_COMMON_APPDATA
on Win2K and later (C:\ProgramData\ on Vista, and "C:\Documents and Settings\All Users\Application Data\" on 2K/XP), and whatever is appropriate on older versions.
getSaveDir would obviously return the home directory on Linux and whatever is appropriate on Mac. getSharedDir would also return the appropriate locations. I don't use either platform so I have no idea what those are. If there is not equivalent directory then it should just return "./".
This seems like a sensible addition to me and would allow users of LWJGL to easily write data to the appropriate location regardless of platform. Otherwise, we'd have to resort to hacks, custom JNI code, or write to the wrong folders. I know it's possible to get the home directory through system properties, but that doesn't help on Windows. Nor does it help in getting the shared app directory. When you throw different languages into the mix, where the folder names are no longer in English, it's a necessity to go through the Win32 API to get to the proper locations.