+ 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)) {
+ strcpy(lastpath, fname);
+ *p = '/';
+ for (p=fname+1; (p=strchr(p,'/')); p++) {
+ *p = 0;
+ send_file_name(f, flist, fname, 0);
+ *p = '/';
+ }
+ } else {
+ *p = '/';
+ }
+ }
+
+ if (!*fname)
+ fname = ".";
+
+ if (dir && *dir) {
+ if (getcwd(dbuf,MAXPATHLEN-1) == NULL) {
+ fprintf(FERROR,"getwd : %s\n",strerror(errno));
+ exit_cleanup(1);
+ }
+ if (chdir(dir) != 0) {
+ fprintf(FERROR,"chdir %s : %s\n",
+ dir,strerror(errno));
+ continue;
+ }
+ flist_dir = dir;
+ if (one_file_system)
+ set_filesystem(fname);
+ send_file_name(f,flist,fname,recurse);
+ flist_dir = NULL;
+ if (chdir(dbuf) != 0) {
+ fprintf(FERROR,"chdir %s : %s\n",
+ dbuf,strerror(errno));
+ exit_cleanup(1);
+ }
+ continue;
+ }
+
+ if (one_file_system)
+ set_filesystem(fname);
+ send_file_name(f,flist,fname,recurse);
+ }