GNOME Bugzilla – Bug 105887
g_get_home_dir() in win98 returns null.
Last modified: 2011-02-04 16:16:24 UTC
g_get_home_dir() returns NULL in win98, while it should return something like 'c:\my documents'. I checked the source and noticed that it checks for some env. variables, which may work in win2k but are unavailable in win98. So, I think it should check for the following registry values: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\, value 'Personal' or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\, value 'Personal'. Maybe SHGetSpecialFolderPath (..., CSIDL_PERSONAL, ...) will work too.
Seems reasonable, will implement the Registry lookup. On Win2k, at least, there is also the "AppData" key that sounds like an even more appropriate place for application settings, but not perhaps as an equivalent of the Unix "home directory" concept. Hmm, in fact I think it's the parent folder of the "My Documents" folder that is the equivalent of "home directory", at least on Win2k. Whether some application then wants to use the "My Documents" or "Application Data" (or even "Local Settings\Application Data") subfolder depends on what it is using the home directory for. But as there is only one g_get_home_dir() function, and not separate g_get_user_home_documents_dir() and g_get_user_home_settings_dir() ones, probably the "My Documents" is a good compromise.
I will attach a file showing how to use SHGetSpecialFolderLocation from C to get this folder. This method is recommended by MS over using the registry. I have tested my code on NT4 and XP, but not 9x. Note that the simpler function SHGetSpecialFolderPath doesn't work on NT4. Also, I think that it might be a good idea to check for the HOME environment variable first, so that it can be used to override the other setting.
Created attachment 15108 [details] how to use SHGetSpecialFolderLocation to get "My Documents" directory
If you read the code, it *does* check HOME first on Windows... Thanks for the sample code!
Move remaining bugs off 2.2.2 target milestone.
Move remaining bugs off the 2.2.3 milestone
I am still not convinced that using CSIDL_PERSONAL as an equivalent to the Unix HOME is the right thing to do. What about CSIDL_PROFILE? (Or perhaps CSIDL_APPDATA or CSIDL_LOCAL_APPDATA?) Or is it so that any of these is better than the current approach, using environment variables? But don't all modern Windowses always set the USERPROFILE environment variable to the same as CSIDL_PROFILE would return anyway?
Mass changing gtk+ bugs with target milestone of 2.4.2 to target 2.4.4, as Matthias said he was trying to do himself on IRC and was asking for help with. If you see this message, it means I was successful at fixing the borken-ness in bugzilla :) Sorry for the spam; just query on this message and delete all emails you get with this message, since there will probably be a lot.
Fixed a while ago in HEAD: 2004-08-25 Tor Lillqvist <tml@iki.fi> (g_get_any_init): Use CSIDL_PROFILE as HOME if not overridden by env vars.