MinGW: a hardlink implementation
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b3debd2b0c
commit
7be401e069
@ -1118,3 +1118,24 @@ void mingw_open_html(const char *unixpath)
|
||||
printf("Launching default browser to display HTML ...\n");
|
||||
ShellExecute(NULL, "open", htmlpath, NULL, "\\", 0);
|
||||
}
|
||||
|
||||
int link(const char *oldpath, const char *newpath)
|
||||
{
|
||||
typedef BOOL WINAPI (*T)(const char*, const char*, LPSECURITY_ATTRIBUTES);
|
||||
static T create_hard_link = NULL;
|
||||
if (!create_hard_link) {
|
||||
create_hard_link = (T) GetProcAddress(
|
||||
GetModuleHandle("kernel32.dll"), "CreateHardLinkA");
|
||||
if (!create_hard_link)
|
||||
create_hard_link = (T)-1;
|
||||
}
|
||||
if (create_hard_link == (T)-1) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
if (!create_hard_link(newpath, oldpath, NULL)) {
|
||||
errno = err_win_to_posix(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user