A few formatting tweaks in delete_file().
authorWayne Davison <wayned@samba.org>
Tue, 23 Mar 2004 16:16:15 +0000 (16:16 +0000)
committerWayne Davison <wayned@samba.org>
Tue, 23 Mar 2004 16:16:15 +0000 (16:16 +0000)
rsync.c

diff --git a/rsync.c b/rsync.c
index f91cda59ea23f7c226b0eb57a9cb5b9ed089074b..1eab8ab61203d879cecb780e0821fda2b7461d6f 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -64,28 +64,28 @@ int delete_file(char *fname)
 #else
        ret = do_stat(fname, &st);
 #endif
-       if (ret) {
+       if (ret)
                return -1;
-       }
 
        if (!S_ISDIR(st.st_mode)) {
-               if (robust_unlink(fname) == 0 || errno == ENOENT) return 0;
+               if (robust_unlink(fname) == 0 || errno == ENOENT)
+                       return 0;
                rprintf(FERROR, "delete_file: unlink %s failed: %s\n",
                        full_fname(fname), strerror(errno));
                return -1;
        }
 
-       if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
-       if (!force_delete || !recurse ||
-           (errno != ENOTEMPTY && errno != EEXIST)) {
+       if (do_rmdir(fname) == 0 || errno == ENOENT)
+               return 0;
+       if (!force_delete || !recurse
+           || (errno != ENOTEMPTY && errno != EEXIST)) {
                rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
                        full_fname(fname), strerror(errno));
                return -1;
        }
 
        /* now we do a recsursive delete on the directory ... */
-       d = opendir(fname);
-       if (!d) {
+       if (!(d = opendir(fname))) {
                rprintf(FERROR, "delete_file: opendir %s failed: %s\n",
                        full_fname(fname), strerror(errno));
                return -1;
@@ -93,12 +93,12 @@ int delete_file(char *fname)
 
        for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) {
                char *dname = d_name(di);
-               if (strcmp(dname,".") == 0
-                   || strcmp(dname,"..") == 0)
+               if (dname[0] == '.' && (dname[1] == '\0'
+                   || (dname[1] == '.' && dname[2] == '\0')))
                        continue;
                pathjoin(buf, sizeof buf, fname, dname);
                if (verbose > 0)
-                       rprintf(FINFO,"deleting %s\n", buf);
+                       rprintf(FINFO, "deleting %s\n", buf);
                if (delete_file(buf) != 0) {
                        closedir(d);
                        return -1;