Skip to content

Commit

Permalink
Merge branch 'mingw-CreateHardLink'
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Nov 15, 2018
2 parents e6eb0f7 + 2953149 commit 70f331e
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,24 +2153,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;
}
Expand Down

0 comments on commit 70f331e

Please sign in to comment.