Show More
@@ -1005,7 +1005,7 b' def opener(base, audit=True):' | |||||
1005 | p = base |
|
1005 | p = base | |
1006 | audit_p = audit |
|
1006 | audit_p = audit | |
1007 |
|
1007 | |||
1008 | def mktempcopy(name): |
|
1008 | def mktempcopy(name, emptyok=False): | |
1009 | d, fn = os.path.split(name) |
|
1009 | d, fn = os.path.split(name) | |
1010 | fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d) |
|
1010 | fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d) | |
1011 | os.close(fd) |
|
1011 | os.close(fd) | |
@@ -1019,6 +1019,8 b' def opener(base, audit=True):' | |||||
1019 | raise |
|
1019 | raise | |
1020 | st_mode = 0666 & ~_umask |
|
1020 | st_mode = 0666 & ~_umask | |
1021 | os.chmod(temp, st_mode) |
|
1021 | os.chmod(temp, st_mode) | |
|
1022 | if emptyok: | |||
|
1023 | return temp | |||
1022 | try: |
|
1024 | try: | |
1023 | try: |
|
1025 | try: | |
1024 | ifp = posixfile(name, "rb") |
|
1026 | ifp = posixfile(name, "rb") | |
@@ -1043,7 +1045,7 b' def opener(base, audit=True):' | |||||
1043 | """the file will only be copied when rename is called""" |
|
1045 | """the file will only be copied when rename is called""" | |
1044 | def __init__(self, name, mode): |
|
1046 | def __init__(self, name, mode): | |
1045 | self.__name = name |
|
1047 | self.__name = name | |
1046 | self.temp = mktempcopy(name) |
|
1048 | self.temp = mktempcopy(name, emptyok=('w' in mode)) | |
1047 | posixfile.__init__(self, self.temp, mode) |
|
1049 | posixfile.__init__(self, self.temp, mode) | |
1048 | def rename(self): |
|
1050 | def rename(self): | |
1049 | if not self.closed: |
|
1051 | if not self.closed: |
General Comments 0
You need to be logged in to leave comments.
Login now