mingw: use `CreateHardLink()` directly

The function `CreateHardLink()` is available in all supported Windows versions (even since Windows XP), so there is no more need to resolve it at runtime. Helped-by: Max Kirillov <max@max630.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 13, 2018 at 06:37 UTC 1e1a876bb2c895d59db8b7c8c4eb49ceef454bd3
1 file changed +1 -13
compat/mingw.c
+1 -13
@@ -2211,24 +2211,12 @@ int mingw_raise(int sig)
2211
2212 int link(const char *oldpath, const char *newpath)
2213 {
2214 - typedef BOOL (WINAPI *T)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
2215 - static T create_hard_link = NULL;
2214 wchar_t woldpath[MAX_PATH], wnewpath[MAX_PATH];
2215 if (xutftowcs_path(woldpath, oldpath) < 0 ||
2216 xutftowcs_path(wnewpath, newpath) < 0)
2217 return -1;
2218
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)) {
2220 errno = err_win_to_posix(GetLastError());
2221 return -1;
2222 }