First set some canonical macros to recognise various flavours of Windows
and then use them to patch up some file-system accesses on Windows.
lib/backup-files.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
Index: quilt-HEAD/lib/backup-files.c
===================================================================
--- quilt-HEAD.orig/lib/backup-files.c
+++ quilt-HEAD/lib/backup-files.c
@@ -25,12 +25,28 @@
* -B and -Z options.
*/
-#define _GNU_SOURCE
-
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#define _GNU_SOURCE
+
+#if defined(__MINGW32__) && !defined(__MINGW__)
+# define __MINGW__ __MINGW32__
+#endif
+#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
+# define __CYGWIN__ __CYGWIN32__
+#endif
+#if defined(_WIN32) && !defined(WIN32)
+# define WIN32 _WIN32
+#endif
+#if defined(WIN32) && !defined(__WINDOWS__)
+# define __WINDOWS__ WIN32
+#endif
+#if defined(__CYGWIN__) && defined(__WINDOWS__)
+# undef __WINDOWS__
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <utime.h>
@@ -103,7 +119,11 @@ create_parents(const char *filename)
while (f != NULL) {
*f = '\0';
if (!rv || (rv = stat(f, &st)) != 0) {
+#ifdef __WINDOWS__
+ mkdir(fn);
+#else
mkdir(fn, 0777);
+#endif
}
*f = '/';
f = strchr(f+1, '/');
@@ -143,6 +163,7 @@ link_or_copy(const char *from, struct st
{
int from_fd, to_fd, error = 1;
+#ifndef __WINDOWS__
if (link(from, to) == 0)
return 0;
if (errno != EXDEV && errno != EPERM && errno != EMLINK) {
@@ -152,11 +173,18 @@ link_or_copy(const char *from, struct st
}
if ((from_fd = open(from, O_RDONLY)) == -1) {
+#else
+ if ((from_fd = open(from, O_RDONLY|O_BINARY, _S_IREAD|_S_IWRITE)) ==
-1) {
+#endif
perror(from);
return 1;
}
unlink(to); /* make sure we don't inherit this file's mode. */
+#ifdef __WINDOWS__
+ if ((to_fd = open(to, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,
_S_IREAD|_S_IWRITE)) != -1) {
+#else
if ((to_fd = creat(to, st->st_mode))) {
+#endif
perror(to);
close(from_fd);
return 1;
--
Gary V. Vaughan ())_. [EMAIL PROTECTED],gnu.org}
Research Scientist ( '/ http://tkd.kicks-ass.net
GNU Hacker / )= http://www.gnu.org/software/libtool
Technical Author `(_~)_ http://sources.redhat.com/autobook
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev