pidgin/pidgin

0fc4ba7fa2be
Make XDG dir structure inside custom user dir
--- a/libpurple/util.c Wed Sep 28 02:21:24 2016 +0300
+++ b/libpurple/util.c Wed Sep 28 14:15:08 2016 +0300
@@ -58,10 +58,10 @@
if (!xdg_dir_exists) {
gint mkdir_res;
- mkdir_res = g_mkdir_with_parents(purple_xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR));
+ mkdir_res = purple_build_dir(purple_xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR));
if (mkdir_res == -1) {
purple_debug_error("util", "Error creating xdg directory %s: %s; failed migration\n",
- purple_xdg_dir, g_strerror(errno));
+ purple_xdg_dir, g_strerror(errno));
return;
}
}
@@ -209,9 +209,7 @@
escape_js_gen = json_generator_new();
json_node_set_boolean(escape_js_node, FALSE);
- if (custom_user_dir == NULL) {
- migrate_to_xdg_base_dirs();
- }
+ migrate_to_xdg_base_dirs();
}
void
@@ -3004,12 +3002,12 @@
const char *
purple_cache_dir(void)
{
- if (custom_user_dir != NULL) {
- return custom_user_dir;
- }
-
if (!cache_dir) {
- cache_dir = g_build_filename(g_get_user_cache_dir(), "purple", NULL);
+ if (!custom_user_dir) {
+ cache_dir = g_build_filename(g_get_user_cache_dir(), "purple", NULL);
+ } else {
+ cache_dir = g_build_filename(custom_user_dir, "cache", NULL);
+ }
}
return cache_dir;
@@ -3018,12 +3016,12 @@
const char *
purple_config_dir(void)
{
- if (custom_user_dir != NULL) {
- return custom_user_dir;
- }
-
if (!config_dir) {
- config_dir = g_build_filename(g_get_user_config_dir(), "purple", NULL);
+ if (!custom_user_dir) {
+ config_dir = g_build_filename(g_get_user_config_dir(), "purple", NULL);
+ } else {
+ config_dir = g_build_filename(custom_user_dir, "config", NULL);
+ }
}
return config_dir;
@@ -3032,12 +3030,12 @@
const char *
purple_data_dir(void)
{
- if (custom_user_dir != NULL) {
- return custom_user_dir;
- }
-
if (!data_dir) {
- data_dir = g_build_filename(g_get_user_data_dir(), "purple", NULL);
+ if (!custom_user_dir) {
+ data_dir = g_build_filename(g_get_user_data_dir(), "purple", NULL);
+ } else {
+ data_dir = g_build_filename(custom_user_dir, "data", NULL);
+ }
}
return data_dir;
@@ -3053,7 +3051,7 @@
custom_user_dir = NULL;
}
-int purple_build_dir (const char *path, int mode)
+int purple_build_dir(const char *path, int mode)
{
return g_mkdir_with_parents(path, mode);
}
@@ -3069,7 +3067,7 @@
purple_debug_misc("util", "Writing file %s to directory %s",
filename, dir);
- /* Ensure the user directory exists */
+ /* Ensure the directory exists */
if (!g_file_test(dir, G_FILE_TEST_IS_DIR))
{
if (g_mkdir(dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
@@ -3088,11 +3086,6 @@
return ret;
}
-/*
- * This function is long and beautiful, like my--um, yeah. Anyway,
- * it includes lots of error checking so as we don't overwrite
- * people's settings if there is a problem writing the new values.
- */
gboolean
purple_util_write_data_to_file(const char *filename, const char *data, gssize size)
{
@@ -3129,6 +3122,11 @@
return ret;
}
+/*
+ * This function is long and beautiful, like my--um, yeah. Anyway,
+ * it includes lots of error checking so as we don't overwrite
+ * people's settings if there is a problem writing the new values.
+ */
gboolean
purple_util_write_data_to_file_absolute(const char *filename_full, const char *data, gssize size)
{
--- a/libpurple/util.h Wed Sep 28 02:21:24 2016 +0300
+++ b/libpurple/util.h Wed Sep 28 14:15:08 2016 +0300
@@ -791,9 +791,9 @@
* purple_cache_dir:
*
* Returns the purple cache directory according to XDG Base Directory Specification.
- * This is usually ~/.cache/purple
- *
- * See purple_home_dir()
+ * This is usually ~/.cache/purple.
+ * If custom user dir was specified then this is cache
+ * sub-directory of DIR argument passed to -c option.
*
* Returns: The purple cache directory.
*/
@@ -803,9 +803,9 @@
* purple_config_dir:
*
* Returns the purple configuration directory according to XDG Base Directory Specification.
- * This is usually ~/.config/purple
- *
- * See purple_home_dir()
+ * This is usually ~/.config/purple.
+ * If custom user dir was specified then this is config
+ * sub-directory of DIR argument passed to -c option.
*
* Returns: The purple configuration directory.
*/
@@ -815,9 +815,9 @@
* purple_data_dir:
*
* Returns the purple data directory according to XDG Base Directory Specification.
- * This is usually ~/.local/share/purple
- *
- * See purple_home_dir()
+ * This is usually ~/.local/share/purple.
+ * If custom user dir was specified then this is data
+ * sub-directory of DIR argument passed to -c option.
*
* Returns: The purple data directory.
*/
@@ -877,7 +877,8 @@
*
* Returns: TRUE if the file was written successfully. FALSE otherwise.
*/
-gboolean purple_util_write_data_to_cache_file(const char *filename, const char *data, gssize size);
+gboolean
+purple_util_write_data_to_cache_file(const char *filename, const char *data, gssize size);
/**
* purple_util_write_data_to_config_file:
@@ -893,7 +894,8 @@
*
* Returns: TRUE if the file was written successfully. FALSE otherwise.
*/
-gboolean purple_util_write_data_to_config_file(const char *filename, const char *data, gssize size);
+gboolean
+purple_util_write_data_to_config_file(const char *filename, const char *data, gssize size);
/**
* purple_util_write_data_to_data_file:
@@ -909,7 +911,8 @@
*
* Returns: TRUE if the file was written successfully. FALSE otherwise.
*/
-gboolean purple_util_write_data_to_data_file(const char *filename, const char *data, gssize size);
+gboolean
+purple_util_write_data_to_data_file(const char *filename, const char *data, gssize size);
/**
* purple_util_write_data_to_file_absolute: