Skip to content

Commit

Permalink
Windows: always chmod(, 0666) before unlink().
Browse files Browse the repository at this point in the history
On Windows, read-only files cannot be deleted. To make sure that
deletion does not fail because of this, always call chmod() before
unlink().

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
  • Loading branch information
Johannes Schindelin authored and Johannes Sixt committed Jun 23, 2008
1 parent f7597ac commit 132a6e9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ 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

static inline int waitpid(pid_t pid, unsigned *status, unsigned options)
{
if (options == 0)
Expand Down

0 comments on commit 132a6e9

Please sign in to comment.