]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Another step towards clean Windows builds: libarchive, libarchive_test, and bsdtar_...
authorTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 18:34:07 +0000 (14:34 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 18:34:07 +0000 (14:34 -0400)
SVN-Revision: 1305

CMakeLists.txt
build/cmake/config.h.in
libarchive/test/main.c
libarchive/test/test.h
libarchive/test/test_open_fd.c
libarchive/test/test_read_data_large.c
libarchive/test/test_read_large.c
tar/test/main.c

index 12ec0e8b7a05b73c8f6df00c26336f12f6bbdebc..21530a23da75ff8e6988e80547c2720f163dc657 100644 (file)
@@ -284,6 +284,8 @@ CHECK_FUNCTION_EXISTS(SHA512_Init HAVE_SHA512)
 #
 # Check functions
 #
+CHECK_SYMBOL_EXISTS(CreateHardLink "windows.h" HAVE_CREATEHARDLINK)
+CHECK_SYMBOL_EXISTS(CreateSymbolicLink "windows.h" HAVE_CREATESYMBOLICLINK)
 CHECK_FUNCS(chflags chown chroot)
 CHECK_FUNCS(fchdir fchflags fchmod fchown fcntl fork)
 CHECK_FUNCS(fstat ftruncate futimes geteuid getpid)
index b24016bfaf7c0918c98a281cf7e2650c1b72e4f7..4720aadaf6beaaba5e897b9e278cb020efcca1e6 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 `CreateHardLink function. */
+#cmakedefine HAVE_CREATEHARDLINK 1
+
 /* Define to 1 if you have the <ctype.h> header file. */
 #cmakedefine HAVE_CTYPE_H 1
 
index 8087710027879041a6827697eb4b0064eadf4bd6..d59e35115e39291f0d16a19b1c22d192bc377f27 100644 (file)
@@ -945,6 +945,9 @@ int
 test_assert_is_symlink(const char *file, int line,
     const char *pathname, const char *contents)
 {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       return (0);
+#else
        char buff[300];
        struct stat st;
        ssize_t linklen;
@@ -995,6 +998,7 @@ test_assert_is_symlink(const char *file, int line,
                return (0);
        }
        return (1);
+#endif
 }
 
 int
@@ -1061,10 +1065,12 @@ test_assert_make_hardlink(const char *file, int line,
        int succeeded;
 
        count_assertion(file, line);
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if HAVE_CREATEHARDLINK
        succeeded = CreateHardLink(newpath, linkto, NULL);
-#else
+#elif HAVE_LINK
        succeeded = !link(linkto, newpath);
+#else
+       succeeded = 0;
 #endif
        if (succeeded) {
                msg[0] = '\0';
@@ -1087,13 +1093,15 @@ test_assert_make_symlink(const char *file, int line,
 {
        int succeeded;
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if HAVE_CREATESYMBOLICLINK
        int targetIsDir = 0; /* TODO: Fix this. */
        count_assertion(file, line);
        succeeded = CreateSymbolicLink(newpath, linkto, targetIsDir);
-#else
+#elif HAVE_SYMLINK
        count_assertion(file, line);
        succeeded = !symlink(linkto, newpath);
+#else
+       succeeded = 0;
 #endif
        if (succeeded) {
                msg[0] = '\0';
index 809cf66ce97118c971ed0974d329c5ca9afa5b03..ec8d072fd742c1a2ceb94886d5f9c0ccf2d821fa 100644 (file)
 #endif
 #include <errno.h>
 #include <fcntl.h>
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <wchar.h>
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
 
 
 #ifdef __FreeBSD__
index 18e461cbf9491c3712e43dc2efa845a78802cf4e..79cbba2ce040740d7129c152df29ff2cb0b6d27e 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD$");
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define open _open
+#define lseek _lseek
+#define close _close
+#endif
 
 DEFINE_TEST(test_open_fd)
 {
index f9a8ad44bbbef4859f3f0bbf21c664e85cd4084f..9487485bdbdd5bebf33854f74bbc876e6bb92138 100644 (file)
@@ -33,6 +33,11 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_data_large.c,v 1.4 2008/09
  * had a bug relating to this, fixed in Nov 2006).
  */
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define open _open
+#define close _close
+#endif
+
 char buff1[11000000];
 char buff2[10000000];
 char buff3[10000000];
index 1e72d473aefda72672725dc532de76b6d00f579e..b98f07fe128a906aecdceee5ceea49dd93f00336 100644 (file)
@@ -29,6 +29,11 @@ static unsigned char testdata[10 * 1024 * 1024];
 static unsigned char testdatacopy[10 * 1024 * 1024];
 static unsigned char buff[11 * 1024 * 1024];
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define open _open
+#define close _close
+#endif
+
 /* Check correct behavior on large reads. */
 DEFINE_TEST(test_read_large)
 {
index a061fcd19a091b8fc6470f6b9e5bbfbd6397e5dd..8891e90fc260b0b0eb4274a4df9e6bf5caf8b18b 100644 (file)
@@ -1069,10 +1069,12 @@ test_assert_make_hardlink(const char *file, int line,
        int succeeded;
 
        count_assertion(file, line);
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if HAVE_CREATEHARDLINK
        succeeded = CreateHardLink(newpath, linkto, NULL);
-#else
+#elif HAVE_LINK
        succeeded = !link(linkto, newpath);
+#else
+       succeeded = 0;
 #endif
        if (succeeded) {
                msg[0] = '\0';
@@ -1095,13 +1097,15 @@ test_assert_make_symlink(const char *file, int line,
 {
        int succeeded;
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if HAVE_CREATESYMBOLICLINK
        int targetIsDir = 0; /* TODO: Fix this. */
        count_assertion(file, line);
        succeeded = CreateSymbolicLink(newpath, linkto, targetIsDir);
-#else
+#elif HAVE_SYMLINK
        count_assertion(file, line);
        succeeded = !symlink(linkto, newpath);
+#else
+       succeeded = 0;
 #endif
        if (succeeded) {
                msg[0] = '\0';