summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2015-05-31 17:57:45 +0200
committerThomas Waldmann <tw@waldmann-edv.de>2015-05-31 17:57:45 +0200
commit926454c0d826d41e49c69e52a0d3573f08e1f219 (patch)
tree7a8deb61eaf783ccda65286960d3ec350d995996
parent776bb9fabc4806be9858ff960040e7be2002b5c9 (diff)
explicitely specify binary mode to open binary files
on POSIX OSes, it doesn't make a difference, but it is cleaner and also good for portability.
-rw-r--r--borg/_hashindex.c4
-rw-r--r--borg/cache.py2
-rw-r--r--borg/testsuite/archiver.py4
3 files changed, 5 insertions, 5 deletions
diff --git a/borg/_hashindex.c b/borg/_hashindex.c
index 591f5c9f6..e2589d0b8 100644
--- a/borg/_hashindex.c
+++ b/borg/_hashindex.c
@@ -136,7 +136,7 @@ hashindex_read(const char *path)
HashHeader header;
HashIndex *index = NULL;
- if((fd = fopen(path, "r")) == NULL) {
+ if((fd = fopen(path, "rb")) == NULL) {
EPRINTF_PATH(path, "fopen for reading failed");
return NULL;
}
@@ -260,7 +260,7 @@ hashindex_write(HashIndex *index, const char *path)
};
int ret = 1;
- if((fd = fopen(path, "w")) == NULL) {
+ if((fd = fopen(path, "wb")) == NULL) {
EPRINTF_PATH(path, "fopen for writing failed");
return 0;
}
diff --git a/borg/cache.py b/borg/cache.py
index 037a8e76b..573a7f5cc 100644
--- a/borg/cache.py
+++ b/borg/cache.py
@@ -93,7 +93,7 @@ class Cache:
with open(os.path.join(self.path, 'config'), 'w') as fd:
config.write(fd)
ChunkIndex().write(os.path.join(self.path, 'chunks').encode('utf-8'))
- with open(os.path.join(self.path, 'files'), 'w') as fd:
+ with open(os.path.join(self.path, 'files'), 'wb') as fd:
pass # empty file
def destroy(self):
diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py
index 11efefd3d..b35df2477 100644
--- a/borg/testsuite/archiver.py
+++ b/borg/testsuite/archiver.py
@@ -400,9 +400,9 @@ class ArchiverTestCase(ArchiverTestCaseBase):
self.cmd('extract', '--dry-run', self.repository_location + '::test')
self.cmd('check', self.repository_location)
name = sorted(os.listdir(os.path.join(self.tmpdir, 'repository', 'data', '0')), reverse=True)[0]
- with open(os.path.join(self.tmpdir, 'repository', 'data', '0', name), 'r+') as fd:
+ with open(os.path.join(self.tmpdir, 'repository', 'data', '0', name), 'r+b') as fd:
fd.seek(100)
- fd.write('XXXX')
+ fd.write(b'XXXX')
self.cmd('check', self.repository_location, exit_code=1)
def test_readonly_repository(self):