Skip to content
Snippets Groups Projects
Commit c56aa1d2 authored by Junio C Hamano's avatar Junio C Hamano
Browse files

Merge branch 'js/mingw-create-hard-link'

Windows update.

* js/mingw-create-hard-link:
  mingw: use `CreateHardLink()` directly
parents 744fad66 1e1a876b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2211,24 +2211,12 @@ int mingw_raise(int sig)
 
int link(const char *oldpath, const char *newpath)
{
typedef BOOL (WINAPI *T)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
static T create_hard_link = NULL;
wchar_t woldpath[MAX_PATH], wnewpath[MAX_PATH];
if (xutftowcs_path(woldpath, oldpath) < 0 ||
xutftowcs_path(wnewpath, newpath) < 0)
return -1;
 
if (!create_hard_link) {
create_hard_link = (T) GetProcAddress(
GetModuleHandle("kernel32.dll"), "CreateHardLinkW");
if (!create_hard_link)
create_hard_link = (T)-1;
}
if (create_hard_link == (T)-1) {
errno = ENOSYS;
return -1;
}
if (!create_hard_link(wnewpath, woldpath, NULL)) {
if (!CreateHardLinkW(wnewpath, woldpath, NULL)) {
errno = err_win_to_posix(GetLastError());
return -1;
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment