Commit da6d8bb6 authored by owsla's avatar owsla

Use the Python os.lstat() on Windows. (Patch from Josh Nisly)


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@905 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 343b8424
New in v1.1.17 (????/??/??) New in v1.1.17 (????/??/??)
--------------------------- ---------------------------
Use the Python os.lstat() on Windows. (Patch from Josh Nisly)
Support for Windows ACLs. (Patch from Josh Nisly and Fred Gansevles) Support for Windows ACLs. (Patch from Josh Nisly and Fred Gansevles)
Fix user_group.py to run on native Windows, which lacks grp and pwd Python Fix user_group.py to run on native Windows, which lacks grp and pwd Python
......
...@@ -48,10 +48,6 @@ ...@@ -48,10 +48,6 @@
/* This code taken from Python's posixmodule.c */ /* This code taken from Python's posixmodule.c */
#undef STAT #undef STAT
#if defined(MS_WIN64) || defined(MS_WIN32) #if defined(MS_WIN64) || defined(MS_WIN32)
# define LSTAT _stati64
# define STAT _stati64
# define FSTAT _fstati64
# define STRUCT_STAT struct _stati64
# define SYNC _flushall # define SYNC _flushall
#else #else
# define LSTAT lstat # define LSTAT lstat
...@@ -77,15 +73,6 @@ ...@@ -77,15 +73,6 @@
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#endif #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 *UnknownFileTypeError;
static PyObject *c_make_file_dict(PyObject *self, PyObject *args); static PyObject *c_make_file_dict(PyObject *self, PyObject *args);
static PyObject *long2str(PyObject *self, PyObject *args); static PyObject *long2str(PyObject *self, PyObject *args);
...@@ -98,6 +85,10 @@ static PyObject *c_make_file_dict(self, args) ...@@ -98,6 +85,10 @@ static PyObject *c_make_file_dict(self, args)
PyObject *self; PyObject *self;
PyObject *args; PyObject *args;
{ {
#if defined(MS_WINDOWS)
PyErr_SetString(PyExc_AttributeError, "This function is not implemented on Windows.");
return NULL;
#else
PyObject *size, *inode, *mtime, *atime, *ctime, *devloc, *return_val; PyObject *size, *inode, *mtime, *atime, *ctime, *devloc, *return_val;
char *filename, filetype[5]; char *filename, filetype[5];
STRUCT_STAT sbuf; STRUCT_STAT sbuf;
...@@ -118,10 +109,7 @@ static PyObject *c_make_file_dict(self, args) ...@@ -118,10 +109,7 @@ static PyObject *c_make_file_dict(self, args)
return NULL; return NULL;
} }
} }
#if defined(MS_WINDOWS)
size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size);
inode = PyLong_FromLongLong((PY_LONG_LONG)-1);
#else
#ifdef HAVE_LARGEFILE_SUPPORT #ifdef HAVE_LARGEFILE_SUPPORT
size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size); size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size);
inode = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_ino); inode = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_ino);
...@@ -129,10 +117,9 @@ static PyObject *c_make_file_dict(self, args) ...@@ -129,10 +117,9 @@ static PyObject *c_make_file_dict(self, args)
size = PyInt_FromLong(sbuf.st_size); size = PyInt_FromLong(sbuf.st_size);
inode = PyInt_FromLong((long)sbuf.st_ino); inode = PyInt_FromLong((long)sbuf.st_ino);
#endif /* HAVE_LARGEFILE_SUPPORT */ #endif /* HAVE_LARGEFILE_SUPPORT */
#endif /* defined(MS_WINDOWS) */
mode = (long)sbuf.st_mode; mode = (long)sbuf.st_mode;
perms = mode & 07777; perms = mode & 07777;
#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) #if defined(HAVE_LONG_LONG)
devloc = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_dev); devloc = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_dev);
#else #else
devloc = PyInt_FromLong((long)sbuf.st_dev); devloc = PyInt_FromLong((long)sbuf.st_dev);
...@@ -189,7 +176,7 @@ static PyObject *c_make_file_dict(self, args) ...@@ -189,7 +176,7 @@ static PyObject *c_make_file_dict(self, args)
} else if (S_ISCHR(mode) || S_ISBLK(mode)) { } else if (S_ISCHR(mode) || S_ISBLK(mode)) {
/* Device files */ /* Device files */
char devtype[2]; char devtype[2];
#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) #if defined(HAVE_LONG_LONG)
PY_LONG_LONG devnums = (PY_LONG_LONG)sbuf.st_rdev; PY_LONG_LONG devnums = (PY_LONG_LONG)sbuf.st_rdev;
PyObject *major_num = PyLong_FromLongLong(major(devnums)); PyObject *major_num = PyLong_FromLongLong(major(devnums));
#else #else
...@@ -223,6 +210,7 @@ static PyObject *c_make_file_dict(self, args) ...@@ -223,6 +210,7 @@ static PyObject *c_make_file_dict(self, args)
Py_DECREF(atime); Py_DECREF(atime);
Py_DECREF(ctime); Py_DECREF(ctime);
return return_val; return return_val;
#endif /* defined(MS_WINDOWS) */
} }
/* Convert python long into 7 byte string */ /* Convert python long into 7 byte string */
......
...@@ -246,7 +246,7 @@ def rename(rp_source, rp_dest): ...@@ -246,7 +246,7 @@ def rename(rp_source, rp_dest):
if not rp_source.lstat(): rp_dest.delete() if not rp_source.lstat(): rp_dest.delete()
else: else:
if rp_dest.lstat() and rp_source.getinode() == rp_dest.getinode() and \ if rp_dest.lstat() and rp_source.getinode() == rp_dest.getinode() and \
rp_source.getinode() != -1: rp_source.getinode() != 0:
log.Log("Warning: Attempt to rename over same inode: %s to %s" log.Log("Warning: Attempt to rename over same inode: %s to %s"
% (rp_source.path, rp_dest.path), 2) % (rp_source.path, rp_dest.path), 2)
# You can't rename one hard linked file over another # You can't rename one hard linked file over another
...@@ -824,10 +824,13 @@ class RPath(RORPath): ...@@ -824,10 +824,13 @@ class RPath(RORPath):
def setdata(self): def setdata(self):
"""Set data dictionary using C extension""" """Set data dictionary using C extension"""
self.data = self.conn.C.make_file_dict(self.path) try:
self.data = self.conn.C.make_file_dict(self.path)
except AttributeError:
self.data = self.make_file_dict_python()
if self.lstat(): self.conn.rpath.setdata_local(self) if self.lstat(): self.conn.rpath.setdata_local(self)
def make_file_dict_old(self): def make_file_dict_python(self):
"""Create the data dictionary""" """Create the data dictionary"""
statblock = self.conn.rpath.tupled_lstat(self.path) statblock = self.conn.rpath.tupled_lstat(self.path)
if statblock is None: if statblock is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment