]> Dogcows Code - chaz/tar/blobdiff - src/port.c
*** empty log message ***
[chaz/tar] / src / port.c
index 2f3c28240aa6bc440688267497372446b0fea0fa..c45ee3a9955c94227bd98808020fdadbb48b0aba 100644 (file)
@@ -177,14 +177,22 @@ rename (from, to)
 {
   struct stat from_stats;
 
-  if (stat (from, &from_stats) == 0)
+  if (stat (from, &from_stats))
+    return -1;
+
+  if (unlink (to) && errno != ENOENT)
+    return -1;
+
+  if (link (from, to))
+    return -1;
+
+  if (unlink (from) && errno != ENOENT)
     {
-      if (unlink (to) && errno != ENOENT)
-       return -1;
-      if (link (from, to) == 0 && (unlink (from) == 0 || errno == ENOENT))
-       return 0;
+      unlink (to);
+      return -1;
     }
-  return -1;
+
+  return 0;
 }
 #endif
 
This page took 0.020095 seconds and 4 git commands to generate.