summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--glib/glibmm/miscutils.cc34
-rw-r--r--glib/glibmm/miscutils.h29
3 files changed, 65 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ff17ad8..1c36025c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-21 Murray Cumming <murrayc@murrayc-desktop>
+
+ Added get_system_data_dirs() and get_system_config_dirs().
+
+ * glib/glibmm/miscutils.[h|cc]: Wrappping g_get_system_data_dirs() and
+ g_get_system_config_dirs(), which were actually added in glib 2.6 but
+ not noticed by us until now.
+ Notice that these return std::vector<> instead of ArrayHandle, because we
+ have decided to do that for new APIs.
+
2010-10-19 Murray Cumming <murrayc@murrayc.com>
Fix the build with the latest glib API.
diff --git a/glib/glibmm/miscutils.cc b/glib/glibmm/miscutils.cc
index 2da6ac92..99f50852 100644
--- a/glib/glibmm/miscutils.cc
+++ b/glib/glibmm/miscutils.cc
@@ -121,6 +121,40 @@ std::string get_user_config_dir()
return convert_const_gchar_ptr_to_stdstring(g_get_user_config_dir());
}
+std::vector<std::string> get_system_data_dirs()
+{
+ //TODO: Use a utility function:
+ std::vector<std::string> result;
+ const char* const * cresult = g_get_system_data_dirs();
+ if(cresult)
+ return result;
+
+ for(const gchar* const * iter = cresult; *iter != 0; ++iter)
+ {
+ result.push_back(
+ convert_const_gchar_ptr_to_stdstring(*iter));
+ }
+
+ return result;
+}
+
+std::vector<std::string> get_system_config_dirs()
+{
+ //TODO: Use a utility function:
+ std::vector<std::string> result;
+ const char* const * cresult = g_get_system_config_dirs();
+ if(cresult)
+ return result;
+
+ for(const gchar* const * iter = cresult; *iter != 0; ++iter)
+ {
+ result.push_back(
+ convert_const_gchar_ptr_to_stdstring(*iter));
+ }
+
+ return result;
+}
+
std::string get_user_cache_dir()
{
return convert_const_gchar_ptr_to_stdstring(g_get_user_cache_dir());
diff --git a/glib/glibmm/miscutils.h b/glib/glibmm/miscutils.h
index 8b1ad5d7..3e4ae8dd 100644
--- a/glib/glibmm/miscutils.h
+++ b/glib/glibmm/miscutils.h
@@ -104,21 +104,21 @@ std::string getenv(const std::string& variable);
* they can be any sequence of bytes. On Windows, they should be in
* UTF-8.
*
- * Note that on some systems, when variables are overwritten, the memory
+ * Note that on some systems, when variables are overwritten, the memory
* used for the previous variables and its value isn't reclaimed.
*
* @param variable The environment variable to set. It must not contain '='.
* @param value The value to which the variable should be set.
* @param overwrite Whether to change the variable if it already exists.
* @result false if the environment variable couldn't be set.
- */
+ */
bool setenv(const std::string& variable, const std::string& value, bool overwrite = true);
/** Removes an environment variable from the environment.
*
- * Note that on some systems, when variables are overwritten, the memory
+ * Note that on some systems, when variables are overwritten, the memory
* used for the previous variables and its value isn't reclaimed.
- * Furthermore, this function can't be guaranteed to operate in a
+ * Furthermore, this function can't be guaranteed to operate in a
* threadsafe way.
*
* @param variable: the environment variable to remove. It must not contain '='.
@@ -169,7 +169,7 @@ std::string get_tmp_dir();
std::string get_current_dir();
//TODO: We could create a C++ enum to wrap the C GUserDirectory enum,
-//but we would have to either be very careful, or define the enum
+//but we would have to either be very careful, or define the enum
//values in terms of the C enums anyway.
/** Returns the full path of a special directory using its logical id.
*
@@ -181,7 +181,7 @@ std::string get_current_dir();
*
* Return value: the path to the specified special directory.
* @param directory Te logical id of special directory
- *
+ *
* @newin{2,14}
*/
std::string get_user_special_dir(GUserDirectory directory);
@@ -206,6 +206,20 @@ std::string get_user_data_dir();
*/
std::string get_user_config_dir();
+/** Returns an ordered list of base directories in which to access system-wide application data.
+ * On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification.
+ *
+ * @newin{2,18}
+ */
+std::vector<std::string> get_system_data_dirs();
+
+/** Returns an ordered list of base directories in which to access system-wide configuration information.
+ * On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification.
+ *
+ * @newin{2,18}
+ */
+std::vector<std::string> get_system_config_dirs();
+
/** Returns a base directory in which to store non-essential, cached data
* specific to particular user.
*
@@ -294,7 +308,7 @@ std::string build_filename(const std::string& elem1, const std::string& elem2);
* Other than for determination of the number of leading and trailing
* copies of the separator, elements consisting only of copies
* of the separator are ignored.
- *
+ *
* @param separator A string used to separate the elements of the path.
* @param elements A container holding the elements of the path to build.
* Any STL compatible container type is accepted.
@@ -331,4 +345,3 @@ std::string find_program_in_path(const std::string& program);
#endif /* _GLIBMM_FILEUTILS_H */
-