[glibmm] Added get_system_data_dirs() and get_system_config_dirs().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Added get_system_data_dirs() and get_system_config_dirs().
- Date: Thu, 21 Oct 2010 14:09:56 +0000 (UTC)
commit 5f53f9ba141b86955a6d379e71c11f3c6850b3c6
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Oct 21 16:09:28 2010 +0200
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.
ChangeLog | 10 ++++++++++
glib/glibmm/miscutils.cc | 34 ++++++++++++++++++++++++++++++++++
glib/glibmm/miscutils.h | 29 +++++++++++++++++++++--------
3 files changed, 65 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7ff17ad..1c36025 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 2da6ac9..99f5085 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 8b1ad5d..3e4ae8d 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 */
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]