+ dir = NULL;
+
+ if (!relative_paths) {
+ p = strrchr(fname,'/');
+ if (p) {
+ *p = 0;
+ if (p == fname)
+ dir = "/";
+ else
+ dir = fname;
+ fname = p+1;
+ }
+ } else if (f != -1 && (p=strrchr(fname,'/'))) {
+ /* this ensures we send the intermediate directories,
+ thus getting their permissions right */
+ *p = 0;
+ if (strcmp(lastpath,fname)) {
+ strlcpy(lastpath, fname, sizeof(lastpath)-1);
+ *p = '/';
+ for (p=fname+1; (p=strchr(p,'/')); p++) {
+ int copy_links_saved = copy_links;
+ *p = 0;
+ copy_links = 0;
+ send_file_name(f, flist, fname, 0, 0);
+ copy_links = copy_links_saved;
+ *p = '/';
+ }
+ } else {
+ *p = '/';
+ }
+ }
+
+ if (!*fname)
+ fname = ".";
+
+ if (dir && *dir) {
+ char *olddir = push_dir(dir, 1);
+
+ if (!olddir) {
+ io_error=1;
+ rprintf(FERROR,"push_dir %s : %s\n",
+ dir,strerror(errno));
+ continue;
+ }
+
+ flist_dir = dir;
+ if (one_file_system)
+ set_filesystem(fname);
+ send_file_name(f,flist,fname,recurse,FLAG_DELETE);
+ flist_dir = NULL;
+ if (pop_dir(olddir) != 0) {
+ rprintf(FERROR,"pop_dir %s : %s\n",
+ dir,strerror(errno));
+ exit_cleanup(1);
+ }
+ continue;
+ }
+
+ if (one_file_system)
+ set_filesystem(fname);
+ send_file_name(f,flist,fname,recurse,FLAG_DELETE);
+ }