From: Johannes Sixt <j6t@kdbg.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Petr Kodl <petrkodl@gmail.com>
Subject: [PATCH 2/2] MinGW: a hardlink implementation
Date: Tue, 17 Mar 2009 08:46:43 +0100 [thread overview]
Message-ID: <49BF5563.2060500@kdbg.org> (raw)
In-Reply-To: <49BF53C2.6020707@kdbg.org>
From: Petr Kodl <petrkodl@gmail.com>
Date: Sat, 24 Jan 2009 15:04:39 +0100
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
This is the meat of Petr's original patch with the fixup that was
discussed in the msysgit mailing list (WINAPI was added in the
typedef).
-- Hannes
compat/mingw.c | 21 +++++++++++++++++++++
compat/mingw.h | 3 +--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index f66ad56..171fa85 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;
+}
diff --git a/compat/mingw.h b/compat/mingw.h
index f5da647..762eb14 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -67,8 +67,6 @@ static inline int readlink(const char *path, char *buf, size_t bufsiz)
{ errno = ENOSYS; return -1; }
static inline int symlink(const char *oldpath, const char *newpath)
{ errno = ENOSYS; return -1; }
-static inline int link(const char *oldpath, const char *newpath)
-{ errno = ENOSYS; return -1; }
static inline int fchmod(int fildes, mode_t mode)
{ errno = ENOSYS; return -1; }
static inline int fork(void)
@@ -134,6 +132,7 @@ int getpagesize(void); /* defined in MinGW's libgcc.a */
struct passwd *getpwuid(int uid);
int setitimer(int type, struct itimerval *in, struct itimerval *out);
int sigaction(int sig, struct sigaction *in, struct sigaction *out);
+int link(const char *oldpath, const char *newpath);
/*
* replacements of existing functions
--
1.6.2.rc2.971.g14d5
next prev parent reply other threads:[~2009-03-17 7:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-17 7:39 [PATCH 1/2] MinGW: a helper function that translates Win32 API error codes Johannes Sixt
2009-03-17 7:46 ` Johannes Sixt [this message]
2009-03-17 10:12 ` [PATCH 2/2] MinGW: a hardlink implementation Johannes Schindelin
2009-03-17 10:10 ` [PATCH 1/2] MinGW: a helper function that translates Win32 API error codes Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49BF5563.2060500@kdbg.org \
--to=j6t@kdbg.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=petrkodl@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.