summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/rpath.py
diff options
context:
space:
mode:
authorjoshn <joshn@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2009-06-04 23:50:58 +0000
committerjoshn <joshn@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2009-06-04 23:50:58 +0000
commit55a4a7d925ab079617e74113d448f4540661e317 (patch)
treecf7eb6eae3a08893702c4ca5bccd3198df25171e /rdiff-backup/rdiff_backup/rpath.py
parent2717ce34a4c17ad87b021a0a51be89164ef7a2c3 (diff)
downloadrdiff-backup-55a4a7d925ab079617e74113d448f4540661e317.tar.gz
Gah. Fix unicode support for linux systems where the destination Python installation doesn't support unicode filenames.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@1057 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/rpath.py')
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index ed64cf0..8b0ecd4 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -1417,19 +1417,24 @@ class RPath(RORPath):
write_win_acl(self, acl)
self.data['win_acl'] = acl
-class UnicodeFile:
- """ Wraps a RPath and reads/writes unicode. """
+class MaybeUnicode:
+ """ Wraps a RPath and reads/writes unicode if Globals.use_unicode_paths is on. """
def __init__(self, fileobj):
self.fileobj = fileobj
def read(self, length = -1):
- return unicode(self.fileobj.read(length), 'utf-8')
+ data = self.fileobj.read(length)
+ if Globals.use_unicode_paths:
+ data = unicode(data, 'utf-8')
+ return data
def write(self, buf):
- if type(buf) != unicode:
- buf = unicode(buf, 'utf-8')
- return self.fileobj.write(buf.encode('utf-8'))
+ if Globals.use_unicode_paths:
+ if type(buf) != unicode:
+ buf = unicode(buf, 'utf-8')
+ buf = buf.encode('utf-8')
+ return self.fileobj.write(buf)
def close(self):
return self.fileobj.close()
@@ -1463,7 +1468,7 @@ class GzipFile(gzip.GzipFile):
unicode with the filename."""
if mode and 'b' not in mode:
mode += 'b'
- if type(filename) != unicode:
+ if type(filename) != unicode and Globals.use_unicode_paths:
filename = unicode(filename, 'utf-8')
fileobj = open(filename, mode or 'rb')
gzip.GzipFile.__init__(self, filename.encode('utf-8'),