+ send_if_directory(f, flist, flist->files[i], fbuf, len, flags);
+ }
+}
+
+void send_extra_file_list(int f, int at_least)
+{
+ char fbuf[MAXPATHLEN];
+ struct file_list *flist;
+ int64 start_write;
+ int past_and_present, save_io_error = io_error;
+
+ if (send_dir_ndx < 0)
+ return;
+
+ /* Keep sending data until we have the requested number of
+ * files in the upcoming file-lists. */
+ past_and_present = cur_flist->ndx_start - first_flist->ndx_start
+ + cur_flist->count;
+ while (file_total - past_and_present < at_least) {
+ start_write = stats.total_written;
+ struct file_struct *file = dir_flist->files[send_dir_ndx];
+ int32 *dp;
+ int dlen;
+
+ f_name(file, fbuf);
+ dlen = strlen(fbuf);
+
+ if (F_ROOTDIR(file) != flist_dir) {
+ if (!push_flist_dir(F_ROOTDIR(file), -1))
+ exit_cleanup(RERR_FILESELECT);
+ }
+
+ flist = flist_new(0, "send_extra_file_list");
+
+ write_int(f, NDX_FLIST_OFFSET - send_dir_ndx);
+ change_local_filter_dir(fbuf, dlen, send_dir_depth);
+ send_directory(f, flist, send_dir_ndx, fbuf, dlen, FLAG_DIVERT_DIRS | FLAG_XFER_DIR);
+ write_byte(f, 0);
+
+ clean_flist(flist, 0, 0);
+ file_total += flist->count;
+ stats.flist_size += stats.total_written - start_write;
+ stats.num_files += flist->count;
+ if (verbose > 3)
+ output_flist(flist);
+
+ dp = F_DIRNODE_P(file);
+ if (DIR_FIRST_CHILD(dp) >= 0) {
+ send_dir_ndx = DIR_FIRST_CHILD(dp);
+ send_dir_depth++;
+ } else {
+ while (DIR_NEXT_SIBLING(dp) < 0) {
+ if ((send_dir_ndx = DIR_PARENT(dp)) < 0) {
+ write_int(f, NDX_FLIST_EOF);
+ flist_eof = 1;
+ change_local_filter_dir(NULL, 0, 0);
+ goto finish;
+ }
+ send_dir_depth--;
+ file = dir_flist->files[send_dir_ndx];
+ dp = F_DIRNODE_P(file);
+ }
+ send_dir_ndx = DIR_NEXT_SIBLING(dp);
+ }