mercurial/win32.py
changeset 8421 b6d0fa8c7685
parent 8329 79a12651d46b
child 8656 284fda4cd093
--- a/mercurial/win32.py	Thu May 14 14:12:32 2009 -0700
+++ b/mercurial/win32.py	Wed May 13 21:36:16 2009 +0200
@@ -264,114 +264,6 @@
     return [os.path.join(userdir, 'mercurial.ini'),
             os.path.join(userdir, '.hgrc')]
 
-class posixfile_nt(object):
-    '''file object with posix-like semantics.  on windows, normal
-    files can not be deleted or renamed if they are open. must open
-    with win32file.FILE_SHARE_DELETE. this flag does not exist on
-    windows < nt, so do not use this class there.'''
-
-    # ideally, we could use win32file._open_osfhandle and avoid this
-    # class entirely, but we would need the win32 _fdopen function,
-    # which is not exported by the win32file module.
-
-    def __init__(self, name, mode='rb'):
-        self.closed = False
-        self.name = name
-        self.mode = mode
-        access = 0
-        if 'r' in mode or '+' in mode:
-            access |= win32file.GENERIC_READ
-        if 'w' in mode or 'a' in mode or '+' in mode:
-            access |= win32file.GENERIC_WRITE
-        if 'r' in mode:
-            creation = win32file.OPEN_EXISTING
-        elif 'a' in mode:
-            creation = win32file.OPEN_ALWAYS
-        else:
-            creation = win32file.CREATE_ALWAYS
-        try:
-            self.handle = win32file.CreateFile(name,
-                                               access,
-                                               win32file.FILE_SHARE_READ |
-                                               win32file.FILE_SHARE_WRITE |
-                                               win32file.FILE_SHARE_DELETE,
-                                               None,
-                                               creation,
-                                               win32file.FILE_ATTRIBUTE_NORMAL,
-                                               0)
-        except pywintypes.error, err:
-            raise WinIOError(err, name)
-
-    def __iter__(self):
-        for line in self.readlines():
-            yield line
-
-    def read(self, count=-1):
-        try:
-            cs = cStringIO.StringIO()
-            while count:
-                wincount = int(count)
-                if wincount == -1:
-                    wincount = 1048576
-                val, data = win32file.ReadFile(self.handle, wincount)
-                if not data: break
-                cs.write(data)
-                if count != -1:
-                    count -= len(data)
-            return cs.getvalue()
-        except pywintypes.error, err:
-            raise WinIOError(err)
-
-    def readlines(self, sizehint=None):
-        # splitlines() splits on single '\r' while readlines()
-        # does not. cStringIO has a well behaving readlines() and is fast.
-        return cStringIO.StringIO(self.read()).readlines()
-
-    def write(self, data):
-        try:
-            if 'a' in self.mode:
-                win32file.SetFilePointer(self.handle, 0, win32file.FILE_END)
-            nwrit = 0
-            while nwrit < len(data):
-                val, nwrit = win32file.WriteFile(self.handle, data)
-                data = data[nwrit:]
-        except pywintypes.error, err:
-            raise WinIOError(err)
-
-    def writelines(self, sequence):
-        for s in sequence:
-            self.write(s)
-
-    def seek(self, pos, whence=0):
-        try:
-            win32file.SetFilePointer(self.handle, int(pos), whence)
-        except pywintypes.error, err:
-            raise WinIOError(err)
-
-    def tell(self):
-        try:
-            return win32file.SetFilePointer(self.handle, 0,
-                                            win32file.FILE_CURRENT)
-        except pywintypes.error, err:
-            raise WinIOError(err)
-
-    def close(self):
-        if not self.closed:
-            self.handle = None
-            self.closed = True
-
-    def flush(self):
-        # we have no application-level buffering
-        pass
-
-    def truncate(self, pos=0):
-        try:
-            win32file.SetFilePointer(self.handle, int(pos),
-                                     win32file.FILE_BEGIN)
-            win32file.SetEndOfFile(self.handle)
-        except pywintypes.error, err:
-            raise WinIOError(err)
-
 def getuser():
     '''return name of current user'''
     return win32api.GetUserName()