131
132
self._translate_error(e, path)
133
134
def put(self, relpath, f, mode=None):
134
"""Copy the file-like or string object into the location.
135
"""Copy the file-like object into the location.
136
137
:param relpath: Location to put the contents, relative to base.
137
:param f: File-like or string object.
138
:param f: File-like object.
139
:param mode: The mode for the newly created file,
140
None means just use the default
139
142
from bzrlib.atomicfile import AtomicFile
157
def non_atomic_put(self, relpath, f, mode=None):
158
"""Copy the file-like object into the target location.
160
This function is not strictly safe to use. It is only meant to
161
be used when you already know that the target does not exist.
162
It is not safe, because it will open and truncate the remote
163
file. So there may be a time when the file has invalid contents.
165
:param relpath: The remote location to put the contents.
166
:param f: File-like object.
167
:param mode: Possible access permissions for new file.
168
None means do not set remote permissions.
170
abspath = self._abspath(relpath)
172
# os.open() will automatically use the umask
177
fd = os.open(abspath, _non_atomic_put_flags, local_mode)
178
except (IOError, OSError),e:
179
self._translate_error(e, relpath)
182
if mode is not None and mode != S_IMODE(st.st_mode):
183
# Because of umask, we may still need to chmod the file.
184
# But in the general case, we won't have to
185
os.chmod(abspath, mode)
186
self._pump_to_fd(f, fd)
154
190
def iter_files_recursive(self):
155
191
"""Iter the relative paths of files in the transports sub-tree."""
156
192
queue = list(self.list_dir(u'.'))