[gnome-commander] Fix for creating a GFile object for a GnomeCmdCon instance



commit 49541a36f86a701513e8297f186317e4c0b7c106
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Wed Jan 5 14:46:35 2022 +0100

    Fix for creating a GFile object for a GnomeCmdCon instance
    
    Only if path was given for that GnomeCmdCon instance, use g_uri_build to
    build the correct GFile object, if not, just use the URI of that GnomeCmdCon instance.
    
    This might be reverted later on, I am not sure if that approach is correct.

 src/gnome-cmd-con-remote.cc | 26 ++++++++++++++++++++------
 src/gnome-cmd-con.h         |  2 +-
 2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/src/gnome-cmd-con-remote.cc b/src/gnome-cmd-con-remote.cc
index 523faeef..3568a838 100644
--- a/src/gnome-cmd-con-remote.cc
+++ b/src/gnome-cmd-con-remote.cc
@@ -75,7 +75,7 @@ static void mount_func (GnomeCmdCon *con)
 {
     g_return_if_fail(GNOME_CMD_IS_CON(con));
 
-    auto gFile = gnome_cmd_con_create_gfile(con, con->base_path);
+    auto gFile = gnome_cmd_con_create_gfile(con);
 
     auto uri = g_file_get_uri(gFile);
     DEBUG('m', "Connecting to %s\n", uri);
@@ -184,15 +184,29 @@ static gboolean remote_open_is_needed (GnomeCmdCon *con)
 }
 
 
+static GFile *create_remote_gfile_with_path(GnomeCmdCon *con, GnomeCmdPath *path)
+{
+    auto gUri = g_uri_build(G_URI_FLAGS_NONE, con->scheme, nullptr, con->hostname, con->port, 
path->get_path(), nullptr, nullptr);
+    auto gFilePathUriString = g_uri_to_string(gUri);
+    auto gFile = g_file_new_for_uri(gFilePathUriString);
+    g_free(gFilePathUriString);
+    return gFile;
+}
+
+
 static GFile *remote_create_gfile (GnomeCmdCon *con, GnomeCmdPath *path)
 {
     g_return_val_if_fail (con->uri != nullptr, nullptr);
 
-    auto uri = g_strdup_printf("%s://%s%s", con->scheme, con->hostname, path->get_path());
-    auto gFile = g_file_new_for_uri (uri);
-    g_free(uri);
-
-    return gFile;
+    if (path)
+    {
+        return create_remote_gfile_with_path(con, path);
+    }
+    else
+    {
+        auto gFile = g_file_new_for_uri (con->uri);
+        return gFile;
+    }
 }
 
 
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index 194d8667..1f72eb76 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -195,7 +195,7 @@ inline void gnome_cmd_con_set_scheme (GnomeCmdCon *con, const std::string &schem
     con->scheme = scheme.empty() ? NULL : g_strdup (scheme.c_str());
 }
 
-GFile *gnome_cmd_con_create_gfile (GnomeCmdCon *con, GnomeCmdPath *path);
+GFile *gnome_cmd_con_create_gfile (GnomeCmdCon *con, GnomeCmdPath *path = nullptr);
 
 GnomeCmdPath *gnome_cmd_con_create_path (GnomeCmdCon *con, const gchar *path_str);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]