LWJGL
May 18, 2013, 12:22:09 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL is now using GitHub
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Proposal: two new Sys methods for user directories  (Read 5857 times)
aldacron
Regular nerd
**
Posts: 67


« on: February 02, 2007, 03:11:45 »

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:

getSaveDir()
getSharedDir()

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.



Logged
Matzon
Administrator
Demigod
*****
Posts: 2237



« Reply #1 on: February 02, 2007, 04:47:00 »

I basically agree - however, this is of course for LWJGL 1.1
Logged

numberR
Talks Too Much
***
Posts: 101


« Reply #2 on: February 02, 2007, 10:28:49 »

personally, i want Java to handle this instead of LWJGL.

let's say new version of Windows came out and now it uses different directory for saving personal stuff for some reason. Then, LWJGL needs to update to reflect that. I don't think that's LWJGL's job though.
Logged
oNyx
Talks Too Much
***
Posts: 177


弾幕


« Reply #3 on: February 02, 2007, 17:07:49 »

Ehm... System.getProperty("user.home")...
Logged

aldacron
Regular nerd
**
Posts: 67


« Reply #4 on: February 03, 2007, 03:26:10 »

Ehm... System.getProperty("user.home")...

Not the same thing at all.
Logged
mot
Regular nerd
**
Posts: 57


WWW
« Reply #5 on: February 03, 2007, 04:52:00 »

Hello.

http://lwjgl.org/forum/index.php/topic,1956.0.html
http://code.google.com/p/winfoldersjava/

Check the second link for a brief explanation of why System.getProperty("user.home") is not that good a solution.

Quote
let's say new version of Windows came out and now it uses different directory for saving personal stuff for some reason. Then, LWJGL needs to update to reflect that. I don't think that's LWJGL's job though.

SHGetSpecialFolderPath is part of the Windows API and it always returns the correct location, so no updates are necessary.
Logged

Tom Andrle - Catnap Games - http://www.catnapgames.com
erikd
Newbie
*
Posts: 21



WWW
« Reply #6 on: March 15, 2007, 08:45:49 »

I'd still rather see this implemented as a new standard system property in java (just like user.home), than in LWJGL only.
It's not really something that fits a gaming library imho.
Logged
bobjob
Prolific Timewaster
****
Posts: 335


LWJGL: WOW SO GOOD


« Reply #7 on: March 15, 2007, 09:50:57 »

I basically agree - however, this is of course for LWJGL 1.1

rapped 2 here theres gonna be another lwjgl  Grin
sry wot was the forums topic again  Wink
Logged

LWJGL Benchmark online test:
http://have2chat.net/benchmark/
http://have2chat.net/benchmark/fullpage.html (run full OpenGL webpage)
Orangy Tang
Talks Too Much
***
Posts: 199



« Reply #8 on: June 06, 2007, 09:15:29 »

Sneaky bump. Grin This functionally would be a really good addition IMHO.
Logged
Matzon
Administrator
Demigod
*****
Posts: 2237



« Reply #9 on: June 06, 2007, 10:12:40 »

forgot about this one... I'll look into it
Logged

elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #10 on: June 07, 2007, 02:25:58 »

I'm not keen on catering for a single platform (only the windows platform need native code for this seemingly simple task), however, I'm inclined to agreeing with the original poster. A few issues though:

1. I don't think getSharedDir is worthy of inclusion, since the shared folder concept is only  supported on windows, afaik.
2. getSaveDir should probably take a application id String argument, so that getSaveDir("TribalTrouble") could be transformed to ~/.TribalTrouble on linux (note the leading dot).
(3. Naming - getSaveDir() -> getLocalApplicationDirectory(String application_id)?)

 - elias
Logged

elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #11 on: June 07, 2007, 05:42:41 »

4. I'd prefer not to use the c:\Users\<user>\Saved Games dir, since games could store more than saved games in their directory and since it's a vista specific feature.

 - elias
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!