121
121
except (IOError, OSError),e:
122
122
self._translate_error(e, path)
124
def put(self, relpath, f, mode=None):
124
def put(self, relpath, f, mode=0666):
125
125
"""Copy the file-like or string object into the location.
127
127
:param relpath: Location to put the contents, relative to base.
165
165
except (IOError, OSError),e:
166
166
self._translate_error(e, path)
168
def append(self, relpath, f, mode=None):
168
def append(self, relpath, f, mode=0666):
169
169
"""Append the text in the file-like object into the final location."""
170
170
abspath = self._abspath(relpath)
172
fp = open(abspath, 'ab')
173
# FIXME should we really be chmodding every time ? RBC 20060523
175
os.chmod(abspath, mode)
172
fd = os.open(abspath, os.O_CREAT | os.O_APPEND | os.O_WRONLY, mode)
176
173
except (IOError, OSError),e:
177
174
self._translate_error(e, relpath)
178
# win32 workaround (tell on an unwritten file returns 0)
176
result = os.lseek(fd, 0, 2)
177
# TODO: make a raw FD version of _pump ?
178
self._pump_to_fd(f, fd)
183
def _pump_to_fd(self, fromfile, to_fd):
184
"""Copy contents of one file to another."""
187
b = fromfile.read(BUFSIZE)
184
192
def copy(self, rel_from, rel_to):
185
193
"""Copy the item at rel_from to the location at rel_to"""
186
194
path_from = self._abspath(rel_from)