summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/rpath.py
diff options
context:
space:
mode:
authorjoshn <joshn@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2009-04-18 21:54:18 +0000
committerjoshn <joshn@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2009-04-18 21:54:18 +0000
commite4ee35cf4556f20f0be75474b3c57b14beae965d (patch)
tree77ba0b5ba1a9ac36e4928523173947b25e11cf70 /rdiff-backup/rdiff_backup/rpath.py
parente4c108ce309ff198af46f99acfdd1ef95d90acec (diff)
downloadrdiff-backup-e4ee35cf4556f20f0be75474b3c57b14beae965d.tar.gz
Some older systems don't support unicode, so check for support before using it.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@1054 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/rpath.py')
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index 3fc432b..ed64cf0 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -309,23 +309,23 @@ def make_file_dict_python(filename):
data = {}
mode = statblock[stat.ST_MODE]
- if stat.S_ISREG(mode): type = 'reg'
- elif stat.S_ISDIR(mode): type = 'dir'
+ if stat.S_ISREG(mode): type_ = 'reg'
+ elif stat.S_ISDIR(mode): type_ = 'dir'
elif stat.S_ISCHR(mode):
- type = 'dev'
+ type_ = 'dev'
s = statblock.st_rdev
data['devnums'] = ('c',) + (s >> 8, s & 0xff)
elif stat.S_ISBLK(mode):
- type = 'dev'
+ type_ = 'dev'
s = statblock.st_rdev
data['devnums'] = ('b',) + (s >> 8, s & 0xff)
- elif stat.S_ISFIFO(mode): type = 'fifo'
+ elif stat.S_ISFIFO(mode): type_ = 'fifo'
elif stat.S_ISLNK(mode):
- type = 'sym'
+ type_ = 'sym'
data['linkname'] = os.readlink(filename)
- elif stat.S_ISSOCK(mode): type = 'sock'
+ elif stat.S_ISSOCK(mode): type_ = 'sock'
else: raise C.UnknownFileError(filename)
- data['type'] = type
+ data['type'] = type_
data['size'] = statblock[stat.ST_SIZE]
data['perms'] = stat.S_IMODE(mode)
data['uid'] = statblock[stat.ST_UID]
@@ -335,12 +335,16 @@ def make_file_dict_python(filename):
data['nlink'] = statblock[stat.ST_NLINK]
if os.name == 'nt':
- attribs = win32file.GetFileAttributesW(filename)
+ global type
+ if type(filename) == unicode:
+ attribs = win32file.GetFileAttributesW(filename)
+ else:
+ attribs = win32file.GetFileAttributes(filename)
if attribs & winnt.FILE_ATTRIBUTE_REPARSE_POINT:
data['type'] = 'sym'
data['linkname'] = None
- if not (type == 'sym' or type == 'dev'):
+ if not (type_ == 'sym' or type_ == 'dev'):
# mtimes on symlinks and dev files don't work consistently
data['mtime'] = long(statblock[stat.ST_MTIME])
data['atime'] = long(statblock[stat.ST_ATIME])
@@ -1000,7 +1004,7 @@ class RPath(RORPath):
path = self.path
# Use pass in unicode to os.listdir, so that the returned
# entries are in unicode.
- if type(path) != unicode:
+ if type(path) != unicode and Globals.use_unicode_paths:
path = unicode(path, 'utf-8')
return self.conn.os.listdir(path)