LRN: make disk iterator start return GNUNET_SYSERR if run on empty directory
authorChristian Grothoff <christian@grothoff.org>
Mon, 9 Jan 2012 16:38:26 +0000 (16:38 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 9 Jan 2012 16:38:26 +0000 (16:38 +0000)
src/include/gnunet_disk_lib.h
src/util/disk.c

index 19c1328bdc473fb19ce9af6d1bc045268000837e..fc2f0170470d0efcb419f992dfa572bd31b047da 100644 (file)
@@ -565,8 +565,10 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter,
  * @param dirName the name of the directory
  * @param callback the method to call for each file
  * @param callback_cls closure for callback
+ * @return GNUNET_YES if directory is not empty and @callback
+ *         will be called later, GNUNET_NO otherwise, GNUNET_SYSERR on error.
  */
-void
+int
 GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
                                       const char *dirName,
                                       GNUNET_DISK_DirectoryIteratorCallback
index e6b542adfeaa608e27e0456243b34142fa8518d8..430d9cc46710d7b0db82e3dcd5bbfe440ea20a91 100644 (file)
@@ -1047,8 +1047,10 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter,
  * @param dirName the name of the directory
  * @param callback the method to call for each file
  * @param callback_cls closure for callback
+ * @return GNUNET_YES if directory is not empty and @callback
+ *         will be called later, GNUNET_NO otherwise, GNUNET_SYSERR on error.
  */
-void
+int
 GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
                                       const char *dirName,
                                       GNUNET_DISK_DirectoryIteratorCallback
@@ -1064,11 +1066,11 @@ GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
   {
     GNUNET_free (di);
     callback (callback_cls, NULL, NULL, NULL);
-    return;
+    return GNUNET_SYSERR;
   }
   di->dirname = GNUNET_strdup (dirName);
   di->priority = prio;
-  GNUNET_DISK_directory_iterator_next (di, GNUNET_NO);
+  return GNUNET_DISK_directory_iterator_next (di, GNUNET_NO);
 }