14adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao"""Extended file operations available in POSIX.
24adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
34adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof = posixfile.open(filename, [mode, [bufsize]])
44adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will create a new posixfile object
54adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
64adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof = posixfile.fileopen(fileobject)
74adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will create a posixfile object from a builtin file object
84adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
94adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof.file()
104adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will return the original builtin file object
114adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
124adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof.dup()
134adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will return a new file object based on a new filedescriptor
144adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
154adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof.dup2(fd)
164adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will return a new file object based on the given filedescriptor
174adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
184adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof.flags(mode)
194adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will turn on the associated flag (merge)
204adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      mode can contain the following characters:
214adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
224adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao  (character representing a flag)
234adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      a       append only flag
244adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      c       close on exec flag
254adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      n       no delay flag
264adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      s       synchronization flag
274adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao  (modifiers)
284adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      !       turn flags 'off' instead of default 'on'
294adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      =       copy flags 'as is' instead of default 'merge'
304adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      ?       return a string in which the characters represent the flags
314adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao              that are set
324adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
334adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      note: - the '!' and '=' modifiers are mutually exclusive.
344adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            - the '?' modifier will return the status of the flags after they
354adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao              have been changed by other characters in the mode string
364adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
374adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaof.lock(mode [, len [, start [, whence]]])
384adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      will (un)lock a region
394adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      mode can contain the following characters:
404adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
414adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao  (character representing type of lock)
424adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      u       unlock
434adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      r       read lock
444adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      w       write lock
454adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao  (modifiers)
464adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      |       wait until the lock can be granted
474adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      ?       return the first lock conflicting with the requested lock
484adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao              or 'None' if there is no conflict. The lock returned is in the
494adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao              format (mode, len, start, whence, pid) where mode is a
504adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao              character representing the type of lock ('r' or 'w')
514adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
524adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao      note: - the '?' modifier prevents a region from being locked; it is
534adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao              query only
544adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao"""
554adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaoimport warnings
564adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaowarnings.warn("The posixfile module is deprecated; "
574adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                "fcntl.lockf() provides better locking", DeprecationWarning, 2)
584adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
594adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaoclass _posixfile_:
604adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    """File wrapper class that provides extra POSIX file routines."""
614adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
624adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    states = ['open', 'closed']
634adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
644adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    #
654adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    # Internal routines
664adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    #
674adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def __repr__(self):
684adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        file = self._file_
694adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        return "<%s posixfile '%s', mode '%s' at %s>" % \
704adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                (self.states[file.closed], file.name, file.mode, \
714adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                 hex(id(self))[2:])
724adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
734adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    #
744adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    # Initialization routines
754adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    #
764adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def open(self, name, mode='r', bufsize=-1):
774adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import __builtin__
784adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        return self.fileopen(__builtin__.open(name, mode, bufsize))
794adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
804adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def fileopen(self, file):
814adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import types
824adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if repr(type(file)) != "<type 'file'>":
834adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            raise TypeError, 'posixfile.fileopen() arg must be file object'
844adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        self._file_  = file
854adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        # Copy basic file methods
864adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        for maybemethod in dir(file):
874adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if not maybemethod.startswith('_'):
884adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                attr = getattr(file, maybemethod)
894adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                if isinstance(attr, types.BuiltinMethodType):
904adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    setattr(self, maybemethod, attr)
914adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        return self
924adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
934adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    #
944adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    # New methods
954adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    #
964adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def file(self):
974adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        return self._file_
984adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
994adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def dup(self):
1004adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import posix
1014adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1024adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if not hasattr(posix, 'fdopen'):
1034adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            raise AttributeError, 'dup() method unavailable'
1044adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1054adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        return posix.fdopen(posix.dup(self._file_.fileno()), self._file_.mode)
1064adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1074adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def dup2(self, fd):
1084adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import posix
1094adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1104adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if not hasattr(posix, 'fdopen'):
1114adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            raise AttributeError, 'dup() method unavailable'
1124adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1134adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        posix.dup2(self._file_.fileno(), fd)
1144adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        return posix.fdopen(fd, self._file_.mode)
1154adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1164adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def flags(self, *which):
1174adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import fcntl, os
1184adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1194adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if which:
1204adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if len(which) > 1:
1214adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                raise TypeError, 'Too many arguments'
1224adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            which = which[0]
1234adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        else: which = '?'
1244adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1254adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        l_flags = 0
1264adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if 'n' in which: l_flags = l_flags | os.O_NDELAY
1274adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if 'a' in which: l_flags = l_flags | os.O_APPEND
1284adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if 's' in which: l_flags = l_flags | os.O_SYNC
1294adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1304adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        file = self._file_
1314adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1324adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if '=' not in which:
1334adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
1344adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if '!' in which: l_flags = cur_fl & ~ l_flags
1354adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            else: l_flags = cur_fl | l_flags
1364adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1374adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)
1384adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1394adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if 'c' in which:
1404adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            arg = ('!' not in which)    # 0 is don't, 1 is do close on exec
1414adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
1424adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1434adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if '?' in which:
1444adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            which = ''                  # Return current flags
1454adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
1464adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if os.O_APPEND & l_flags: which = which + 'a'
1474adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
1484adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                which = which + 'c'
1494adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if os.O_NDELAY & l_flags: which = which + 'n'
1504adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if os.O_SYNC & l_flags: which = which + 's'
1514adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            return which
1524adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1534adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    def lock(self, how, *args):
1544adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import struct, fcntl
1554adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1564adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if 'w' in how: l_type = fcntl.F_WRLCK
1574adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif 'r' in how: l_type = fcntl.F_RDLCK
1584adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif 'u' in how: l_type = fcntl.F_UNLCK
1594adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        else: raise TypeError, 'no type of lock specified'
1604adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1614adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if '|' in how: cmd = fcntl.F_SETLKW
1624adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif '?' in how: cmd = fcntl.F_GETLK
1634adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        else: cmd = fcntl.F_SETLK
1644adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1654adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        l_whence = 0
1664adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        l_start = 0
1674adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        l_len = 0
1684adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1694adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if len(args) == 1:
1704adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            l_len = args[0]
1714adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif len(args) == 2:
1724adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            l_len, l_start = args
1734adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif len(args) == 3:
1744adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            l_len, l_start, l_whence = args
1754adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif len(args) > 3:
1764adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            raise TypeError, 'too many arguments'
1774adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1784adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        # Hack by davem@magnet.com to get locking to go on freebsd;
1794adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        # additions for AIX by Vladimir.Marangozov@imag.fr
1804adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        import sys, os
1814adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if sys.platform in ('netbsd1',
1824adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                            'openbsd2',
1834adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                            'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
1844adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                            'freebsd6', 'freebsd7', 'freebsd8',
1854adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                            'bsdos2', 'bsdos3', 'bsdos4'):
1864adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            flock = struct.pack('lxxxxlxxxxlhh', \
1874adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                  l_start, l_len, os.getpid(), l_type, l_whence)
1884adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        elif sys.platform in ('aix3', 'aix4'):
1894adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            flock = struct.pack('hhlllii', \
1904adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                  l_type, l_whence, l_start, l_len, 0, 0, 0)
1914adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        else:
1924adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            flock = struct.pack('hhllhh', \
1934adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                  l_type, l_whence, l_start, l_len, 0, 0)
1944adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1954adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        flock = fcntl.fcntl(self._file_.fileno(), cmd, flock)
1964adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
1974adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao        if '?' in how:
1984adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if sys.platform in ('netbsd1',
1994adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                                'openbsd2',
2004adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                                'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
2014adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                                'bsdos2', 'bsdos3', 'bsdos4'):
2024adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                l_start, l_len, l_pid, l_type, l_whence = \
2034adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    struct.unpack('lxxxxlxxxxlhh', flock)
2044adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            elif sys.platform in ('aix3', 'aix4'):
2054adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \
2064adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    struct.unpack('hhlllii', flock)
2074adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            elif sys.platform == "linux2":
2084adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                l_type, l_whence, l_start, l_len, l_pid, l_sysid = \
2094adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    struct.unpack('hhllhh', flock)
2104adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            else:
2114adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                l_type, l_whence, l_start, l_len, l_sysid, l_pid = \
2124adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    struct.unpack('hhllhh', flock)
2134adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
2144adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao            if l_type != fcntl.F_UNLCK:
2154adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                if l_type == fcntl.F_RDLCK:
2164adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    return 'r', l_len, l_start, l_whence, l_pid
2174adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                else:
2184adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao                    return 'w', l_len, l_start, l_whence, l_pid
2194adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
2204adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaodef open(name, mode='r', bufsize=-1):
2214adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    """Public routine to open a file as a posixfile object."""
2224adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    return _posixfile_().open(name, mode, bufsize)
2234adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
2244adfde8bc82dd39f59e0445588c3e599ada477dJosh Gaodef fileopen(file):
2254adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    """Public routine to get a posixfile object from a Python file object."""
2264adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao    return _posixfile_().fileopen(file)
2274adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
2284adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao#
2294adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao# Constants
2304adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao#
2314adfde8bc82dd39f59e0445588c3e599ada477dJosh GaoSEEK_SET = 0
2324adfde8bc82dd39f59e0445588c3e599ada477dJosh GaoSEEK_CUR = 1
2334adfde8bc82dd39f59e0445588c3e599ada477dJosh GaoSEEK_END = 2
2344adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao
2354adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao#
2364adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao# End of posixfile.py
2374adfde8bc82dd39f59e0445588c3e599ada477dJosh Gao#
238