]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Probe for CreateHardLinkW and use it only if it's found.
authorTim Kientzle <kientzle@gmail.com>
Sat, 5 Sep 2009 02:41:09 +0000 (22:41 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sat, 5 Sep 2009 02:41:09 +0000 (22:41 -0400)
(Needed for MinGW, which doesn't have new enough Windows
headers to compile calls to CreateHardLinkW.)

SVN-Revision: 1423

CMakeLists.txt
build/cmake/config.h.in
libarchive/archive_windows.c

index fa7d5b28d5b8cc888004fd9e3975674a6fcb6bb6..11f511dc0b818d4f05ce8fe021723aa07892be32 100644 (file)
@@ -337,6 +337,7 @@ CHECK_FUNCTION_EXISTS(SHA512_Init HAVE_SHA512)
 # Check functions
 #
 CHECK_SYMBOL_EXISTS(CreateHardLinkA "windows.h" HAVE_CREATEHARDLINKA)
+CHECK_SYMBOL_EXISTS(CreateHardLinkW "windows.h" HAVE_CREATEHARDLINKW)
 CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
 CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
 CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
index 0347d89597fabca58df5fcd997cf843cde41a11a..416ffc18a067962ce360509e5b05bbe023bfa515 100644 (file)
 /* Define to 1 if you have the `chroot' function. */
 #cmakedefine HAVE_CHROOT 1
 
-/* Define to 1 if you have the `CreateSymbolicLink function. */
-#cmakedefine HAVE_CREATESYMBOLICLINK 1
+/* Define to 1 if you have the `CreateHardLinkA' function. */
+#cmakedefine HAVE_CREATEHARDLINKA 1
 
-/* Define to 1 if you have the `CreateHardLink function. */
-#cmakedefine HAVE_CREATEHARDLINK 1
+/* Define to 1 if you have the `CreateHardLinkW' function. */
+#cmakedefine HAVE_CREATEHARDLINKW 1
 
 /* Define to 1 if you have the <ctype.h> header file. */
 #cmakedefine HAVE_CTYPE_H 1
index 2e5e8578a8f8587b638e2aae021018e51ccbc985..cd3a067338862e63d304e22142c0f3eefc002396 100644 (file)
@@ -218,6 +218,10 @@ la_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
        return (handle);
 }
 
+#if HAVE_CREATEHARDLINKW
+/* Check that path1 and path2 can be hard-linked by each other.
+ * Both arguments must be made by permissive_name function. 
+ */
 static size_t
 wequallen(const wchar_t *s1, const wchar_t *s2)
 {
@@ -229,9 +233,6 @@ wequallen(const wchar_t *s1, const wchar_t *s2)
        return (i);
 }
 
-/* Check that path1 and path2 can be hard-linked by each other.
- * Both arguments must be made by permissive_name function. 
- */
 static int
 canHardLinkW(const wchar_t *path1, const wchar_t *path2)
 {
@@ -297,6 +298,7 @@ canHardLinkW(const wchar_t *path1, const wchar_t *path2)
        else
                return (0);
 }
+#endif
 
 /* Make a link to src called dst.  */
 static int
@@ -328,9 +330,11 @@ __link(const char *src, const char *dst, int sym)
                        retval = -1;
                        goto exit;
                }
+#if HAVE_CREATEHARDLINKW
                if (!sym && canHardLinkW(wsrc, wdst))
                        res = CreateHardLinkW(wdst, wsrc, NULL);
                else
+#endif
                        res = CopyFileW(wsrc, wdst, FALSE);
        } else {
                /* wsrc does not exist; try src prepend it with the dirname of wdst */
@@ -387,9 +391,11 @@ __link(const char *src, const char *dst, int sym)
                        retval = -1;
                        goto exit;
                }
+#if HAVE_CREATEHARDLINKW
                if (!sym && canHardLinkW(wnewsrc, wdst))
                        res = CreateHardLinkW(wdst, wnewsrc, NULL);
                else
+#endif
                        res = CopyFileW(wnewsrc, wdst, FALSE);
                free (wnewsrc);
        }