[aquaria] What about using Freedesktop config-spec ? (Patch included)
julroy67 at gmail.com
Fri Apr 22 07:10:20 EDT 2011
2011/4/22 Thomas W. Most <twm at freecog.net>:
> On Thu, Apr 21, 2011 at 10:03 PM, Ryan C. Gordon <icculus at icculus.org> wrote:
>> On 4/21/11 6:58 PM, Julien Humbert wrote:
>>> Hello everyone !
>>> Aquaria uses ATM the « ~/.Aquaria » config directory, and I think it
>>> is a bad practice. $HOME is cluttered with many « ~/.something » files
>>> and dirs. Freedesktop has a spec for this. Apps should use « ~/.config
>>> » for user config files and « ~/.local/share » for user data.
>> Mac OS X has the same sort of split (~/Library/Preferences and ~/Library/Application Support), but I think separating the files is counterproductive, so it all goes under Application Support on the Mac.
>> I agree having the ~/.Aquaria directory is undesirable, and it's only there for the sake of Unix legacy. Would there be a lot of complaints, though, if we settled on ~/.local/share/Aquaria for everything?
> I disagree about the separation. In general, the point of separating
> them is that things in ~/.config can be blown away without loosing
> user data, while stuff in ~/.local/share can be treated as more
> precious. In Aquaria's particular case, it is nice to separate them
> because the user settings include machine-specific stuff like screen
> resolution. In contrast, data like saved games would be useful to
> synchronize between machines, and this is made easier by segregation.
> Regardless, if we mean to implement the XDG spec properly then we'll
> need to check the $XDG_DATA_HOME and $XDG_CONFIG_HOME environment
> variables, using "~/.local/share" and "~/.config" as their default
> values, as defined in the spec .
> : http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
> aquaria mailing list
> aquaria at icculus.org
As Thomas explained, I think separating is better, but altough it is
easy to change and store all in one dir if no one agrees.
As for the XDG spec, I updated the patch and I use separate dirs on
Linux only (OSX uses only one dir for the moment).
Hope it is better handled and I took care of OSX correctly (as in the
previous patch the OSX build was surely broken).
-------------- next part --------------
diff -r ebd81d4a03a4 BBGE/Core.cpp
--- a/BBGE/Core.cpp Fri Apr 22 04:14:59 2011 -0400
+++ b/BBGE/Core.cpp Fri Apr 22 13:08:58 2011 +0200
@@ -877,15 +877,40 @@
mkdir(home.c_str(), 0700); // just in case.
- // "/home/icculus/.Aquaria" or something. Spaces are okay.
+ // Using XDG Spec for Linux and separate config/data.
const std::string prefix("Library/Application Support/");
- const std::string prefix(".");
userDataFolder = home + "/" + prefix + userDataSubFolder;
+ // Checking XDG env vars
+ const char *xdgConfigHome;
+ const char *xdgDataHome;
+ if (xdgConfigHome == NULL)
+ const std::string configPrefix(".config/");
+ userConfigFolder = home + "/" + configPrefix + userDataSubFolder;
+ userConfigFolder = xdgConfigHome;
+ if (xdgDataHome == NULL)
+ const std::string dataPrefix(".local/share/");
+ userDataFolder = home + "/" + dataPrefix + userDataSubFolder;
+ userDataFolder = xdgDataHome;
+ mkdir(userConfigFolder.c_str(), 0700);
+ mkdir(userDataFolder.c_str(), 0700);
debugLogPath = userDataFolder + "/";
mkdir((userDataFolder + "/screenshots").c_str(), 0700);
@@ -1045,7 +1070,11 @@
- return userDataFolder + "/preferences";
+ #ifdef BBGE_BUILD_MACOSX
+ return userDataFolder + "/preferences";
+ return userConfigFolder;
diff -r ebd81d4a03a4 BBGE/Core.h
--- a/BBGE/Core.h Fri Apr 22 04:14:59 2011 -0400
+++ b/BBGE/Core.h Fri Apr 22 13:08:58 2011 +0200
@@ -1318,6 +1318,7 @@
+ std::string userConfigFolder;
More information about the aquaria