summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_disk_windows.c
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2011-12-28 11:39:54 -0500
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2011-12-28 11:39:54 -0500
commit2275e52191fba80d667b502cc7110de9072038d7 (patch)
tree49c878e64ec8836856950d38fa3c83c7fede6d85 /libarchive/archive_write_disk_windows.c
parent66ef42e7776ba4649dc25e5153099f255164ba85 (diff)
downloadlibarchive-2275e52191fba80d667b502cc7110de9072038d7.tar.gz
Issue 206.
It seems the CreateHardLinkW API Windows 2000 provides cannot handle the path which have \\?\ prefix, so if CreateHardLinkW failed, try it again without \\?' prefix. SVN-Revision: 4020
Diffstat (limited to 'libarchive/archive_write_disk_windows.c')
-rw-r--r--libarchive/archive_write_disk_windows.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c
index 9df9ddc7..830c1e02 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