OSDN Git Service

Fix MinGW-Bug #3295526 (reported by Charles Wilson).
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 12 May 2011 20:11:52 +0000 (20:11 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 12 May 2011 20:11:52 +0000 (20:11 +0000)
ChangeLog
src/pkgunst.cpp

index 2af1d3d..1851c17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-05-12  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
+       Fix MinGW-Bug #3295526 (reported by Charles Wilson).
+
+       * src/pkgunst.cpp (sys/stat.h): #include it; we need it for...
+       (pkg_unlink): ...chmod( file, S_IWRITE ), emulating `rm -f' semantics.
+
+2011-05-12  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
        Diagnose and aggressively retry failed download connections.
 
        * src/debug.h (DEBUG_TRACE_INTERNET_REQUESTS): New macro; define it.
index 03eb5a2..599eb8c 100644 (file)
@@ -263,6 +263,14 @@ int pkg_rmdir( const char *sysroot, const char *pathname )
   return retval;
 }
 
+/* We want the following "unlink" function to emulate "rm -f"
+ * semantics; thus we need to ensure that each file we attempt
+ * to unlink is writeable.  To do this, we call "chmod()" prior
+ * to "unlink()"; we need sys/stat.h for the S_IWRITE mode we
+ * are required to set.
+ */
+#include <sys/stat.h>
+
 static __inline__ __attribute__((__always_inline__))
 int pkg_unlink( const char *sysroot, const char *pathname )
 {
@@ -282,6 +290,7 @@ int pkg_unlink( const char *sysroot, const char *pathname )
        dmh_printf( "  %s: unlink file\n", filepath )
       );
 
+    chmod( filepath, S_IWRITE );
     if( ((retval = unlink( filepath )) != 0) && (errno != ENOENT) )
       dmh_notify( DMH_WARNING, "%s:unlink failed; %s\n", filepath, strerror( errno ) );
   }