[llvm-commits] [llvm] r123604 - /llvm/trunk/lib/Support/Unix/PathV2.inc

Michael J. Spencer bigcheesegs at gmail.com
Sun Jan 16 14:18:41 PST 2011


Author: mspencer
Date: Sun Jan 16 16:18:41 2011
New Revision: 123604

URL: http://llvm.org/viewvc/llvm-project?rev=123604&view=rev
Log:
Fix rename.

Modified:
    llvm/trunk/lib/Support/Unix/PathV2.inc

Modified: llvm/trunk/lib/Support/Unix/PathV2.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=123604&r1=123603&r2=123604&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/PathV2.inc (original)
+++ llvm/trunk/lib/Support/Unix/PathV2.inc Sun Jan 16 16:18:41 2011
@@ -230,8 +230,17 @@
   StringRef f = from.toNullTerminatedStringRef(from_storage);
   StringRef t = to.toNullTerminatedStringRef(to_storage);
 
-  if (::rename(f.begin(), t.begin()) == -1)
-    return error_code(errno, system_category());
+  if (::rename(f.begin(), t.begin()) == -1) {
+    // If it's a cross device link, copy then delete, otherwise return the error
+    if (errno == EXDEV) {
+      if (error_code ec = copy_file(from, to, copy_option::overwrite_if_exists))
+        return ec;
+      bool Existed;
+      if (error_code ec = remove(from, Existed))
+        return ec;
+    } else
+      return error_code(errno, system_category());
+  }
 
   return success;
 }





More information about the llvm-commits mailing list