Commit 6829f99a by willmcgugan@gmail.com

createfile fixes

parent cbcad9d0
......@@ -895,12 +895,12 @@ class FS(object):
:param wipe: if True, the contents of the file will be erased
"""
with self._lock:
if not wipe and self.isfile(path):
return
f = None
try:
f = self.open(path, 'w')
f = self.open(path, 'wb')
finally:
if f is not None:
f.close()
......
......@@ -192,6 +192,8 @@ def pathcombine(path1, path2):
'foo/bar/baz'
"""
if not path1:
return path2.lstrip()
return "%s/%s" % (path1.rstrip('/'), path2.lstrip('/'))
......
......@@ -103,6 +103,7 @@ class RemoteFileBuffer(FileWrapper):
# Do not use remote file object
self._eof = True
self._rfile = None
self._changed = True
if rfile is not None and hasattr(rfile,"close"):
rfile.close()
super(RemoteFileBuffer,self).__init__(wrapped_file,mode)
......
......@@ -30,6 +30,9 @@ class RemoteTempFS(TempFS):
Simple filesystem implementing setfilecontents
for RemoteFileBuffer tests
"""
def __repr__(self):
return '<RemoteTempFS: %s>' % self._temp_dir
def open(self, path, mode='rb', write_on_flush=True, **kwargs):
if 'a' in mode or 'r' in mode or '+' in mode:
f = super(RemoteTempFS, self).open(path, mode='rb', **kwargs)
......
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