summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@nil.im>2020-05-16 19:33:57 +0200
committerJonathan Schleifer <js@nil.im>2020-05-16 19:33:57 +0200
commit42b007f99dcfa5ac6b2f70d5778c7d2bf380095c (patch)
treee8803cd084ed35748b17f1dd2a6fc48252dda180
parentb38d9296fc349514fd289b43e32f34761e440bcc (diff)
OFFileURLHandler: Weakly link CreateHardLinkW()
-rw-r--r--src/OFFileURLHandler.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/OFFileURLHandler.m b/src/OFFileURLHandler.m
index b2361f31..ca98fe9e 100644
--- a/src/OFFileURLHandler.m
+++ b/src/OFFileURLHandler.m
@@ -109,6 +109,8 @@ static OFMutex *readdirMutex;
#ifdef OF_WINDOWS
static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD);
+static WINAPI BOOLEAN (*func_CreateHardLinkW)(LPCWSTR, LPCWSTR,
+ LPSECURITY_ATTRIBUTES);
#endif
#ifdef OF_WINDOWS
@@ -498,10 +500,15 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
#endif
#ifdef OF_WINDOWS
- if ((module = LoadLibrary("kernel32.dll")) != NULL)
+ if ((module = LoadLibrary("kernel32.dll")) != NULL) {
func_CreateSymbolicLinkW =
(WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD))
GetProcAddress(module, "CreateSymbolicLinkW");
+ func_CreateHardLinkW =
+ (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR,
+ LPSECURITY_ATTRIBUTES))
+ GetProcAddress(module, "CreateHardLinkW");
+ }
#endif
/*
@@ -1166,7 +1173,11 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
destinationURL: destination
errNo: errno];
# else
- if (!CreateHardLinkW(destinationPath.UTF16String,
+ if (func_CreateHardLinkW == NULL)
+ @throw [OFNotImplementedException exceptionWithSelector: _cmd
+ object: self];
+
+ if (!func_CreateHardLinkW(destinationPath.UTF16String,
sourcePath.UTF16String, NULL))
@throw [OFLinkFailedException
exceptionWithSourceURL: source