Skip to content

Commit 70f331e

Browse files
committed
Merge branch 'mingw-CreateHardLink'
Signed-off-by: Johannes Schindelin <[email protected]>
2 parents e6eb0f7 + 2953149 commit 70f331e

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

compat/mingw.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,24 +2153,12 @@ int mingw_raise(int sig)
21532153

21542154
int link(const char *oldpath, const char *newpath)
21552155
{
2156-
typedef BOOL (WINAPI *T)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
2157-
static T create_hard_link = NULL;
21582156
wchar_t woldpath[MAX_PATH], wnewpath[MAX_PATH];
21592157
if (xutftowcs_path(woldpath, oldpath) < 0 ||
21602158
xutftowcs_path(wnewpath, newpath) < 0)
21612159
return -1;
21622160

2163-
if (!create_hard_link) {
2164-
create_hard_link = (T) GetProcAddress(
2165-
GetModuleHandle("kernel32.dll"), "CreateHardLinkW");
2166-
if (!create_hard_link)
2167-
create_hard_link = (T)-1;
2168-
}
2169-
if (create_hard_link == (T)-1) {
2170-
errno = ENOSYS;
2171-
return -1;
2172-
}
2173-
if (!create_hard_link(wnewpath, woldpath, NULL)) {
2161+
if (!CreateHardLinkW(wnewpath, woldpath, NULL)) {
21742162
errno = err_win_to_posix(GetLastError());
21752163
return -1;
21762164
}

0 commit comments

Comments
 (0)