[gvfs] Don't show not requested info in gvfs-info (#582175)



commit 454a365b0b53cce2010787f6eb4ee28c321a6375
Author: Andreas Henriksson <andreas fatal se>
Date:   Tue Jun 23 17:40:46 2009 +0200

    Don't show not requested info in gvfs-info (#582175)
    
    For example:
    vuntz lyon ~/>gvfs-info -a standard::content-type ~/blah.txt
    type: unknown
    size: 0
    attributes:
      standard::content-type: text/plain
    
    type and size probably shouldn't be displayed if a specific attribute was
    requested..

 programs/gvfs-info.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/programs/gvfs-info.c b/programs/gvfs-info.c
index b3d6e0e..8c74441 100644
--- a/programs/gvfs-info.c
+++ b/programs/gvfs-info.c
@@ -153,11 +153,11 @@ show_info (GFileInfo *info)
   name = g_file_info_get_display_name (info);
   if (name)
     g_print ("display name: %s\n", name);
-  
+
   name = g_file_info_get_edit_name (info);
   if (name)
     g_print ("edit name: %s\n", name);
-  
+
   name = g_file_info_get_name (info);
   if (name)
     {
@@ -165,16 +165,22 @@ show_info (GFileInfo *info)
       g_print ("name: %s\n", escaped);
       g_free (escaped);
     }
-  
-  type = type_to_string (g_file_info_get_file_type (info));
-  g_print ("type: %s\n", type);
-  
-  size = g_file_info_get_size (info);
-  g_print ("size: %"G_GUINT64_FORMAT"\n", (guint64)size);
-  
+
+  if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_TYPE))
+    {
+      type = type_to_string (g_file_info_get_file_type (info));
+      g_print ("type: %s\n", type);
+    }
+
+  if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE))
+    {
+      size = g_file_info_get_size (info);
+      g_print ("size: %"G_GUINT64_FORMAT"\n", (guint64)size);
+    }
+
   if (g_file_info_get_is_hidden (info))
     g_print ("hidden\n");
-  
+
   show_attributes (info);
 }
 



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