[stsf-commit] stsf/stsflib path.c, 1.2, 1.3 sft.h, 1.2, 1.3 stsfutil.c, 1.13, 1.14

Alan Coopersmith stsf-commit at pdx.freedesktop.org
Mon Feb 28 19:15:08 PST 2005


Committed by: alanc


Index: path.c
===================================================================
RCS file: /cvs/stsf/stsf/stsflib/path.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- path.c	2 Jul 2004 05:00:17 -0000	1.2
+++ path.c	1 Mar 2005 03:15:06 -0000	1.3
@@ -191,7 +191,7 @@
 {
     struct stat st;
 
-    if (stat(pathname, &st) == -1) {
+    if (lstat(pathname, &st) == -1) {
         return ST_FILETYPE_DOESNOTEXIST;
     }
 

Index: sft.h
===================================================================
RCS file: /cvs/stsf/stsf/stsflib/sft.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sft.h	2 Jul 2004 05:00:17 -0000	1.2
+++ sft.h	1 Mar 2005 03:15:06 -0000	1.3
@@ -117,12 +117,16 @@
 #endif
 #endif
 
-#ifdef __BIG_ENDIAN__
-#define G_BIG_ENDIAN
+#if defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
+# ifndef G_BIG_ENDIAN
+#  define G_BIG_ENDIAN
+# endif
 #endif
 
-#ifdef __LITTLE_ENDIAN__
-#define G_LITTLE_ENDIAN
+#if defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
+# ifndef G_LITTLE_ENDIAN
+#  define G_LITTLE_ENDIAN
+# endif
 #endif
 
 #if !defined(G_BIG_ENDIAN) && !defined(G_LITTLE_ENDIAN)

Index: stsfutil.c
===================================================================
RCS file: /cvs/stsf/stsf/stsflib/stsfutil.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- stsfutil.c	2 Jul 2004 05:00:17 -0000	1.13
+++ stsfutil.c	1 Mar 2005 03:15:06 -0000	1.14
@@ -1348,7 +1348,7 @@
             } else {
                 *p = '\0';
             }
-            if (stat(q, &st)) {
+            if (lstat(q, &st)) {
                 if (errno != ENOENT || mkdir(q, mode) < 0) {
                     ret = 1;
                 }
@@ -1369,16 +1369,19 @@
 
 void DelTree(char *path)
 {
-    DIR *dirp = opendir(path);
+    DIR *dirp;
     struct dirent *dp;
     struct stat st;
 
+    if (lstat(path, &st) == 0 && !S_ISDIR(st.st_mode)) {
+      // printf("- %s\n", path);
+      remove(path);
+      return;
+    }
+    
+    dirp = opendir(path);
     if (!dirp) {
-        if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) {
-            // printf("- %s\n", path);
-            unlink(path);
-        }
-        return;
+      return;
     }
 
     // printf("+ %s\n", path);
@@ -1390,14 +1393,12 @@
         if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue;
         cp = malloc(strlen(path) + strlen(dp->d_name) + 2);
         strcpy(cp, path); strcat(cp, "/"); strcat(cp, dp->d_name);
-        if (stat(cp, &st) == 0) {
-            if (!S_ISDIR(st.st_mode)) {
-                // printf("- %s\n", cp);
-                unlink(cp);
-            } else {
+        if (lstat(cp, &st) == 0) {
+	    // printf("- %s\n", cp);
+            if (S_ISDIR(st.st_mode)) {
                 DelTree(cp);
-                rmdir(cp);
-            }
+	    }
+	    remove(cp);
         }
         free(cp);
     }



More information about the stsf-commit mailing list