Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntenore Gatta <antenore.gatta@kyndryl.com>2021-10-21 00:40:38 +0300
committerAntenore Gatta <antenore.gatta@kyndryl.com>2021-10-21 00:40:38 +0300
commit83da19928954fddaf0edc3af20f3e4529c062ce0 (patch)
tree1cdd0c124ffd849fc252ab5a2e15b1318b64c484 /src/remmina_file_manager.c
parentd1d937cc1e4a5eada22975a751c3d8301beeea9c (diff)
folder initializations fixes
Diffstat (limited to 'src/remmina_file_manager.c')
-rw-r--r--src/remmina_file_manager.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/remmina_file_manager.c b/src/remmina_file_manager.c
index 687b75f83..6d7fab3d9 100644
--- a/src/remmina_file_manager.c
+++ b/src/remmina_file_manager.c
@@ -36,9 +36,11 @@
#include "config.h"
+#include <errno.h>
#include <gtk/gtk.h>
#include <string.h>
+#include "remmina_log.h"
#include "remmina_public.h"
#include "remmina_pref.h"
#include "remmina_string_array.h"
@@ -49,8 +51,11 @@
static gchar *remminadir;
static gchar *cachedir;
-/* return first found data dir as per XDG specs.
- * The returned string must be freed by the caller with g_free */
+/**
+ * Return datadir_path from pref or first found data dir as per XDG specs.
+ *
+ * The returned string must be freed by the caller with g_free
+ */
gchar *remmina_file_get_datadir(void)
{
TRACE_CALL(__func__);
@@ -99,6 +104,12 @@ static gboolean remmina_file_manager_do_copy(const char *src_path, const char *d
return ok;
}
+/**
+ * It creates the Remmina data and cache folders
+ *
+ * If it finds the legacy ~/.remmina folder it copies the connection profiles in the new folder.
+ *
+ * If it finds default profiles in the XDG_DATA_DIRS it copies the profiles in the user data folder.
void remmina_file_manager_init(void)
{
TRACE_CALL(__func__);
@@ -107,10 +118,21 @@ void remmina_file_manager_init(void)
const gchar *filename;
int i;
- remminadir = g_build_path("/", g_get_user_data_dir(), "remmina", NULL);
- /* Create the XDG_USER_DATA directory */
- g_mkdir_with_parents(remminadir, 0750);
- g_free(remminadir), remminadir = NULL;
+ /* Get and create the XDG_DATA_HOME directory */
+ remminadir = remmina_pref_get_value("datadir_path");
+ if (g_mkdir_with_parents(remminadir, 0750) == 0) {
+ REMMINA_DEBUG ("Remmina data folder %s initialized successfully", remminadir);
+ g_free(remminadir), remminadir = NULL;
+ } else {
+ g_free(remminadir), remminadir = NULL;
+ /* Get and create the XDG_DATA_HOME directory */
+ remminadir = g_build_path("/", g_get_user_data_dir(), "remmina", NULL);
+ if (g_mkdir_with_parents(remminadir, 0750) == 0)
+ REMMINA_DEBUG ("Remmina data folder %s initialized successfully", remminadir);
+ else
+ REMMINA_CRITICAL("Cannot create data folder %s", remminadir);
+ g_free(remminadir), remminadir = NULL;
+ }
/* Create the XDG_CACHE_HOME directory */
cachedir = g_build_path("/", g_get_user_cache_dir(), "remmina", NULL);
g_mkdir_with_parents(cachedir, 0750);