create .config dir if it does not exist (issue #629)

This commit is contained in:
o9000 2017-03-10 17:15:36 +01:00
parent c5f6e64a83
commit 5fab41887a

View file

@ -1274,6 +1274,11 @@ gboolean config_read_default_path()
// generate config file
fprintf(stderr, "tint2 warning: could not find a config file!\n");
// According to the XDG Base Directory Specification (https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html)
// if the user's config directory does not exist, we should create it with permissions set to 0700.
if (!g_file_test(g_get_user_config_dir(), G_FILE_TEST_IS_DIR))
g_mkdir(g_get_user_config_dir(), 0700);
gchar *dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL);
if (!g_file_test(dir, G_FILE_TEST_IS_DIR))
g_mkdir(dir, 0700);