From 4caee83a25ea255def17a585109f691d1ab36ddd Mon Sep 17 00:00:00 2001 From: owsla Date: Tue, 8 Apr 2008 13:06:55 +0000 Subject: Get cmodule.c building natively on Windows (Patch from Josh Nisly) git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@880 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 2 ++ rdiff-backup/rdiff_backup/cmodule.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index f37d28d..c96529b 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,6 +1,8 @@ New in v1.1.16 (????/??/??) --------------------------- +Get cmodule.c building natively on Windows. (Patch from Josh Nisly) + Don't give up right away if we can't open a file. Try chmod'ing it even if we aren't root or don't own it, since that can sometimes work on AFS and NFS. Closes Savannah bug #21202. (Andrew Ferguson) diff --git a/rdiff-backup/rdiff_backup/cmodule.c b/rdiff-backup/rdiff_backup/cmodule.c index 5fc61e0..28c5292 100644 --- a/rdiff-backup/rdiff_backup/cmodule.c +++ b/rdiff-backup/rdiff_backup/cmodule.c @@ -24,7 +24,9 @@ #include #include #include +#if !defined(MS_WIN64) && !defined(MS_WIN32) #include +#endif #include @@ -46,13 +48,17 @@ /* This code taken from Python's posixmodule.c */ #undef STAT #if defined(MS_WIN64) || defined(MS_WIN32) +# define LSTAT _stati64 # define STAT _stati64 # define FSTAT _fstati64 # define STRUCT_STAT struct _stati64 +# define SYNC _flushall #else +# define LSTAT lstat # define STAT stat # define FSTAT fstat # define STRUCT_STAT struct stat +# define SYNC sync #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG @@ -69,6 +75,15 @@ #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) #endif +#if defined(MS_WIN64) || defined(MS_WIN32) +#define S_ISSOCK(mode) (0) +#define S_ISFIFO(mode) (0) +#define S_ISLNK(mode) (0) +#define S_ISLNK(mode) (0) +#define S_ISCHR(mode) (0) +#define S_ISBLK(mode) (0) +#endif + static PyObject *UnknownFileTypeError; static PyObject *c_make_file_dict(PyObject *self, PyObject *args); static PyObject *long2str(PyObject *self, PyObject *args); @@ -90,7 +105,7 @@ static PyObject *c_make_file_dict(self, args) if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; Py_BEGIN_ALLOW_THREADS - res = lstat(filename, &sbuf); + res = LSTAT(filename, &sbuf); Py_END_ALLOW_THREADS if (res != 0) { @@ -225,7 +240,7 @@ static PyObject *my_sync(self, args) PyObject *args; { if (!PyArg_ParseTuple(args, "")) return NULL; - sync(); + SYNC(); return Py_BuildValue(""); } -- cgit v1.2.1