##// END OF EJS Templates
windows: seek to the end of posixfile when opening in append mode...
Matt Harbison -
r24051:7956d174 default
parent child Browse files
Show More
@@ -26,11 +26,19 b' testpid = win32.testpid'
26 unlink = win32.unlink
26 unlink = win32.unlink
27
27
28 umask = 0022
28 umask = 0022
29 _SEEK_END = 2 # os.SEEK_END was introduced in Python 2.5
29
30
30 # wrap osutil.posixfile to provide friendlier exceptions
31 # wrap osutil.posixfile to provide friendlier exceptions
31 def posixfile(name, mode='r', buffering=-1):
32 def posixfile(name, mode='r', buffering=-1):
32 try:
33 try:
33 return osutil.posixfile(name, mode, buffering)
34 fp = osutil.posixfile(name, mode, buffering)
35
36 # The position when opening in append mode is implementation defined, so
37 # make it consistent with other platforms, which position at EOF.
38 if 'a' in mode:
39 fp.seek(0, _SEEK_END)
40
41 return fp
34 except WindowsError, err:
42 except WindowsError, err:
35 raise IOError(err.errno, '%s: %s' % (name, err.strerror))
43 raise IOError(err.errno, '%s: %s' % (name, err.strerror))
36 posixfile.__doc__ = osutil.posixfile.__doc__
44 posixfile.__doc__ = osutil.posixfile.__doc__
General Comments 0
You need to be logged in to leave comments. Login now