return (handle);
}
-#if HAVE_CREATEHARDLINKW
+static void *
+la_GetFunctionKernel32(const char *name)
+{
+ static HINSTANCE lib;
+ static int set;
+ if (!set) {
+ set = 1;
+ lib = LoadLibrary("kernel32.dll");
+ }
+ if (lib == NULL) {
+ fprintf(stderr, "Can't load kernel32.dll?!\n");
+ exit(1);
+ }
+ return (void *)GetProcAddress(lib, name);
+}
+
+static int
+la_CreateHardLinkW(wchar_t *linkname, wchar_t *target)
+{
+ static BOOLEAN (WINAPI *f)(LPWSTR, LPWSTR, LPSECURITY_ATTRIBUTES);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = la_GetFunctionKernel32("CreateHardLinkW");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, NULL);
+}
+
/* Check that path1 and path2 can be hard-linked by each other.
* Both arguments must be made by permissive_name function.
*/
else
return (0);
}
-#endif
/* Make a link to src called dst. */
static int
retval = -1;
goto exit;
}
-#if HAVE_CREATEHARDLINKW
- if (!sym && canHardLinkW(wsrc, wdst))
- res = CreateHardLinkW(wdst, wsrc, NULL);
- else
-#endif
+ if (!sym && canHardLinkW(wsrc, wdst)) {
+ res = la_CreateHardLinkW(wdst, wsrc);
+ } else {
res = CopyFileW(wsrc, wdst, FALSE);
+ }
} else {
/* wsrc does not exist; try src prepend it with the dirname of wdst */
wchar_t *wnewsrc, *slash;
retval = -1;
goto exit;
}
-#if HAVE_CREATEHARDLINKW
if (!sym && canHardLinkW(wnewsrc, wdst))
- res = CreateHardLinkW(wdst, wnewsrc, NULL);
+ res = la_CreateHardLinkW(wdst, wnewsrc);
else
-#endif
res = CopyFileW(wnewsrc, wdst, FALSE);
free (wnewsrc);
}
return (void *)GetProcAddress(lib, name);
}
-int __CreateSymbolicLinkA(const char *linkname, const char *target, int flags)
+static int
+my_CreateSymbolicLinkA(const char *linkname, const char *target, int flags)
{
- static BOOLEAN (*f)(LPCSTR, LPCSTR, DWORD);
+ static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, DWORD);
static int set;
if (!set) {
set = 1;
}
return f == NULL ? 0 : (*f)(linkname, target, flags);
}
+
+static int
+my_CreateHardLinkA(const char *linkname, const char *target)
+{
+ static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = GetFunctionKernel32("CreateHardLinkA");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, NULL);
+}
#endif
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
va_list ap;
va_start(ap, fmt);
- sprintf(buff, fmt, ap);
+ vsprintf(buff, fmt, ap);
va_end(ap);
/* failure_start() isn't quite right, but is awfully convenient. */
failure_start(test_filename, test_line, "SKIPPING: %s", buff);
int succeeded;
assertion_count(file, line);
-#if HAVE_LINK
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ succeeded = my_CreateHardLinkA(newpath, linkto);
+#elif HAVE_LINK
succeeded = !link(linkto, newpath);
-#elif HAVE_CREATEHARDLINKA
- succeeded = CreateHardLinkA(newpath, linkto, NULL);
#else
succeeded = 0;
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
int targetIsDir = 0; /* TODO: Fix this */
assertion_count(file, line);
- if (__CreateSymbolicLinkA(newpath, linkto, targetIsDir))
+ if (my_CreateSymbolicLinkA(newpath, linkto, targetIsDir))
return (1);
#elif HAVE_SYMLINK
assertion_count(file, line);