Skip to content

Commit c56aa1d

Browse files
committed
Merge branch 'js/mingw-create-hard-link'
Windows update. * js/mingw-create-hard-link: mingw: use `CreateHardLink()` directly
2 parents 744fad6 + 1e1a876 commit c56aa1d

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
@@ -2211,24 +2211,12 @@ int mingw_raise(int sig)
22112211

22122212
int link(const char *oldpath, const char *newpath)
22132213
{
2214-
typedef BOOL (WINAPI *T)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
2215-
static T create_hard_link = NULL;
22162214
wchar_t woldpath[MAX_PATH], wnewpath[MAX_PATH];
22172215
if (xutftowcs_path(woldpath, oldpath) < 0 ||
22182216
xutftowcs_path(wnewpath, newpath) < 0)
22192217
return -1;
22202218

2221-
if (!create_hard_link) {
2222-
create_hard_link = (T) GetProcAddress(
2223-
GetModuleHandle("kernel32.dll"), "CreateHardLinkW");
2224-
if (!create_hard_link)
2225-
create_hard_link = (T)-1;
2226-
}
2227-
if (create_hard_link == (T)-1) {
2228-
errno = ENOSYS;
2229-
return -1;
2230-
}
2231-
if (!create_hard_link(wnewpath, woldpath, NULL)) {
2219+
if (!CreateHardLinkW(wnewpath, woldpath, NULL)) {
22322220
errno = err_win_to_posix(GetLastError());
22332221
return -1;
22342222
}

0 commit comments

Comments
 (0)