From: Michihiro NAKAJIMA Date: Wed, 28 Dec 2011 16:41:32 +0000 (-0500) Subject: Issue 206. Merge from r4020 from trunk. X-Git-Tag: v3.0.3~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4668bb54d5997b84e862f6abb435e3a0457433e4;p=thirdparty%2Flibarchive.git Issue 206. Merge from r4020 from trunk. SVN-Revision: 4021 --- diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c index 9df9ddc72..830c1e02e 100644 --- a/libarchive/archive_write_disk_windows.c +++ b/libarchive/archive_write_disk_windows.c @@ -542,11 +542,36 @@ la_CreateHardLinkW(wchar_t *linkname, wchar_t *target) { static BOOLEAN (WINAPI *f)(LPWSTR, LPWSTR, LPSECURITY_ATTRIBUTES); static int set; + BOOL ret; + if (!set) { set = 1; f = la_GetFunctionKernel32("CreateHardLinkW"); } - return f == NULL ? 0 : (*f)(linkname, target, NULL); + if (!f) + return (0); + ret = (*f)(linkname, target, NULL); + if (!ret) { + /* Under windows 2000, it is necessary to remove + * the "\\?\" prefix. */ +#define IS_UNC(name) ((name[0] == L'U' || name[0] == L'u') && \ + (name[1] == L'N' || name[1] == L'n') && \ + (name[2] == L'C' || name[2] == L'c') && \ + name[3] == L'\\') + if (!wcsncmp(linkname,L"\\\\?\\", 4)) { + linkname += 4; + if (IS_UNC(linkname)) + linkname += 4; + } + if (!wcsncmp(target,L"\\\\?\\", 4)) { + target += 4; + if (IS_UNC(target)) + target += 4; + } +#undef IS_UNC + ret = (*f)(linkname, target, NULL); + } + return (ret); } static int