[gnome-commander] Retrieve a gFile attribute as string in a more general method



commit 10787b6ab598beb045d16aa4ee4452309e81b4f8
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Wed Dec 30 17:23:35 2020 +0100

    Retrieve a gFile attribute as string in a more general method

 src/gnome-cmd-file.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 50e43ac7..ab30344a 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -479,7 +479,7 @@ gchar *GnomeCmdFile::get_unescaped_dirname()
 
 GAppInfo *GnomeCmdFile::GetAppInfoForContentType()
 {
-    auto contentTypeString = this->GetGfileContentTypeString();
+    auto contentTypeString = this->GetGfileAttributeString(G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
     auto appInfo = g_app_info_get_default_for_type (contentTypeString, false);
     g_free(contentTypeString);
 
@@ -487,12 +487,12 @@ GAppInfo *GnomeCmdFile::GetAppInfoForContentType()
 }
 
 
-gchar *GnomeCmdFile::GetGfileContentTypeString()
+gchar *GnomeCmdFile::GetGfileAttributeString(const char *attribute)
 {
     GError *error;
     error = nullptr;
     auto gcmdFileInfo = g_file_query_info(gFile,
-                                   G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+                                   attribute,
                                    G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                    nullptr,
                                    &error);
@@ -500,13 +500,13 @@ gchar *GnomeCmdFile::GetGfileContentTypeString()
     {
         g_message ("retrieving file info failed: %s", error->message);
         g_error_free (error);
-        exit (EXIT_FAILURE);
+        return nullptr;
     }
 
-    auto gFileContentTypeString = g_strdup(g_file_info_get_attribute_string (gcmdFileInfo, 
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE));
+    auto gFileAttributeString = g_strdup(g_file_info_get_attribute_string (gcmdFileInfo, attribute));
     g_object_unref(gcmdFileInfo);
 
-    return gFileContentTypeString;
+    return gFileAttributeString;
 }
 
 


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