[PATCH 08/40] Windows: always chmod(, 0666) before unlink().
- From
Johannes Sixt <johannes.sixt@telecom.at>
- Date
- Feb 27, 2008, 18:54 UTC
- Message-ID
- <1204138503-6126-9-git-send-email-johannes.sixt@telecom.at>
- In-Reply-To
- <1204138503-6126-1-git-send-email-johannes.sixt@telecom.at>
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
On Windows, a 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> --- git-compat-util.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h index 672c074..06ac2c1 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -551,6 +551,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)
-- 1.5.4.1.126.ge5a7d