Code

Windows: always chmod(, 0666) before unlink().
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Tue, 23 Jan 2007 12:39:09 +0000 (13:39 +0100)
committerJohannes Sixt <johannes.sixt@telecom.at>
Mon, 23 Jun 2008 11:38:23 +0000 (13:38 +0200)
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>
compat/mingw.h

index 901cfa7c82981a1cfdffca3f73334e1dcf6dfed1..95a08b4128d6d5a2017aca18b9b6de59dcbc12ea 100644 (file)
@@ -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)