diff options
author | Petr Kodl <petrkodl@gmail.com> | 2009-01-24 15:04:39 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-17 09:21:32 -0700 |
commit | 7be401e069758cc36d335241d9b80f9aeebf58c7 (patch) | |
tree | 18254a54c1a00473acf544860be31d5f7ca4a9f3 /compat/mingw.c | |
parent | b3debd2b0c091990c420f78e074c0c160498e51d (diff) | |
download | git-7be401e069758cc36d335241d9b80f9aeebf58c7.tar.gz git-7be401e069758cc36d335241d9b80f9aeebf58c7.tar.xz |
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>
Diffstat (limited to 'compat/mingw.c')
-rw-r--r-- | compat/mingw.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c index f66ad56aa..171fa85e4 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -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; +} |