X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/cad2bba7d809c9f385fd8b85959c09c5e687edb5..e1b3d5c4be46ee0b17a98aa48cb7cb152c4a008b:/flist.c diff --git a/flist.c b/flist.c index 179e7e7e..75920690 100644 --- a/flist.c +++ b/flist.c @@ -21,12 +21,13 @@ #include "rsync.h" +extern struct stats stats; + extern int csum_length; extern int verbose; extern int am_server; extern int always_checksum; -extern int64 total_size; extern int cvs_exclude; @@ -90,49 +91,6 @@ static void send_directory(int f,struct file_list *flist,char *dir); static char *flist_dir; -static void clean_fname(char *name) -{ - char *p; - int l; - int modified = 1; - - if (!name) return; - - while (modified) { - modified = 0; - - if ((p=strstr(name,"/./"))) { - modified = 1; - while (*p) { - p[0] = p[2]; - p++; - } - } - - if ((p=strstr(name,"//"))) { - modified = 1; - while (*p) { - p[0] = p[1]; - p++; - } - } - - if (strncmp(p=name,"./",2) == 0) { - modified = 1; - do { - p[0] = p[2]; - } while (*p++); - } - - l = strlen(p=name); - if (l > 1 && p[l-1] == '/') { - modified = 1; - p[l-1] = 0; - } - } -} - - void send_file_entry(struct file_struct *file,int f,unsigned base_flags) { @@ -464,7 +422,7 @@ static struct file_struct *make_file(char *fname) } if (!S_ISDIR(st.st_mode)) - total_size += st.st_size; + stats.total_size += st.st_size; return file; } @@ -566,15 +524,17 @@ struct file_list *send_file_list(int f,int argc,char *argv[]) int i,l; STRUCT_STAT st; char *p,*dir; - char dbuf[MAXPATHLEN]; char lastpath[MAXPATHLEN]=""; struct file_list *flist; + int64 start_write; if (verbose && recurse && !am_server && f != -1) { rprintf(FINFO,"building file list ... "); rflush(FINFO); } + start_write = stats.total_written; + flist = (struct file_list *)malloc(sizeof(flist[0])); if (!flist) out_of_memory("send_file_list"); @@ -646,24 +606,23 @@ struct file_list *send_file_list(int f,int argc,char *argv[]) fname = "."; if (dir && *dir) { - if (getcwd(dbuf,MAXPATHLEN-1) == NULL) { - rprintf(FERROR,"getwd : %s\n",strerror(errno)); - exit_cleanup(1); - } - if (chdir(dir) != 0) { + char *olddir = push_dir(dir, 1); + + if (!olddir) { io_error=1; - rprintf(FERROR,"chdir %s : %s\n", + 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 (chdir(dbuf) != 0) { - rprintf(FERROR,"chdir %s : %s\n", - dbuf,strerror(errno)); + if (pop_dir(olddir) != 0) { + rprintf(FERROR,"pop_dir %s : %s\n", + dir,strerror(errno)); exit_cleanup(1); } continue; @@ -696,6 +655,8 @@ struct file_list *send_file_list(int f,int argc,char *argv[]) if (f != -1) { io_end_buffering(f); + stats.flist_size = stats.total_written - start_write; + stats.num_files = flist->count; } if (verbose > 2) @@ -709,12 +670,15 @@ struct file_list *recv_file_list(int f) { struct file_list *flist; unsigned char flags; + int64 start_read; if (verbose && recurse && !am_server) { rprintf(FINFO,"receiving file list ... "); rflush(FINFO); } + start_read = stats.total_read; + flist = (struct file_list *)malloc(sizeof(flist[0])); if (!flist) goto oom; @@ -745,7 +709,7 @@ struct file_list *recv_file_list(int f) receive_file_entry(&flist->files[i],flags,f); if (S_ISREG(flist->files[i]->mode)) - total_size += flist->files[i]->length; + stats.total_size += flist->files[i]->length; flist->count++; @@ -776,6 +740,9 @@ struct file_list *recv_file_list(int f) if (verbose > 2) rprintf(FINFO,"recv_file_list done\n"); + stats.flist_size = stats.total_read - start_read; + stats.num_files = flist->count; + return flist; oom: @@ -790,8 +757,8 @@ int file_compare(struct file_struct **f1,struct file_struct **f2) if (!(*f1)->basename) return -1; if (!(*f2)->basename) return 1; if ((*f1)->dirname == (*f2)->dirname) - return strcmp((*f1)->basename, (*f2)->basename); - return strcmp(f_name(*f1),f_name(*f2)); + return u_strcmp((*f1)->basename, (*f2)->basename); + return u_strcmp(f_name(*f1),f_name(*f2)); }