- * The function from which the scanner thread starts
- *
- * @param cls the 'struct GNUNET_FS_DirScanner'
- * @return 0/NULL
- */
-#if WINDOWS
-DWORD
-#else
-static void *
-#endif
-run_directory_scan_thread (void *cls)
-{
- struct GNUNET_FS_DirScanner *ds = cls;
-
- if (GNUNET_OK != preprocess_file (ds,
- ds->filename_expanded,
- &ds->toplevel))
- {
- (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
- GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE);
- return 0;
- }
- if (GNUNET_OK !=
- write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_ALL_COUNTED))
- {
- GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE);
- return 0;
- }
- if (GNUNET_OK !=
- extract_files (ds, ds->toplevel))
- {
- (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
- GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE);
- return 0;
- }
- (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_FINISHED);
- GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE);
- return 0;
-}
-
-
-/**
- * Read 'size' bytes from 'in' into 'buf'.
- *
- * @param in pipe to read from
- * @param buf buffer to read to
- * @param size number of bytes to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-static int
-read_all (const struct GNUNET_DISK_FileHandle *in,
- char *buf,
- size_t size)
-{
- size_t total;
- ssize_t rd;
-
- total = 0;
- do
- {
- rd = GNUNET_DISK_file_read (in,
- &buf[total],
- size - total);
- if (rd > 0)
- total += rd;
- } while ( (rd > 0) && (total < size) );
- if (rd <= 0)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to read from inter thread communication pipe: %s\n",
- strerror (errno));
- return (total == size) ? GNUNET_OK : GNUNET_SYSERR;
-}
-
-
-/**
- * Called every time there is data to read from the scanner.
- * Calls the scanner progress handler.