quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [patch 4/8] Unmerged patches regenerated against CVS HEAD


From: Gary V. Vaughan
Subject: [Quilt-dev] [patch 4/8] Unmerged patches regenerated against CVS HEAD
Date: Thu, 22 Sep 2005 13:27:04 +0100
User-agent: quilt/0.42-1

Only create and remove parents that are missing or empty.
 lib/backup-files.c |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)

Index: quilt-HEAD/lib/backup-files.c
===================================================================
--- quilt-HEAD.orig/lib/backup-files.c
+++ quilt-HEAD/lib/backup-files.c
@@ -94,43 +94,35 @@ void
 create_parents(const char *filename)
 {
        struct stat st;
+       int rv = -1;
        char *fn = malloc_nofail(strlen(filename) + 1), *f;
 
        strcpy(fn, filename);
        f = strchr(fn, '/');
 
-       if (f != NULL) {
-               *f = '\0';
-               if (stat(f, &st) != 0) {
                        while (f != NULL) {
                                *f = '\0';
+               if (!rv || (rv = stat(f, &st)) != 0) {
                                mkdir(fn, 0777);
-                               *f = '/';
-                               f = strchr(f+1, '/');
                        }
-               } else {
                        *f = '/';
-               }
+                       f = strchr(f+1, '/');
        }
        free(fn);
 }
 
 void
-remove_parents(char *filename)
+remove_parents(const char *filename)
 {
-       char *f, *g = NULL;
+       char *fn = strdup(filename), *f;
 
-       f = strrchr(filename, '/');
-       while ((f = strrchr(filename, '/')) != NULL) {
-               if (g != NULL)
-                       *g = '/';
-               g = f;
-               *f= '\0';
+       while ((f = strrchr(fn, '/')) != NULL) {
+               *f = '\0';
 
-               rmdir(filename);
+               if (rmdir(filename) == -1);
+                   return;
        }
-       if (g != NULL)
-               *g = '/';
+       rmdir(fn);
 }
 
 static int

--
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook




reply via email to

[Prev in Thread] Current Thread [Next in Thread]