mercurial/util_win32.py
changeset 5848 e90a7a3c28a4
parent 5847 e52383c7e7ab
parent 5840 c67dfc4ecba6
child 5895 f1ac41359b36
equal deleted inserted replaced
5847:e52383c7e7ab 5848:e90a7a3c28a4
   225 
   225 
   226     # tried to use win32file._open_osfhandle to pass fd to os.fdopen,
   226     # tried to use win32file._open_osfhandle to pass fd to os.fdopen,
   227     # but does not work at all. wrap win32 file api instead.
   227     # but does not work at all. wrap win32 file api instead.
   228 
   228 
   229     def __init__(self, name, mode='rb'):
   229     def __init__(self, name, mode='rb'):
       
   230         self.closed = False
       
   231         self.name = name
       
   232         self.mode = mode
   230         access = 0
   233         access = 0
   231         if 'r' in mode or '+' in mode:
   234         if 'r' in mode or '+' in mode:
   232             access |= win32file.GENERIC_READ
   235             access |= win32file.GENERIC_READ
   233         if 'w' in mode or 'a' in mode or '+' in mode:
   236         if 'w' in mode or 'a' in mode or '+' in mode:
   234             access |= win32file.GENERIC_WRITE
   237             access |= win32file.GENERIC_WRITE
   248                                                creation,
   251                                                creation,
   249                                                win32file.FILE_ATTRIBUTE_NORMAL,
   252                                                win32file.FILE_ATTRIBUTE_NORMAL,
   250                                                0)
   253                                                0)
   251         except pywintypes.error, err:
   254         except pywintypes.error, err:
   252             raise WinIOError(err, name)
   255             raise WinIOError(err, name)
   253         self.closed = False
       
   254         self.name = name
       
   255         self.mode = mode
       
   256 
   256 
   257     def __iter__(self):
   257     def __iter__(self):
   258         for line in self.read().splitlines(True):
   258         for line in self.read().splitlines(True):
   259             yield line
   259             yield line
   260 
   260