gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r13393 - gnunet-gtk/src


From: gnunet
Subject: [GNUnet-SVN] r13393 - gnunet-gtk/src
Date: Tue, 26 Oct 2010 14:59:32 +0200

Author: grothoff
Date: 2010-10-26 14:59:31 +0200 (Tue, 26 Oct 2010)
New Revision: 13393

Modified:
   gnunet-gtk/src/main_window_file_publish.c
Log:
use marker instead of 0 for directory file size

Modified: gnunet-gtk/src/main_window_file_publish.c
===================================================================
--- gnunet-gtk/src/main_window_file_publish.c   2010-10-26 12:56:00 UTC (rev 
13392)
+++ gnunet-gtk/src/main_window_file_publish.c   2010-10-26 12:59:31 UTC (rev 
13393)
@@ -26,6 +26,8 @@
 #include "edit_publish_dialog.h"
 #include <gnunet/gnunet_util_lib.h>
 
+#define MARKER_DIR_FILE_SIZE "-"
+
 /**
  * Builder used for the master publish dialog.
  */
@@ -278,7 +280,10 @@
                                                    expiration);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_FS_uri_destroy (ksk_uri);
-  file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size);
+  if (S_ISDIR (sbuf.st_mode))
+    file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE);
+  else
+    file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size);
   gtk_tree_store_set (ts, &pos,
                      0, file_size_fancy,
                      1, (gboolean) do_index,
@@ -343,7 +348,7 @@
                                                          expiration);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   gtk_tree_store_set (ts, pos,
-                     0, "0",
+                     0, MARKER_DIR_FILE_SIZE,
                      1, (gboolean) GNUNET_NO,
                      2, name,
                      3, (guint) anonymity,
@@ -633,15 +638,25 @@
   struct GNUNET_FS_Uri *ksk_uri;
   const char *ss;
   const char *short_fn;
- 
-  if (GNUNET_OK != 
-      GNUNET_DISK_file_size (filename,
-                            &file_size,
-                            GNUNET_YES))
+  struct stat sbuf;
+
+  if (0 != STAT (filename, &sbuf))
+    return;
+  if (S_ISDIR (sbuf.st_mode))
     {
-      GNUNET_break (0);
-      return;
+      file_size = 0;
     }
+  else
+    {
+      if (GNUNET_OK != 
+         GNUNET_DISK_file_size (filename,
+                                &file_size,
+                                GNUNET_YES))
+       {
+         GNUNET_break (0);
+         return;
+       }
+    }
   ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
   /* FIXME: modify ksk_uri based on md_no_ksk */
   path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts),
@@ -660,7 +675,10 @@
                                                    expiration);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_FS_uri_destroy (ksk_uri);
-  file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size);
+  if (S_ISDIR (sbuf.st_mode))
+    file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE);
+  else
+    file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size);
   short_fn = filename;
   while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR)))
     short_fn = 1 + ss;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]