def Open(self, file_object):
    """Opens the CPIO archive file.

    Args:
      file_object (FileIO): a file-like object.

    Raises:
      IOError: if the file format signature is not supported.
      OSError: if the file format signature is not supported.
    """
    file_object.seek(0, os.SEEK_SET)
    signature_data = file_object.read(6)

    self.file_format = None
    if len(signature_data) > 2:
      if signature_data[:2] == self._CPIO_SIGNATURE_BINARY_BIG_ENDIAN:
        self.file_format = 'bin-big-endian'
      elif signature_data[:2] == self._CPIO_SIGNATURE_BINARY_LITTLE_ENDIAN:
        self.file_format = 'bin-little-endian'
      elif signature_data == self._CPIO_SIGNATURE_PORTABLE_ASCII:
        self.file_format = 'odc'
      elif signature_data == self._CPIO_SIGNATURE_NEW_ASCII:
        self.file_format = 'newc'
      elif signature_data == self._CPIO_SIGNATURE_NEW_ASCII_WITH_CHECKSUM:
        self.file_format = 'crc'

    if self.file_format is None:
      raise IOError('Unsupported CPIO format.')

    self._file_object = file_object
    self._file_size = file_object.get_size()

    self._ReadFileEntries(self._file_object)
def Open ( self , file_object ) : file_object . seek ( 0 , os . SEEK_SET ) signature_data = file_object . read ( 6 ) self . file_format = None if len ( signature_data ) > 2 : if signature_data [ : 2 ] == self . _CPIO_SIGNATURE_BINARY_BIG_ENDIAN : self . file_format = 'bin-big-endian' elif signature_data [ : 2 ] == self . _CPIO_SIGNATURE_BINARY_LITTLE_ENDIAN : self . file_format = 'bin-little-endian' elif signature_data == self . _CPIO_SIGNATURE_PORTABLE_ASCII : self . file_format = 'odc' elif signature_data == self . _CPIO_SIGNATURE_NEW_ASCII : self . file_format = 'newc' elif signature_data == self . _CPIO_SIGNATURE_NEW_ASCII_WITH_CHECKSUM : self . file_format = 'crc' if self . file_format is None : raise IOError ( 'Unsupported CPIO format.' ) self . _file_object = file_object self . _file_size = file_object . get_size ( ) self . _ReadFileEntries ( self . _file_object )
Opens the CPIO archive file.

    Args:
      file_object (FileIO): a file-like object.

    Raises:
      IOError: if the file format signature is not supported.
      OSError: if the file format signature is not supported.