After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620710 - g_get_user_data_dir() uses CSIDL_PERSONAL and not CSIDL_APPDATA
g_get_user_data_dir() uses CSIDL_PERSONAL and not CSIDL_APPDATA
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
2.25.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
: 592566 634487 (view as bug list)
Depends on:
Blocks: 592566
 
 
Reported: 2010-06-06 04:09 UTC by Javier Jardón (IRC: jjardon)
Modified: 2011-11-30 06:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use CSIDL_APPDATA instead CSIDL_PERSONAL in g_get_user_data_dir() (1.40 KB, patch)
2010-06-08 13:58 UTC, Javier Jardón (IRC: jjardon)
none Details | Review

Description Javier Jardón (IRC: jjardon) 2010-06-06 04:09:37 UTC
From the msdn documentation CSIDL_PERSONAL:

"virtual folder that represents the My Documents desktop item"

I think that CSIDL_APPDATA should be used instead:

"directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data"
Comment 1 Tor Lillqvist 2010-06-08 12:00:01 UTC
You are probably right.
Comment 2 Javier Jardón (IRC: jjardon) 2010-06-08 13:58:25 UTC
Created attachment 163060 [details] [review]
Use CSIDL_APPDATA instead CSIDL_PERSONAL in g_get_user_data_dir()
Comment 3 Tor Lillqvist 2010-10-14 07:43:41 UTC
I think I retract my comment #1.

Is the main point in this bug that the documentation talks about "virtual" folder, making it sound scary? No need to be scared of that, on both XP and Windows 7 the return value from g_get_user_data_dir() is a fully valid pathname to a directory that can be used quite normally in code.

I understand that in bug #592566, which discusses a case where an application-specific (or actually, library-specific) *directory* is created, the end-user expectation would be for that to be created under CSIDL_APPDATA. But what about an application that wants to create a freestanding *document*? Shouldn't that by default be created in CSIDL_PERSONAL? That's what Windows applications designed for Windows do.

With "document" here I mean something that in the filesystem is an isolated file, and which appears fully visible in the desktop environment / file browser / etc as a "document" that can typically be double-clicked to start the associated application editing or viewing it.

An application-specific directory, on the other hand, should ideally be hidden from casual inspection by the user.

The XDG specification is so extremely loosely written that it is hard to say what XDG_DATA_DIRS means.

Also as far as I can see, the directory .gegl-0.0 (the example in bug #592566) falls clearly into the second category, something that should be hidden from casual browsing by the user. (Of course, it's name starting with a period, also indicated that in traditional POSIX shells.)

So is the real problem here that XDG, and thus GLib, doesn't differentiate between the use cases of a folder for a user's documents, and a folder for a user's application-specific data that the user is not supposed to be able to open?
Comment 4 Tor Lillqvist 2010-10-14 07:51:52 UTC
On the other hand, I do see that the documentation for g_get_user_data_dir() specifically talks about "application data" and mentions as examples icons customized for the user. So from that it indeed sounds as if it means a place for files not intended to be casually browsable and editable by the user, and CSIDL_APPDATA would be the more correct place.

(On the other hand, how is that then different from what g_get_user_config_dir() returns? And in that case, why is there then no XDG environment variable, or GLib function, to indicate where to store user-specific editable documents? Surely not in g_get_home_dir()?)

The problem with these functions is that they are so loosely specified, and refer to the somewhat useless XDG Base Directory specification. The documentation and the XDG Base Directory "specification" have been written to justify an existing convention, without actually specifying what the convention is, or what end-user visible appearance the convention wants to achieve.
Comment 5 Javier Jardón (IRC: jjardon) 2010-10-14 14:12:12 UTC
(In reply to comment #4)
> And in that case, why is there then no XDG
> environment variable, or GLib function, to indicate where to store
> user-specific editable documents? Surely not in g_get_home_dir()?)

For this case I think the correct solution is to use:

g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS)
Comment 6 Tor Lillqvist 2010-10-14 14:29:41 UTC
Ah ok. So is the consensus then among you that g_get_user_data_dir() and g_get_user_config_dir() should return the same string on Windows, the CSIDL_APPDATA folder, which maps to C:\Users\<username>\AppData\Roaming on Windows 7? Or CSIDL_LOCAL_APPDATA, which maps to C:\Users\<username>\AppData\Local ?

