Show More
@@ -279,37 +279,38 b' class vfs(abstractvfs):' | |||||
279 | mode += "b" # for that other OS |
|
279 | mode += "b" # for that other OS | |
280 |
|
280 | |||
281 | nlink = -1 |
|
281 | nlink = -1 | |
282 | dirname, basename = util.split(f) |
|
282 | if mode not in ('r', 'rb'): | |
283 | # If basename is empty, then the path is malformed because it points |
|
283 | dirname, basename = util.split(f) | |
284 | # to a directory. Let the posixfile() call below raise IOError. |
|
284 | # If basename is empty, then the path is malformed because it points | |
285 | if basename and mode not in ('r', 'rb'): |
|
285 | # to a directory. Let the posixfile() call below raise IOError. | |
286 |
if |
|
286 | if basename: | |
287 |
if |
|
287 | if atomictemp: | |
288 |
|
|
288 | if not os.path.isdir(dirname): | |
289 |
|
|
289 | util.makedirs(dirname, self.createmode) | |
290 | try: |
|
290 | return util.atomictempfile(f, mode, self.createmode) | |
291 |
|
|
291 | try: | |
292 |
|
|
292 | if 'w' in mode: | |
|
293 | util.unlink(f) | |||
|
294 | nlink = 0 | |||
|
295 | else: | |||
|
296 | # nlinks() may behave differently for files on Windows | |||
|
297 | # shares if the file is open. | |||
|
298 | fd = util.posixfile(f) | |||
|
299 | nlink = util.nlinks(f) | |||
|
300 | if nlink < 1: | |||
|
301 | nlink = 2 # force mktempcopy (issue1922) | |||
|
302 | fd.close() | |||
|
303 | except (OSError, IOError), e: | |||
|
304 | if e.errno != errno.ENOENT: | |||
|
305 | raise | |||
293 | nlink = 0 |
|
306 | nlink = 0 | |
294 | else: |
|
307 | if not os.path.isdir(dirname): | |
295 | # nlinks() may behave differently for files on Windows |
|
308 | util.makedirs(dirname, self.createmode) | |
296 | # shares if the file is open. |
|
309 | if nlink > 0: | |
297 | fd = util.posixfile(f) |
|
310 | if self._trustnlink is None: | |
298 |
nlink = util.nlink |
|
311 | self._trustnlink = nlink > 1 or util.checknlink(f) | |
299 |
if nlink |
|
312 | if nlink > 1 or not self._trustnlink: | |
300 |
|
|
313 | util.rename(util.mktempcopy(f), f) | |
301 | fd.close() |
|
|||
302 | except (OSError, IOError), e: |
|
|||
303 | if e.errno != errno.ENOENT: |
|
|||
304 | raise |
|
|||
305 | nlink = 0 |
|
|||
306 | if not os.path.isdir(dirname): |
|
|||
307 | util.makedirs(dirname, self.createmode) |
|
|||
308 | if nlink > 0: |
|
|||
309 | if self._trustnlink is None: |
|
|||
310 | self._trustnlink = nlink > 1 or util.checknlink(f) |
|
|||
311 | if nlink > 1 or not self._trustnlink: |
|
|||
312 | util.rename(util.mktempcopy(f), f) |
|
|||
313 | fp = util.posixfile(f, mode) |
|
314 | fp = util.posixfile(f, mode) | |
314 | if nlink == 0: |
|
315 | if nlink == 0: | |
315 | self._fixfilemode(f) |
|
316 | self._fixfilemode(f) |
General Comments 0
You need to be logged in to leave comments.
Login now