(self, fhandle, filetype, number, mode, seg, offset, length, locks)
Initialise program file object and write header.
Initialise program file object and write header.
Initialise program file object and write header .
def __init__(self, fhandle, filetype, number, mode, seg, offset, length, locks):
        """Initialise program file object and write header."""
        RawFile.__init__(self, fhandle, filetype, mode)
        # don't lock binary files
        # we need the Locks object to register file as open
        self._locks = locks
        self._number = number
        # binary file parameters
        self.seg, self.offset, self.length = 0, 0, 0
        if self.mode == b'O':
            self.write(TYPE_TO_MAGIC[filetype])
            if self.filetype == b'M':
                self.write(struct.pack(b'<HHH', seg, offset, length))
                self.seg, self.offset, self.length = seg, offset, length
        else:
            # drop magic byte
            self.read(1)
            if self.filetype == b'M':
                # self.length gets ignored: even the \x1a at the end is read
                header = self.read(6)
                if len(header) == 6:
                    self.seg, self.offset, self.length = struct.unpack('<HHH', header)
                else:
                    # truncated header
                    raise error.BASICError(error.BAD_FILE_MODE)
def __init__ ( self , fhandle , filetype , number , mode , seg , offset , length , locks ) : RawFile . __init__ ( self , fhandle , filetype , mode ) # don't lock binary files # we need the Locks object to register file as open self . _locks = locks self . _number = number # binary file parameters self . seg , self . offset , self . length = 0 , 0 , 0 if self . mode == b'O' : self . write ( TYPE_TO_MAGIC [ filetype ] ) if self . filetype == b'M' : self . write ( struct . pack ( b'<HHH' , seg , offset , length ) ) self . seg , self . offset , self . length = seg , offset , length else : # drop magic byte self . read ( 1 ) if self . filetype == b'M' : # self.length gets ignored: even the \x1a at the end is read header = self . read ( 6 ) if len ( header ) == 6 : self . seg , self . offset , self . length = struct . unpack ( '<HHH' , header ) else : # truncated header raise error . BASICError ( error . BAD_FILE_MODE )