if dest symbolic link exists, remove it and relink
authorGengbin Zheng <gzheng@illinois.edu>
Sat, 10 Dec 2005 07:56:29 +0000 (07:56 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Sat, 10 Dec 2005 07:56:29 +0000 (07:56 +0000)
src/arch/win32/createlink.cpp
src/arch/win32/createlink.exe

index 249155060449d8f8c4ad6803ee32b447e8409814..3b4af7fa7eeb1b2ee020ee6d4cbd7d3eb14bbc1a 100644 (file)
@@ -17,8 +17,15 @@ int main(int argc, char **argv)
   bool fCreatedLink  = CreateHardLink(dest, src, NULL);
   if (!fCreatedLink) {
     int err=GetLastError();
-    printf("CreateHardLink %s => %s failed errno=%d, WSAerr=%d\n", src, dest, errno, err);
-    return 1;
+    if (err == ERROR_ALREADY_EXISTS) {
+      remove(dest);
+      fCreatedLink  = CreateHardLink(dest, src, NULL);   // try again
+      if (!fCreatedLink)  err=GetLastError();
+    }
+    if (!fCreatedLink)  {
+      printf("CreateHardLink %s => %s failed errno=%d, WSAerr=%d\n", src, dest, errno, err);
+      exit(1);
+    }
   }
   else {
     exit(0);
index 46d823e6dd5fa927f2174c7aea742e747c35b89c..cbde4031538c14cce2dc6894fb8cd7cc30ddbcbf 100755 (executable)
Binary files a/src/arch/win32/createlink.exe and b/src/arch/win32/createlink.exe differ