Skip to content

Commit

Permalink
mingw: move unlink wrapper to mingw.c
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Voigt authored and Junio C Hamano committed Feb 7, 2011
1 parent b5c1781 commit 337967f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 8 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ int err_win_to_posix(DWORD winerr)
return error;
}

#undef unlink
int mingw_unlink(const char *pathname)
{
/* read-only files cannot be removed */
chmod(pathname, 0666);
return unlink(pathname);
}

#undef open
int mingw_open (const char *filename, int oflags, ...)
{
Expand Down
11 changes: 3 additions & 8 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ static inline int mingw_mkdir(const char *path, int mode)
}
#define mkdir mingw_mkdir

static inline int mingw_unlink(const char *pathname)
{
/* read-only files cannot be removed */
chmod(pathname, 0666);
return unlink(pathname);
}
#define unlink mingw_unlink

#define WNOHANG 1
pid_t waitpid(pid_t pid, int *status, unsigned options);

Expand Down Expand Up @@ -180,6 +172,9 @@ int link(const char *oldpath, const char *newpath);
* replacements of existing functions
*/

int mingw_unlink(const char *pathname);
#define unlink mingw_unlink

int mingw_open (const char *filename, int oflags, ...);
#define open mingw_open

Expand Down

0 comments on commit 337967f

Please sign in to comment.