@matheusbsbs / matheus-bagliano / commits / 337967fb77
Fork 0

mingw: move unlink wrapper to mingw.c

The next patch implements a workaround in case unlink fails on Windows. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Heiko Voigt committed Feb 7, 2011 at 21:49 UTC 337967fb7794b300f1633a413c0db525ab517a3e
2 files changed +11 -8
compat/mingw.c
+8
@@ -116,6 +116,14 @@ int err_win_to_posix(DWORD winerr)
116 return error;
117 }
118
119 +#undef unlink
120 +int mingw_unlink(const char *pathname)
121 +{
122 + /* read-only files cannot be removed */
123 + chmod(pathname, 0666);
124 + return unlink(pathname);
125 +}
126 +
127 #undef open
128 int mingw_open (const char *filename, int oflags, ...)
129 {
compat/mingw.h
+3 -8
@@ -125,14 +125,6 @@ static inline int mingw_mkdir(const char *path, int mode)
125 }
126 #define mkdir mingw_mkdir
127
128 -static inline int mingw_unlink(const char *pathname)
129 -{
130 - /* read-only files cannot be removed */
131 - chmod(pathname, 0666);
132 - return unlink(pathname);
133 -}
134 -#define unlink mingw_unlink
135 -
128 #define WNOHANG 1
129 pid_t waitpid(pid_t pid, int *status, unsigned options);
130
@@ -180,6 +172,9 @@ int link(const char *oldpath, const char *newpath);
172 * replacements of existing functions
173 */
174
175 +int mingw_unlink(const char *pathname);
176 +#define unlink mingw_unlink
177 +
178 int mingw_open (const char *filename, int oflags, ...);
179 #define open mingw_open
180