X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/63cf5ae72cc8f844bb8b478de0343f862db40a41..00f00f846b20b4d6bc0eee2668b0c50fd4531a48:/util.c diff --git a/util.c b/util.c index 3d88b15c..e33c7e83 100644 --- a/util.c +++ b/util.c @@ -377,8 +377,11 @@ int robust_unlink(const char *fname) } /* Returns 0 on successful rename, 1 if we successfully copied the file - * across filesystems, -2 if copy_file() failed, and -1 on other errors. */ -int robust_rename(const char *from, const char *to, int mode) + * across filesystems, -2 if copy_file() failed, and -1 on other errors. + * If partialptr is not NULL and we need to do a copy, copy the file into + * the active partial-dir instead of over the destination file. */ +int robust_rename(char *from, char *to, char *partialptr, + int mode) { int tries = 4; @@ -394,6 +397,11 @@ int robust_rename(const char *from, const char *to, int mode) break; #endif case EXDEV: + if (partialptr) { + if (!handle_partial_dir(partialptr,PDIR_CREATE)) + return -1; + to = partialptr; + } if (copy_file(from, to, mode) != 0) return -2; do_unlink(from); @@ -1130,6 +1138,7 @@ char *timestring(time_t t) { static char TimeBuf[200]; struct tm *tm = localtime(&t); + char *p; #ifdef HAVE_STRFTIME strftime(TimeBuf, sizeof TimeBuf - 1, "%Y/%m/%d %H:%M:%S", tm); @@ -1137,11 +1146,10 @@ char *timestring(time_t t) strlcpy(TimeBuf, asctime(tm), sizeof TimeBuf); #endif - if (TimeBuf[strlen(TimeBuf)-1] == '\n') { - TimeBuf[strlen(TimeBuf)-1] = 0; - } + if ((p = strchr(TimeBuf, '\n')) != NULL) + *p = '\0'; - return(TimeBuf); + return TimeBuf; }