Whichever we choose, somebody is bound to complain sooner or later. Is there any corresponding "local" vs. "roaming" user-specific data on Linux? I guess not... I don't understand fully the difference on Windows. Is the AppData\Roaming folder copies to each machine a user logs in on in a network environment?

And, an application (or library) *really* caring for Windows (and having developer resources for that) won't use these GLib functions anyway...
Comment 7 Javier Jardón (IRC: jjardon) 2010-10-14 15:17:12 UTC
Let's take a look what others do in this case:

http://doc.qt.nokia.com/4.7/qdesktopservices.html

Seems that there is not a value to retrieve the config folder (g_get_user_config_dir()), so we can point in the docs that g_get_user_config_dir() == g_get_user_data_dir() in windows platform, and recomend only the use of g_get_user_data_dir().


QDesktopServices::DataLocation is our g_get_user_data_dir():

They use XDG_DATA_HOME in X11: http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/util/qdesktopservices_x11.cpp#line148

And CSIDL_LOCAL_APPDATA in win: http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/util/qdesktopservices_win.cpp#line193
Comment 8 Tor Lillqvist 2010-10-14 15:30:49 UTC
OK. So let's follow Qt's lead then. (I would be the first to admit they have better cross-platform support than GLib and GTK+. Actually I don't know, never used Qt, but I strongly suspect so.)

Is this a "bug" that should be fixed also in the stable branch, or more an "enhancement" that should be fixed in master only?
Comment 9 Tor Lillqvist 2010-10-14 15:37:09 UTC
BTW, if any of you silently following this bug oppose this change, now is the time to speak up!
Comment 10 Tor Lillqvist 2010-10-14 15:39:12 UTC
*** Bug 592566 has been marked as a duplicate of this bug. ***
Comment 11 Tor Lillqvist 2010-10-18 11:47:00 UTC
OK, no objections, fixed now in GLib master.

commit 9d80c361418f94c609840ec9f83741aede7e482c
Author: Tor Lillqvist <tml@iki.fi>
Date:   Thu Oct 14 22:47:25 2010 +0300

    Use CSIDL_LOCAL_APPDATA on Windows

    Make g_get_user_data_dir() return the CSIDL_LOCAL_APPDATA folder on
    Windows, and not CSIDL_PERSONAL. On Windows 7, that corresponds to the
    subfolders AppData\Local vs. Documents under the profile ("home")
    folder. This matches what Qt does, for instance, and has been widely
    requested.

    Also make g_get_user_config_dir() return this and not the (roaming)
    CSIDL_APPDATA folder. The reason for this change is that it would be
    surprising and hard to justify if g_get_user_data_dir() returned the
    local application data folder while g_get_user_config_dir() would
    return the roaming one. Nothing in the function names or the XDG specs
    suggests that any roaming vs. local dichotomy would be involved.

    Document the new semantics and the fact that these two functions now
    return the same directory on Windows.

    Note that in reality, code that really truly wants to support Windows
    as well as possible probably will not use these GLib functions anyway,
    but Win32 APIs directly to be sure what it is doing...

    Should hopefully satisfy complaints in bug #620710 and related bugs.
Comment 12 Tor Lillqvist 2010-11-10 09:21:47 UTC
*** Bug 634487 has been marked as a duplicate of this bug. ***
Comment 13 Yevgen Muntyan 2011-11-30 06:23:28 UTC
I realize that it's kind of late (by a year) to complain, but this change breaks applications which use g_get_user_config_dir() - after glib upgrade config files got lost. (I discovered it only now because I am still using gtk-2.16 on windows).

The reason why I do complain is this: "code that really truly wants to support Windows as well as possible probably will not use these GLib functions anyway". How do you tell which functions are good to use and which aren't? It's certainly not in the docs :)