Code
stringlengths
103
85.9k
Summary
sequencelengths
0
94
Please provide a description of the function:def set_extent_location(self, extent): # type: (int) -> None ''' A method to set the new location for this UDF BEA Volume Structure. Parameters: extent - The new extent location to set for this UDF BEA Volume Structure. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') self.new_extent_loc = extent
[]
Please provide a description of the function:def parse(self, data, extent): # type: (bytes, int) -> None ''' Parse the passed in data into a UDF NSR Volume Structure. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure already initialized') (structure_type, self.standard_ident, structure_version, reserved_unused) = struct.unpack_from(self.FMT, data, 0) if structure_type != 0: raise pycdlibexception.PyCdlibInvalidISO('Invalid structure type') if self.standard_ident not in [b'NSR02', b'NSR03']: raise pycdlibexception.PyCdlibInvalidISO('Invalid standard identifier') if structure_version != 1: raise pycdlibexception.PyCdlibInvalidISO('Invalid structure version') self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF NSR Volume Structure. Parameters: None. Returns: A string representing this UDF BEA Volume Strucutre. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure not initialized') return struct.pack(self.FMT, 0, self.standard_ident, 1, b'\x00' * 2041)
[]
Please provide a description of the function:def new(self, version): # type: () -> None ''' A method to create a new UDF NSR Volume Structure. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure already initialized') if version == 2: self.standard_ident = b'NSR02' elif version == 3: self.standard_ident = b'NSR03' else: raise pycdlibexception.PyCdlibInternalError('Invalid NSR version requested') self._initialized = True
[]
Please provide a description of the function:def extent_location(self): # type: () -> int ''' A method to get the extent location of this UDF NSR Volume Structure. Parameters: None. Returns: Integer extent location of this UDF NSR Volume Structure. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure not yet initialized') if self.new_extent_loc < 0: return self.orig_extent_loc return self.new_extent_loc
[]
Please provide a description of the function:def parse(self, data, extent): # type: (bytes, int) -> None ''' Parse the passed in data into a UDF Descriptor tag. Parameters: data - The data to parse. extent - The extent to compare against for the tag location. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Tag already initialized') (self.tag_ident, self.desc_version, tag_checksum, reserved, self.tag_serial_number, desc_crc, self.desc_crc_length, self.tag_location) = struct.unpack_from(self.FMT, data, 0) if reserved != 0: raise pycdlibexception.PyCdlibInvalidISO('Reserved data not 0!') if _compute_csum(data[:16]) != tag_checksum: raise pycdlibexception.PyCdlibInvalidISO('Tag checksum does not match!') if self.tag_location != extent: # In theory, we should abort (throw an exception) if we see that a # tag location that doesn't match an actual location. However, we # have seen UDF ISOs in the wild (most notably PS2 GT4 ISOs) that # have an invalid tag location for the second anchor and File Set # Terminator. So that we can support those ISOs, just silently # fix it up. We lose a little bit of detection of whether this is # "truly" a UDFTag, but it is really not a big risk. self.tag_location = extent if self.desc_version not in (2, 3): raise pycdlibexception.PyCdlibInvalidISO('Tag version not 2 or 3') if (len(data) - 16) < self.desc_crc_length: raise pycdlibexception.PyCdlibInternalError('Not enough CRC bytes to compute (expected at least %d, got %d)' % (self.desc_crc_length, len(data) - 16)) if desc_crc != crc_ccitt(data[16:16 + self.desc_crc_length]): raise pycdlibexception.PyCdlibInvalidISO('Tag CRC does not match!') self._initialized = True
[]
Please provide a description of the function:def record(self, crc_bytes): # type: (bytes) -> bytes ''' A method to generate the string representing this UDF Descriptor Tag. Parameters: crc_bytes - The string to compute the CRC over. Returns: A string representing this UDF Descriptor Tag. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Descriptor Tag not initialized') crc_byte_len = len(crc_bytes) if self.desc_crc_length >= 0: crc_byte_len = self.desc_crc_length # We need to compute the checksum, but we'll do that by first creating # the output buffer with the csum field set to 0, computing the csum, # and then setting that record back as usual. rec = bytearray(struct.pack(self.FMT, self.tag_ident, self.desc_version, 0, 0, self.tag_serial_number, crc_ccitt(crc_bytes[:crc_byte_len]), crc_byte_len, self.tag_location)) rec[4] = _compute_csum(rec) return bytes(rec)
[]
Please provide a description of the function:def new(self, tag_ident, tag_serial=0): # type: (int, int) -> None ''' A method to create a new UDF Descriptor Tag. Parameters: tag_ident - The tag identifier number for this tag. tag_serial - The tag serial number for this tag. Returns: Nothing ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Tag already initialized') self.tag_ident = tag_ident self.desc_version = 2 self.tag_serial_number = tag_serial self.tag_location = 0 # This will be set later. self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Anchor Volume Structure. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('Anchor Volume Structure already initialized') (tag_unused, self.main_vd_length, self.main_vd_extent, self.reserve_vd_length, self.reserve_vd_extent) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Anchor Volume Structure. Parameters: None. Returns: A string representing this UDF Anchor Volume Structure. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.main_vd_length, self.main_vd_extent, self.reserve_vd_length, self.reserve_vd_extent)[16:] + b'\x00' * 480 return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Anchor Volume Structure. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure already initialized') self.desc_tag = UDFTag() self.desc_tag.new(2) # FIXME: we should let the user set serial_number self.main_vd_length = 32768 self.main_vd_extent = 0 # This will get set later. self.reserve_vd_length = 32768 self.reserve_vd_extent = 0 # This will get set later. self._initialized = True
[]
Please provide a description of the function:def set_extent_location(self, new_location, main_vd_extent, reserve_vd_extent): # type: (int, int, int) -> None ''' A method to set a new location for this Anchor Volume Structure. Parameters: new_location - The new extent that this Anchor Volume Structure should be located at. main_vd_extent - The extent containing the main Volume Descriptors. reserve_vd_extent - The extent containing the reserve Volume Descriptors. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure not yet initialized') self.new_extent_loc = new_location self.desc_tag.tag_location = new_location self.main_vd_extent = main_vd_extent self.reserve_vd_extent = reserve_vd_extent
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Timestamp. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized') (tz, timetype, self.year, self.month, self.day, self.hour, self.minute, self.second, self.centiseconds, self.hundreds_microseconds, self.microseconds) = struct.unpack_from(self.FMT, data, 0) self.timetype = timetype >> 4 def twos_comp(val, bits): # type: (int, int) -> int ''' Compute the 2's complement of int value val ''' if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255 val = val - (1 << bits) # compute negative value return val # return positive value as is self.tz = twos_comp(((timetype & 0xf) << 8) | tz, 12) if self.tz < -1440 or self.tz > 1440: if self.tz != -2047: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF timezone') if self.year < 1 or self.year > 9999: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF year') if self.month < 1 or self.month > 12: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF month') if self.day < 1 or self.day > 31: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF day') if self.hour < 0 or self.hour > 23: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF hour') if self.minute < 0 or self.minute > 59: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF minute') if self.second < 0 or self.second > 59: raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF second') self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Timestamp. Parameters: None. Returns: A string representing this UDF Timestamp. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Timestamp not initialized') tmp = ((1 << 16) - 1) & self.tz newtz = tmp & 0xff newtimetype = ((tmp >> 8) & 0x0f) | (self.timetype << 4) return struct.pack(self.FMT, newtz, newtimetype, self.year, self.month, self.day, self.hour, self.minute, self.second, self.centiseconds, self.hundreds_microseconds, self.microseconds)
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Timestamp. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized') tm = time.time() local = time.localtime(tm) self.tz = utils.gmtoffset_from_tm(tm, local) # FIXME: for the timetype, 0 is UTC, 1 is local, 2 is 'agreement'. # We should let the user set this. self.timetype = 1 self.year = local.tm_year self.month = local.tm_mon self.day = local.tm_mon self.hour = local.tm_hour self.minute = local.tm_min self.second = local.tm_sec self.centiseconds = 0 self.hundreds_microseconds = 0 self.microseconds = 0 self._initialized = True
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Entity ID. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Entity ID already initialized') (self.flags, self.identifier, self.suffix) = struct.unpack_from(self.FMT, data, 0) self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Entity ID. Parameters: None. Returns: A string representing this UDF Entity ID. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Entity ID not initialized') return struct.pack(self.FMT, self.flags, self.identifier, self.suffix)
[]
Please provide a description of the function:def new(self, flags=0, identifier=b'', suffix=b''): # type: (int, bytes, bytes) -> None ''' A method to create a new UDF Entity ID. Parameters: flags - The flags to set for this Entity ID. identifier - The identifier to set for this Entity ID. suffix - The suffix to set for this Entity ID. None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Entity ID already initialized') if len(identifier) > 23: raise pycdlibexception.PyCdlibInvalidInput('UDF Entity ID identifer must be less than 23 characters') if len(suffix) > 8: raise pycdlibexception.PyCdlibInvalidInput('UDF Entity ID suffix must be less than 8 characters') self.flags = flags self.identifier = identifier + b'\x00' * (23 - len(identifier)) self.suffix = suffix + b'\x00' * (8 - len(suffix)) self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Primary Volume Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor already initialized') (tag_unused, self.vol_desc_seqnum, self.desc_num, self.vol_ident, vol_seqnum, max_vol_seqnum, interchange_level, self.max_interchange_level, char_set_list, max_char_set_list, self.vol_set_ident, self.desc_char_set, self.explanatory_char_set, self.vol_abstract_length, self.vol_abstract_extent, self.vol_copyright_length, self.vol_copyright_extent, app_ident, recording_date, impl_ident, self.implementation_use, self.predecessor_vol_desc_location, flags, reserved) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag if vol_seqnum != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if max_vol_seqnum != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if interchange_level != 2: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if char_set_list != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if max_char_set_list != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if flags != 0: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if reserved != b'\x00' * 22: raise pycdlibexception.PyCdlibInvalidISO('UDF Primary Volume Descriptor reserved data not 0') self.recording_date = UDFTimestamp() self.recording_date.parse(recording_date) self.app_ident = UDFEntityID() self.app_ident.parse(app_ident) self.impl_ident = UDFEntityID() self.impl_ident.parse(impl_ident) self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Primary Volume Descriptor. Parameters: None. Returns: A string representing this UDF Primary Volume Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.vol_desc_seqnum, self.desc_num, self.vol_ident, 1, 1, 2, self.max_interchange_level, 1, 1, self.vol_set_ident, self.desc_char_set, self.explanatory_char_set, self.vol_abstract_length, self.vol_abstract_extent, self.vol_copyright_length, self.vol_copyright_extent, self.app_ident.record(), self.recording_date.record(), self.impl_ident.record(), self.implementation_use, self.predecessor_vol_desc_location, 0, b'\x00' * 22)[16:] return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Primary Volume Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(1) # FIXME: we should let the user set serial_number self.vol_desc_seqnum = 0 # FIXME: we should let the user set this self.desc_num = 0 # FIXME: we should let the user set this self.vol_ident = _ostaunicode_zero_pad('CDROM', 32) # According to UDF 2.60, 2.2.2.5, the VolumeSetIdentifier should have # at least the first 16 characters be a unique value. Further, the # first 8 bytes of that should be a time value in ASCII hexadecimal # representation. To make it truly unique, we use that time plus a # random value, all ASCII encoded. unique = format(int(time.time()), '08x') + format(random.getrandbits(26), '08x') self.vol_set_ident = _ostaunicode_zero_pad(unique, 128) self.desc_char_set = _unicodecharset() self.explanatory_char_set = _unicodecharset() self.vol_abstract_length = 0 # FIXME: we should let the user set this self.vol_abstract_extent = 0 # FIXME: we should let the user set this self.vol_copyright_length = 0 # FIXME: we should let the user set this self.vol_copyright_extent = 0 # FIXME: we should let the user set this self.app_ident = UDFEntityID() self.app_ident.new() self.recording_date = UDFTimestamp() self.recording_date.new() self.impl_ident = UDFEntityID() self.impl_ident.new(0, b'*pycdlib') self.implementation_use = b'\x00' * 64 # FIXME: we should let the user set this self.predecessor_vol_desc_location = 0 # FIXME: we should let the user set this self.max_interchange_level = 2 self._initialized = True
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Implementation Use Volume Descriptor Implementation Use field. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field already initialized') (self.char_set, self.log_vol_ident, self.lv_info1, self.lv_info2, self.lv_info3, impl_ident, self.impl_use) = struct.unpack_from(self.FMT, data, 0) self.impl_ident = UDFEntityID() self.impl_ident.parse(impl_ident) self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Implementation Use Volume Descriptor Implementation Use field. Parameters: None. Returns: A string representing this UDF Implementation Use Volume Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field not initialized') return struct.pack(self.FMT, self.char_set, self.log_vol_ident, self.lv_info1, self.lv_info2, self.lv_info3, self.impl_ident.record(), self.impl_use)
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Implementation Use Volume Descriptor Implementation Use field. Parameters: None: Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field already initialized') self.char_set = _unicodecharset() self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128) self.lv_info1 = b'\x00' * 36 self.lv_info2 = b'\x00' * 36 self.lv_info3 = b'\x00' * 36 self.impl_ident = UDFEntityID() self.impl_ident.new(0, b'*pycdlib', b'') self.impl_use = b'\x00' * 128 self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Implementation Use Volume Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor already initialized') (tag_unused, self.vol_desc_seqnum, impl_ident, impl_use) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag self.impl_ident = UDFEntityID() self.impl_ident.parse(impl_ident) if self.impl_ident.identifier[:12] != b'*UDF LV Info': raise pycdlibexception.PyCdlibInvalidISO("Implementation Use Identifier not '*UDF LV Info'") self.impl_use = UDFImplementationUseVolumeDescriptorImplementationUse() self.impl_use.parse(impl_use) self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Implementation Use Volume Descriptor. Parameters: None: Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(4) # FIXME: we should let the user set serial_number self.vol_desc_seqnum = 1 self.impl_ident = UDFEntityID() self.impl_ident.new(0, b'*UDF LV Info', b'\x02\x01') self.impl_use = UDFImplementationUseVolumeDescriptorImplementationUse() self.impl_use.new() self._initialized = True
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Partition Header Descriptor. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Header Descriptor already initialized') (unalloc_table_length, unalloc_table_pos, unalloc_bitmap_length, unalloc_bitmap_pos, part_integrity_table_length, part_integrity_table_pos, freed_table_length, freed_table_pos, freed_bitmap_length, freed_bitmap_pos, reserved_unused) = struct.unpack_from(self.FMT, data, 0) if unalloc_table_length != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated table length not 0') if unalloc_table_pos != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated table position not 0') if unalloc_bitmap_length != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated bitmap length not 0') if unalloc_bitmap_pos != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated bitmap position not 0') if part_integrity_table_length != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header partition integrity length not 0') if part_integrity_table_pos != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header partition integrity position not 0') if freed_table_length != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed table length not 0') if freed_table_pos != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed table position not 0') if freed_bitmap_length != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed bitmap length not 0') if freed_bitmap_pos != 0: raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed bitmap position not 0') self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Partition Volume Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized') (tag_unused, self.vol_desc_seqnum, self.part_flags, self.part_num, part_contents, part_contents_use, self.access_type, self.part_start_location, self.part_length, impl_ident, self.implementation_use, reserved_unused) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag self.part_contents = UDFEntityID() self.part_contents.parse(part_contents) if self.part_contents.identifier[:6] != b'+NSR02': raise pycdlibexception.PyCdlibInvalidISO("Partition Contents Identifier not '+NSR02'") self.impl_ident = UDFEntityID() self.impl_ident.parse(impl_ident) self.part_contents_use = UDFPartitionHeaderDescriptor() self.part_contents_use.parse(part_contents_use) self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Partition Volume Descriptor. Parameters: None. Returns: A string representing this UDF Partition Volume Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.vol_desc_seqnum, self.part_flags, self.part_num, self.part_contents.record(), self.part_contents_use.record(), self.access_type, self.part_start_location, self.part_length, self.impl_ident.record(), self.implementation_use, b'\x00' * 156)[16:] return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Partition Volume Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(5) # FIXME: we should let the user set serial_number self.vol_desc_seqnum = 2 self.part_flags = 1 # FIXME: how should we set this? self.part_num = 0 # FIXME: how should we set this? self.part_contents = UDFEntityID() self.part_contents.new(2, b'+NSR02') self.part_contents_use = UDFPartitionHeaderDescriptor() self.part_contents_use.new() self.access_type = 1 self.part_start_location = 0 # This will get set later self.part_length = 3 # This will get set later self.impl_ident = UDFEntityID() self.impl_ident.new(0, b'*pycdlib') self.implementation_use = b'\x00' * 128 # FIXME: we should let the user set this self._initialized = True
[]
Please provide a description of the function:def set_start_location(self, new_location): # type: (int) -> None ''' A method to set the location of the start of the partition. Parameters: new_location - The new extent the UDF partition should start at. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor not initialized') self.part_start_location = new_location
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Partition Map. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized') (map_type, map_length, vol_seqnum, self.part_num) = struct.unpack_from(self.FMT, data, 0) if map_type != 1: raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map type is not 1') if map_length != 6: raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map length is not 6') if vol_seqnum != 1: raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Volume Sequence Number is not 1') self._initialized = True
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Partition Map. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized') self.part_num = 0 # FIXME: we should let the user set this self._initialized = True
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Long AD. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Long Allocation descriptor already initialized') (self.extent_length, self.log_block_num, self.part_ref_num, self.impl_use) = struct.unpack_from(self.FMT, data, 0) self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Long AD. Parameters: None. Returns: A string representing this UDF Long AD. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Long AD not initialized') return struct.pack(self.FMT, self.extent_length, self.log_block_num, self.part_ref_num, self.impl_use)
[]
Please provide a description of the function:def new(self, length, blocknum): # type: (int, int) -> None ''' A method to create a new UDF Long AD. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Long AD already initialized') self.extent_length = length self.log_block_num = blocknum self.part_ref_num = 0 # FIXME: we should let the user set this self.impl_use = b'\x00' * 6 self._initialized = True
[]
Please provide a description of the function:def set_extent_location(self, new_location, tag_location): # type: (int, int) -> None ''' A method to set the location fields of this UDF Long AD. Parameters: new_location - The new relative extent that this UDF Long AD references. tag_location - The new absolute extent that this UDF Long AD references. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Long AD not initialized') self.log_block_num = tag_location self.impl_use = b'\x00\x00' + struct.pack('=L', new_location)
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Logical Volume Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor already initialized') (tag_unused, self.vol_desc_seqnum, self.desc_char_set, self.logical_vol_ident, logical_block_size, domain_ident, logical_volume_contents_use, map_table_length, num_partition_maps, impl_ident, self.implementation_use, self.integrity_sequence_length, self.integrity_sequence_extent, partition_map, end_unused) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag if logical_block_size != 2048: raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor block size is not 2048') self.domain_ident = UDFEntityID() self.domain_ident.parse(domain_ident) if self.domain_ident.identifier[:19] != b'*OSTA UDF Compliant': raise pycdlibexception.PyCdlibInvalidISO("Volume Descriptor Identifier not '*OSTA UDF Compliant'") if map_table_length != 6: raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor map table length not 6') if num_partition_maps != 1: raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor number of partition maps not 1') self.impl_ident = UDFEntityID() self.impl_ident.parse(impl_ident) self.partition_map = UDFPartitionMap() self.partition_map.parse(partition_map) self.logical_volume_contents_use = UDFLongAD() self.logical_volume_contents_use.parse(logical_volume_contents_use) self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Logical Volume Descriptor. Parameters: None. Returns: A string representing this UDF Logical Volume Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.vol_desc_seqnum, self.desc_char_set, self.logical_vol_ident, 2048, self.domain_ident.record(), self.logical_volume_contents_use.record(), 6, 1, self.impl_ident.record(), self.implementation_use, self.integrity_sequence_length, self.integrity_sequence_extent, self.partition_map.record(), b'\x00' * 66)[16:] return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Logical Volume Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(6) # FIXME: we should let the user set serial_number self.vol_desc_seqnum = 3 self.desc_char_set = _unicodecharset() self.logical_vol_ident = _ostaunicode_zero_pad('CDROM', 128) self.domain_ident = UDFEntityID() self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03') self.logical_volume_contents_use = UDFLongAD() self.logical_volume_contents_use.new(4096, 0) self.impl_ident = UDFEntityID() self.impl_ident.new(0, b'*pycdlib') self.implementation_use = b'\x00' * 128 # FIXME: let the user set this self.integrity_sequence_length = 4096 self.integrity_sequence_extent = 0 # This will get set later self.partition_map = UDFPartitionMap() self.partition_map.new() self._initialized = True
[]
Please provide a description of the function:def set_integrity_location(self, integrity_extent): # type: (int) -> None ''' A method to set the location of the UDF Integrity sequence that this descriptor references. Parameters: integrity_extent - The new extent that the UDF Integrity sequence should start at. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor not initialized') self.integrity_sequence_extent = integrity_extent
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Unallocated Space Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Unallocated Space Descriptor already initialized') (tag_unused, self.vol_desc_seqnum, num_alloc_descriptors, end_unused) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag if num_alloc_descriptors != 0: raise pycdlibexception.PyCdlibInvalidISO('UDF Unallocated Space Descriptor allocated descriptors is not 0') self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def parse(self, extent, desc_tag): # type: (int, UDFTag) -> None ''' Parse the passed in data into a UDF Terminating Descriptor. Parameters: extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor already initialized') self.desc_tag = desc_tag self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Terminating Descriptor. Parameters: None. Returns: A string representing this UDF Terminating Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, b'\x00' * 496)[16:] return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Terminating Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(8) # FIXME: we should let the user set serial_number self._initialized = True
[]
Please provide a description of the function:def set_extent_location(self, new_location, tag_location=None): # type: (int, int) -> None ''' A method to set the location of this UDF Terminating Descriptor. Parameters: new_location - The new extent this UDF Terminating Descriptor should be located at. tag_location - The tag location to set for this UDF Terminator Descriptor. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized') self.new_extent_loc = new_location if tag_location is None: tag_location = new_location self.desc_tag.tag_location = tag_location
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Logical Volume Header Descriptor. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header Descriptor already initialized') (self.unique_id, reserved_unused) = struct.unpack_from(self.FMT, data, 0) self._initialized = True
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Logical Volume Header Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header Descriptor already initialized') self.unique_id = 261 self._initialized = True
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Logical Volume Implementation Use. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use already initialized') (impl_id, self.num_files, self.num_dirs, self.min_udf_read_revision, self.min_udf_write_revision, self.max_udf_write_revision) = struct.unpack_from(self.FMT, data, 0) self.impl_id = UDFEntityID() self.impl_id.parse(impl_id) self.impl_use = data[46:] self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Logical Volume Implementation Use. Parameters: None. Returns: A string representing this UDF Logical Volume Implementation Use. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use not initialized') return struct.pack(self.FMT, self.impl_id.record(), self.num_files, self.num_dirs, self.min_udf_read_revision, self.min_udf_write_revision, self.max_udf_write_revision) + self.impl_use
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Logical Volume Implementation Use. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use already initialized') self.impl_id = UDFEntityID() self.impl_id.new(0, b'*pycdlib') self.num_files = 0 self.num_dirs = 1 self.min_udf_read_revision = 258 self.min_udf_write_revision = 258 self.max_udf_write_revision = 258 self.impl_use = b'\x00' * 378 # FIXME: let the user set this self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF Logical Volume Integrity Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized') (tag_unused, recording_date, integrity_type, next_integrity_extent_length, next_integrity_extent_extent, logical_volume_contents_use, num_partitions, self.length_impl_use, self.free_space_table, self.size_table, impl_use) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag self.recording_date = UDFTimestamp() self.recording_date.parse(recording_date) if integrity_type != 1: raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Type not 1') if next_integrity_extent_length != 0: raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Extent length not 1') if next_integrity_extent_extent != 0: raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Extent extent not 1') if num_partitions != 1: raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity number partitions not 1') # For now, we only support an implementation use field of up to 424 # bytes (the 'rest' of the 512 byte sector we get here). If we run # across ones that are larger, we can go up to 2048, but anything # larger than that is invalid (I'm not quite sure why UDF defines # this as a 32-bit quantity, since there are no situations in which # this can be larger than 2048 minus 88). if self.length_impl_use > 424: raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity implementation use length too large') if self.free_space_table != 0: raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity free space table not 0') self.logical_volume_contents_use = UDFLogicalVolumeHeaderDescriptor() self.logical_volume_contents_use.parse(logical_volume_contents_use) self.logical_volume_impl_use = UDFLogicalVolumeImplementationUse() self.logical_volume_impl_use.parse(impl_use) self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF Logical Volume Integrity Descriptor. Parameters: None. Returns: A string representing this UDF Logical Volume Integrity Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.recording_date.record(), 1, 0, 0, self.logical_volume_contents_use.record(), 1, self.length_impl_use, self.free_space_table, self.size_table, self.logical_volume_impl_use.record())[16:] return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF Logical Volume Integrity Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(9) # FIXME: we should let the user set serial_number self.recording_date = UDFTimestamp() self.recording_date.new() self.length_impl_use = 46 self.free_space_table = 0 # FIXME: let the user set this self.size_table = 3 self.logical_volume_contents_use = UDFLogicalVolumeHeaderDescriptor() self.logical_volume_contents_use.new() self.logical_volume_impl_use = UDFLogicalVolumeImplementationUse() self.logical_volume_impl_use.new() self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag): # type: (bytes, int, UDFTag) -> None ''' Parse the passed in data into a UDF File Set Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized') (tag_unused, recording_date, interchange_level, max_interchange_level, char_set_list, max_char_set_list, self.file_set_num, file_set_desc_num, self.log_vol_char_set, self.log_vol_ident, self.file_set_char_set, self.file_set_ident, self.copyright_file_ident, self.abstract_file_ident, root_dir_icb, domain_ident, next_extent, reserved_unused) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag self.recording_date = UDFTimestamp() self.recording_date.parse(recording_date) if interchange_level != 3: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if max_interchange_level != 3: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if char_set_list != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if max_char_set_list != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') if file_set_desc_num != 0: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') self.domain_ident = UDFEntityID() self.domain_ident.parse(domain_ident) if self.domain_ident.identifier[:19] != b'*OSTA UDF Compliant': raise pycdlibexception.PyCdlibInvalidISO("File Set Descriptor Identifier not '*OSTA UDF Compliant'") self.root_dir_icb = UDFLongAD() self.root_dir_icb.parse(root_dir_icb) if next_extent != b'\x00' * 16: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported') self.orig_extent_loc = extent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF File Set Descriptor. Parameters: None. Returns: A string representing this UDF File Set Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.recording_date.record(), 3, 3, 1, 1, self.file_set_num, 0, self.log_vol_char_set, self.log_vol_ident, self.file_set_char_set, self.file_set_ident, self.copyright_file_ident, self.abstract_file_ident, self.root_dir_icb.record(), self.domain_ident.record(), b'\x00' * 16, b'\x00' * 48)[16:] return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self): # type: () -> None ''' A method to create a new UDF File Set Descriptor. Parameters: None. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized') self.desc_tag = UDFTag() self.desc_tag.new(256) # FIXME: we should let the user set serial_number self.recording_date = UDFTimestamp() self.recording_date.new() self.domain_ident = UDFEntityID() self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03') self.root_dir_icb = UDFLongAD() self.root_dir_icb.new(2048, 2) self.file_set_num = 0 self.log_vol_char_set = _unicodecharset() self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128) self.file_set_char_set = _unicodecharset() self.file_set_ident = _ostaunicode_zero_pad('CDROM', 32) self.copyright_file_ident = b'\x00' * 32 # FIXME: let the user set this self.abstract_file_ident = b'\x00' * 32 # FIXME: let the user set this self._initialized = True
[]
Please provide a description of the function:def set_extent_location(self, new_location): # type: (int) -> None ''' A method to set the location of this UDF File Set Descriptor. Parameters: new_location - The new extent this UDF File Set Descriptor should be located at. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized') self.new_extent_loc = new_location
[]
Please provide a description of the function:def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF ICB Tag. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag already initialized') (self.prior_num_direct_entries, self.strategy_type, self.strategy_param, self.max_num_entries, reserved, self.file_type, self.parent_icb_log_block_num, self.parent_icb_part_ref_num, self.flags) = struct.unpack_from(self.FMT, data, 0) if self.strategy_type not in (4, 4096): raise pycdlibexception.PyCdlibInvalidISO('UDF ICB Tag invalid strategy type') if reserved != 0: raise pycdlibexception.PyCdlibInvalidISO('UDF ICB Tag reserved not 0') self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF ICB Tag. Parameters: None. Returns: A string representing this UDF ICB Tag. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag not initialized') return struct.pack(self.FMT, self.prior_num_direct_entries, self.strategy_type, self.strategy_param, self.max_num_entries, 0, self.file_type, self.parent_icb_log_block_num, self.parent_icb_part_ref_num, self.flags)
[]
Please provide a description of the function:def new(self, file_type): # type: (str) -> None ''' A method to create a new UDF ICB Tag. Parameters: file_type - What file type this represents, one of 'dir', 'file', or 'symlink'. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag already initialized') self.prior_num_direct_entries = 0 # FIXME: let the user set this self.strategy_type = 4 self.strategy_param = 0 # FIXME: let the user set this self.max_num_entries = 1 if file_type == 'dir': self.file_type = 4 elif file_type == 'file': self.file_type = 5 elif file_type == 'symlink': self.file_type = 12 else: raise pycdlibexception.PyCdlibInternalError("Invalid file type for ICB; must be one of 'dir', 'file', or 'symlink'") self.parent_icb_log_block_num = 0 # FIXME: let the user set this self.parent_icb_part_ref_num = 0 # FIXME: let the user set this self.flags = 560 # hex 0x230 == binary 0010 0011 0000 self._initialized = True
[]
Please provide a description of the function:def parse(self, data, extent, parent, desc_tag): # type: (bytes, int, Optional[UDFFileEntry], UDFTag) -> None ''' Parse the passed in data into a UDF File Entry. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. parent - The parent File Entry for this file (may be None). desc_tag - A UDFTag object that represents the Descriptor Tag. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized') (tag_unused, icb_tag, self.uid, self.gid, self.perms, self.file_link_count, record_format, record_display_attrs, record_len, self.info_len, self.log_block_recorded, access_time, mod_time, attr_time, checkpoint, extended_attr_icb, impl_ident, self.unique_id, self.len_extended_attrs, len_alloc_descs) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag self.icb_tag = UDFICBTag() self.icb_tag.parse(icb_tag) if record_format != 0: raise pycdlibexception.PyCdlibInvalidISO('File Entry record format is not 0') if record_display_attrs != 0: raise pycdlibexception.PyCdlibInvalidISO('File Entry record display attributes is not 0') if record_len != 0: raise pycdlibexception.PyCdlibInvalidISO('File Entry record length is not 0') self.access_time = UDFTimestamp() self.access_time.parse(access_time) self.mod_time = UDFTimestamp() self.mod_time.parse(mod_time) self.attr_time = UDFTimestamp() self.attr_time.parse(attr_time) if checkpoint != 1: raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-only disks supported') self.extended_attr_icb = UDFLongAD() self.extended_attr_icb.parse(extended_attr_icb) self.impl_ident = UDFEntityID() self.impl_ident.parse(impl_ident) offset = struct.calcsize(self.FMT) self.extended_attrs = data[offset:offset + self.len_extended_attrs] offset += self.len_extended_attrs num_alloc_descs = len_alloc_descs // 8 # a short_ad is 8 bytes for i_unused in range(0, num_alloc_descs): (length, pos) = struct.unpack('=LL', data[offset:offset + 8]) self.alloc_descs.append([length, pos]) offset += 8 self.orig_extent_loc = extent self.parent = parent self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF File Entry. Parameters: None. Returns: A string representing this UDF File Entry. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') rec = struct.pack(self.FMT, b'\x00' * 16, self.icb_tag.record(), self.uid, self.gid, self.perms, self.file_link_count, 0, 0, 0, self.info_len, self.log_block_recorded, self.access_time.record(), self.mod_time.record(), self.attr_time.record(), 1, self.extended_attr_icb.record(), self.impl_ident.record(), self.unique_id, self.len_extended_attrs, len(self.alloc_descs) * 8)[16:] rec += self.extended_attrs for length, pos in self.alloc_descs: rec += struct.pack('=LL', length, pos) return self.desc_tag.record(rec) + rec
[]
Please provide a description of the function:def new(self, length, file_type, parent, log_block_size): # type: (int, str, Optional[UDFFileEntry], int) -> None ''' A method to create a new UDF File Entry. Parameters: length - The (starting) length of this UDF File Entry; this is ignored if this is a symlink. file_type - The type that this UDF File entry represents; one of 'dir', 'file', or 'symlink'. parent - The parent UDF File Entry for this UDF File Entry. log_block_size - The logical block size for extents. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized') if file_type not in ('dir', 'file', 'symlink'): raise pycdlibexception.PyCdlibInternalError("UDF File Entry file type must be one of 'dir', 'file', or 'symlink'") self.desc_tag = UDFTag() self.desc_tag.new(261) # FIXME: we should let the user set serial_number self.icb_tag = UDFICBTag() self.icb_tag.new(file_type) self.uid = 4294967295 # Really -1, which means unset self.gid = 4294967295 # Really -1, which means unset if file_type == 'dir': self.perms = 5285 self.file_link_count = 0 self.info_len = 0 self.log_block_recorded = 1 # The second field (position) is bogus, but will get set # properly once reshuffle_extents is called. self.alloc_descs.append([length, 0]) else: self.perms = 4228 self.file_link_count = 1 self.info_len = length self.log_block_recorded = utils.ceiling_div(length, log_block_size) len_left = length while len_left > 0: # According to Ecma-167 14.14.1.1, the least-significant 30 bits # of the allocation descriptor length field specify the length # (the most significant two bits are properties which we don't # currently support). In theory we should then split files # into 2^30 = 0x40000000, but all implementations I've seen # split it into smaller. cdrkit/cdrtools uses 0x3ffff800, and # Windows uses 0x3ff00000. To be more compatible with cdrkit, # we'll choose their number of 0x3ffff800. alloc_len = min(len_left, 0x3ffff800) # The second field (position) is bogus, but will get set # properly once reshuffle_extents is called. self.alloc_descs.append([alloc_len, 0]) len_left -= alloc_len self.access_time = UDFTimestamp() self.access_time.new() self.mod_time = UDFTimestamp() self.mod_time.new() self.attr_time = UDFTimestamp() self.attr_time.new() self.extended_attr_icb = UDFLongAD() self.extended_attr_icb.new(0, 0) self.impl_ident = UDFEntityID() self.impl_ident.new(0, b'*pycdlib') self.unique_id = 0 # this will get set later self.len_extended_attrs = 0 # FIXME: let the user set this self.extended_attrs = b'' self.parent = parent self._initialized = True
[]
Please provide a description of the function:def add_file_ident_desc(self, new_fi_desc, logical_block_size): # type: (UDFFileIdentifierDescriptor, int) -> int ''' A method to add a new UDF File Identifier Descriptor to this UDF File Entry. Parameters: new_fi_desc - The new UDF File Identifier Descriptor to add. logical_block_size - The logical block size to use. Returns: The number of extents added due to adding this File Identifier Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') if self.icb_tag.file_type != 4: raise pycdlibexception.PyCdlibInvalidInput('Can only add a UDF File Identifier to a directory') self.fi_descs.append(new_fi_desc) num_bytes_to_add = UDFFileIdentifierDescriptor.length(len(new_fi_desc.fi)) old_num_extents = 0 # If info_len is 0, then this is a brand-new File Entry, and thus the # number of extents it is using is 0. if self.info_len > 0: old_num_extents = utils.ceiling_div(self.info_len, logical_block_size) self.info_len += num_bytes_to_add new_num_extents = utils.ceiling_div(self.info_len, logical_block_size) self.log_block_recorded = new_num_extents self.alloc_descs[0][0] = self.info_len if new_fi_desc.is_dir(): self.file_link_count += 1 return new_num_extents - old_num_extents
[]
Please provide a description of the function:def remove_file_ident_desc_by_name(self, name, logical_block_size): # type: (bytes, int) -> int ''' A method to remove a UDF File Identifier Descriptor from this UDF File Entry. Parameters: name - The name of the UDF File Identifier Descriptor to remove. logical_block_size - The logical block size to use. Returns: The number of extents removed due to removing this File Identifier Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') tmp_fi_desc = UDFFileIdentifierDescriptor() tmp_fi_desc.isparent = False tmp_fi_desc.fi = name # If flags bit 3 is set, the entries are sorted. desc_index = len(self.fi_descs) for index, fi_desc in enumerate(self.fi_descs): if fi_desc.fi == name: desc_index = index break if desc_index == len(self.fi_descs) or self.fi_descs[desc_index].fi != name: raise pycdlibexception.PyCdlibInvalidInput('Cannot find file to remove') this_desc = self.fi_descs[desc_index] if this_desc.is_dir(): if this_desc.file_entry is None: raise pycdlibexception.PyCdlibInternalError('No UDF File Entry for UDF File Descriptor') if len(this_desc.file_entry.fi_descs) > 1: raise pycdlibexception.PyCdlibInvalidInput('Directory must be empty to use rm_directory') self.file_link_count -= 1 old_num_extents = utils.ceiling_div(self.info_len, logical_block_size) self.info_len -= UDFFileIdentifierDescriptor.length(len(this_desc.fi)) new_num_extents = utils.ceiling_div(self.info_len, logical_block_size) self.alloc_descs[0][0] = self.info_len del self.fi_descs[desc_index] return old_num_extents - new_num_extents
[]
Please provide a description of the function:def set_data_location(self, current_extent, start_extent): # pylint: disable=unused-argument # type: (int, int) -> None ''' A method to set the location of the data that this UDF File Entry points to. Parameters: current_extent - Unused start_extent - The starting extent for this data location. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') current_assignment = start_extent for index, desc_unused in enumerate(self.alloc_descs): self.alloc_descs[index][1] = current_assignment current_assignment += 1
[]
Please provide a description of the function:def set_data_length(self, length): # type: (int) -> None ''' A method to set the length of the data that this UDF File Entry points to. Parameters: length - The new length for the data. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized') len_diff = length - self.info_len if len_diff > 0: # If we are increasing the length, update the last alloc_desc up # to the max of 0x3ffff800, and throw an exception if we overflow. new_len = self.alloc_descs[-1][0] + len_diff if new_len > 0x3ffff800: raise pycdlibexception.PyCdlibInvalidInput('Cannot increase the size of a UDF file beyond the current descriptor') self.alloc_descs[-1][0] = new_len elif len_diff < 0: # We are decreasing the length. It's possible we are removing one # or more alloc_descs, so run through the list updating all of the # descriptors and remove any we no longer need. len_left = length alloc_descs_needed = 0 index = 0 while len_left > 0: this_len = min(len_left, 0x3ffff800) alloc_descs_needed += 1 self.alloc_descs[index][0] = this_len index += 1 len_left -= this_len self.alloc_descs = self.alloc_descs[:alloc_descs_needed] self.info_len = length
[]
Please provide a description of the function:def file_identifier(self): # type: () -> bytes ''' A method to get the name of this UDF File Entry as a byte string. Parameters: None. Returns: The UDF File Entry as a byte string. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') if self.file_ident is None: return b'/' return self.file_ident.fi
[]
Please provide a description of the function:def find_file_ident_desc_by_name(self, currpath): # type: (bytes) -> UDFFileIdentifierDescriptor ''' A method to find a UDF File Identifier descriptor by its name. Parameters: currpath - The UTF-8 encoded name to look up. Returns: The UDF File Identifier descriptor corresponding to the passed in name. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') # If this is a directory or it is an empty directory, just skip # all work. if self.icb_tag.file_type != 4 or not self.fi_descs: raise pycdlibexception.PyCdlibInvalidInput('Could not find path') tmp = currpath.decode('utf-8') try: latin1_currpath = tmp.encode('latin-1') except (UnicodeDecodeError, UnicodeEncodeError): latin1_currpath = b'' ucs2_currpath = tmp.encode('utf-16_be') child = None for fi_desc in self.fi_descs: if latin1_currpath and fi_desc.encoding == 'latin-1': eq = fi_desc.fi == latin1_currpath else: eq = fi_desc.fi == ucs2_currpath if eq: child = fi_desc break if child is None: raise pycdlibexception.PyCdlibInvalidInput('Could not find path') return child
[]
Please provide a description of the function:def track_file_ident_desc(self, file_ident): # type: (UDFFileIdentifierDescriptor) -> None ''' A method to start tracking a UDF File Identifier descriptor in this UDF File Entry. Both 'tracking' and 'addition' add the identifier to the list of file identifiers, but tracking doees not expand or otherwise modify the UDF File Entry. Parameters: file_ident - The UDF File Identifier Descriptor to start tracking. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') self.fi_descs.append(file_ident)
[]
Please provide a description of the function:def finish_directory_parse(self): # type: () -> None ''' A method to finish up the parsing of this UDF File Entry directory. In particular, this method checks to see if it is in sorted order for future use. Parameters: None. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized') if self.icb_tag.file_type != 4: raise pycdlibexception.PyCdlibInternalError('Can only finish_directory for a directory')
[]
Please provide a description of the function:def length(cls, namelen): # type: (Type[UDFFileIdentifierDescriptor], int) -> int ''' A class method to calculate the size this UDFFileIdentifierDescriptor would take up. Parameters: cls - The class to use (always UDFFileIdentifierDescriptor). namelen - The length of the name. Returns: The length that the UDFFileIdentifierDescriptor would take up. ''' if namelen > 0: namelen += 1 to_add = struct.calcsize(cls.FMT) + namelen return to_add + UDFFileIdentifierDescriptor.pad(to_add)
[]
Please provide a description of the function:def parse(self, data, extent, desc_tag, parent): # type: (bytes, int, UDFTag, UDFFileEntry) -> int ''' Parse the passed in data into a UDF File Identifier Descriptor. Parameters: data - The data to parse. extent - The extent that this descriptor currently lives at. desc_tag - A UDFTag object that represents the Descriptor Tag. parent - The UDF File Entry representing the parent. Returns: The number of bytes this descriptor consumed. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor already initialized') (tag_unused, file_version_num, self.file_characteristics, self.len_fi, icb, self.len_impl_use) = struct.unpack_from(self.FMT, data, 0) self.desc_tag = desc_tag if file_version_num != 1: raise pycdlibexception.PyCdlibInvalidISO('File Identifier Descriptor file version number not 1') if self.file_characteristics & 0x2: self.isdir = True if self.file_characteristics & 0x8: self.isparent = True self.icb = UDFLongAD() self.icb.parse(icb) start = struct.calcsize(self.FMT) end = start + self.len_impl_use self.impl_use = data[start:end] start = end end = start + self.len_fi # The very first byte of the File Identifier describes whether this is # an 8-bit or 16-bit encoded string; this corresponds to whether we # encode with 'latin-1' or with 'utf-16_be'. We save that off because we have # to write the correct thing out when we record. if not self.isparent: encoding = bytes(bytearray([data[start]])) if encoding == b'\x08': self.encoding = 'latin-1' elif encoding == b'\x10': self.encoding = 'utf-16_be' else: raise pycdlibexception.PyCdlibInvalidISO('Only UDF File Identifier Descriptor Encodings 8 or 16 are supported') start += 1 self.fi = data[start:end] self.orig_extent_loc = extent self.parent = parent self._initialized = True return end + UDFFileIdentifierDescriptor.pad(end)
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this UDF File Identifier Descriptor. Parameters: None. Returns: A string representing this UDF File Identifier Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor not initialized') if self.len_fi > 0: if self.encoding == 'latin-1': prefix = b'\x08' elif self.encoding == 'utf-16_be': prefix = b'\x10' else: raise pycdlibexception.PyCdlibInternalError('Invalid UDF encoding; this should not happen') fi = prefix + self.fi else: fi = b'' rec = struct.pack(self.FMT, b'\x00' * 16, 1, self.file_characteristics, self.len_fi, self.icb.record(), self.len_impl_use) + self.impl_use + fi + b'\x00' * UDFFileIdentifierDescriptor.pad(struct.calcsize(self.FMT) + self.len_impl_use + self.len_fi) return self.desc_tag.record(rec[16:]) + rec[16:]
[]
Please provide a description of the function:def new(self, isdir, isparent, name, parent): # type: (bool, bool, bytes, Optional[UDFFileEntry]) -> None ''' A method to create a new UDF File Identifier. Parameters: isdir - Whether this File Identifier is a directory. isparent - Whether this File Identifier is a parent (..). name - The name for this File Identifier. parent - The UDF File Entry representing the parent. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Identifier already initialized') self.desc_tag = UDFTag() self.desc_tag.new(257) # FIXME: we should let the user set serial_number self.icb = UDFLongAD() self.icb.new(2048, 2) self.isdir = isdir self.isparent = isparent self.file_characteristics = 0 if self.isdir: self.file_characteristics |= 0x2 if self.isparent: self.file_characteristics |= 0x8 self.len_impl_use = 0 # FIXME: need to let the user set this self.impl_use = b'' self.len_fi = 0 if not isparent: bytename = name.decode('utf-8') try: self.fi = bytename.encode('latin-1') self.encoding = 'latin-1' except UnicodeEncodeError: self.fi = bytename.encode('utf-16_be') self.encoding = 'utf-16_be' self.len_fi = len(self.fi) + 1 self.parent = parent self._initialized = True
[]
Please provide a description of the function:def set_icb(self, new_location, tag_location): # type: (int, int) -> None ''' A method to set the location of the data that this UDF File Identifier Descriptor points at. The data can either be for a directory or for a file. Parameters: new_location - The new extent this UDF File Identifier Descriptor data lives at. tag_location - The new relative extent this UDF File Identifier Descriptor data lives at. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF File Identifier not initialized') self.icb.set_extent_location(new_location, tag_location)
[]
Please provide a description of the function:def pvd_factory(sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa): # type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD ''' An internal function to create a Primary Volume Descriptor. Parameters: sys_ident - The system identification string to use on the new ISO. vol_ident - The volume identification string to use on the new ISO. set_size - The size of the set of ISOs this ISO is a part of. seqnum - The sequence number of the set of this ISO. log_block_size - The logical block size to use for the ISO. While ISO9660 technically supports sizes other than 2048 (the default), this almost certainly doesn't work. vol_set_ident - The volume set identification string to use on the new ISO. pub_ident_str - The publisher identification string to use on the new ISO. preparer_ident_str - The preparer identification string to use on the new ISO. app_ident_str - The application identification string to use on the new ISO. copyright_file - The name of a file at the root of the ISO to use as the copyright file. abstract_file - The name of a file at the root of the ISO to use as the abstract file. bibli_file - The name of a file at the root of the ISO to use as the bibliographic file. vol_expire_date - The date that this ISO will expire at. app_use - Arbitrary data that the application can stuff into the primary volume descriptor of this ISO. xa - Whether to add the ISO9660 Extended Attribute extensions to this ISO. The default is False. Returns: The newly created Primary Volume Descriptor. ''' pvd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_PRIMARY) pvd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa, 1, b'') return pvd
[]
Please provide a description of the function:def enhanced_vd_factory(sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa): # type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD ''' An internal function to create an Enhanced Volume Descriptor for ISO 1999. Parameters: sys_ident - The system identification string to use on the new ISO. vol_ident - The volume identification string to use on the new ISO. set_size - The size of the set of ISOs this ISO is a part of. seqnum - The sequence number of the set of this ISO. log_block_size - The logical block size to use for the ISO. While ISO9660 technically supports sizes other than 2048 (the default), this almost certainly doesn't work. vol_set_ident - The volume set identification string to use on the new ISO. pub_ident_str - The publisher identification string to use on the new ISO. preparer_ident_str - The preparer identification string to use on the new ISO. app_ident_str - The application identification string to use on the new ISO. copyright_file - The name of a file at the root of the ISO to use as the copyright file. abstract_file - The name of a file at the root of the ISO to use as the abstract file. bibli_file - The name of a file at the root of the ISO to use as the bibliographic file. vol_expire_date - The date that this ISO will expire at. app_use - Arbitrary data that the application can stuff into the primary volume descriptor of this ISO. xa - Whether to add the ISO9660 Extended Attribute extensions to this ISO. The default is False. Returns: The newly created Enhanced Volume Descriptor. ''' svd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY) svd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa, 2, b'') return svd
[]
Please provide a description of the function:def joliet_vd_factory(joliet, sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa): # type: (int, bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD ''' An internal function to create an Joliet Volume Descriptor. Parameters: joliet - The joliet version to use, one of 1, 2, or 3. sys_ident - The system identification string to use on the new ISO. vol_ident - The volume identification string to use on the new ISO. set_size - The size of the set of ISOs this ISO is a part of. seqnum - The sequence number of the set of this ISO. log_block_size - The logical block size to use for the ISO. While ISO9660 technically supports sizes other than 2048 (the default), this almost certainly doesn't work. vol_set_ident - The volume set identification string to use on the new ISO. pub_ident_str - The publisher identification string to use on the new ISO. preparer_ident_str - The preparer identification string to use on the new ISO. app_ident_str - The application identification string to use on the new ISO. copyright_file - The name of a file at the root of the ISO to use as the copyright file. abstract_file - The name of a file at the root of the ISO to use as the abstract file. bibli_file - The name of a file at the root of the ISO to use as the bibliographic file. vol_expire_date - The date that this ISO will expire at. app_use - Arbitrary data that the application can stuff into the primary volume descriptor of this ISO. xa - Whether to add the ISO9660 Extended Attribute extensions to this ISO. The default is False. Returns: The newly created Joliet Volume Descriptor. ''' if joliet == 1: escape_sequence = b'%/@' elif joliet == 2: escape_sequence = b'%/C' elif joliet == 3: escape_sequence = b'%/E' else: raise pycdlibexception.PyCdlibInvalidInput('Invalid Joliet level; must be 1, 2, or 3') svd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY) svd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa, 1, escape_sequence) return svd
[]
Please provide a description of the function:def parse(self, vd, extent_loc): # type: (bytes, int) -> None ''' Parse a Volume Descriptor out of a string. Parameters: vd - The string containing the Volume Descriptor. extent_loc - The location on the ISO of this Volume Descriptor. Returns: Nothing. ''' ################ PVD VERSION ###################### (descriptor_type, identifier, self.version, self.flags, self.system_identifier, self.volume_identifier, unused1, space_size_le, space_size_be, self.escape_sequences, set_size_le, set_size_be, seqnum_le, seqnum_be, logical_block_size_le, logical_block_size_be, path_table_size_le, path_table_size_be, self.path_table_location_le, self.optional_path_table_location_le, self.path_table_location_be, self.optional_path_table_location_be, root_dir_record, self.volume_set_identifier, pub_ident_str, prepare_ident_str, app_ident_str, self.copyright_file_identifier, self.abstract_file_identifier, self.bibliographic_file_identifier, vol_create_date_str, vol_mod_date_str, vol_expire_date_str, vol_effective_date_str, self.file_structure_version, unused2, self.application_use, zero_unused) = struct.unpack_from(self.FMT, vd, 0) # According to Ecma-119, 8.4.1, the primary volume descriptor type # should be 1. if descriptor_type != self._vd_type: raise pycdlibexception.PyCdlibInvalidISO('Invalid volume descriptor') # According to Ecma-119, 8.4.2, the identifier should be 'CD001'. if identifier != b'CD001': raise pycdlibexception.PyCdlibInvalidISO('invalid CD isoIdentification') # According to Ecma-119, 8.4.3, the version should be 1 (or 2 for # ISO9660:1999) expected_versions = [1] if self._vd_type == VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY: expected_versions.append(2) if self.version not in expected_versions: raise pycdlibexception.PyCdlibInvalidISO('Invalid volume descriptor version %d' % (self.version)) # According to Ecma-119, 8.4.4, the first flags field should be 0 for a Primary. if self._vd_type == VOLUME_DESCRIPTOR_TYPE_PRIMARY and self.flags != 0: raise pycdlibexception.PyCdlibInvalidISO('PVD flags field is not zero') # According to Ecma-119, 8.4.5, the first unused field (after the # system identifier and volume identifier) should be 0. if unused1 != 0: raise pycdlibexception.PyCdlibInvalidISO('data in 2nd unused field not zero') # According to Ecma-119, 8.4.9, the escape sequences for a PVD should # be 32 zero-bytes. However, we have seen ISOs in the wild (Fantastic # Night Dreams - Cotton Original (Japan).cue from the psx redump # collection) that don't have this set to 0, so allow anything here. # According to Ecma-119, 8.4.30, the file structure version should be 1. # However, we have seen ISOs in the wild that that don't have this # properly set to one. In those cases, forcibly set it to one and let # it pass. if self._vd_type == VOLUME_DESCRIPTOR_TYPE_PRIMARY: if self.file_structure_version != 1: self.file_structure_version = 1 elif self._vd_type == VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY: if self.file_structure_version not in (1, 2): raise pycdlibexception.PyCdlibInvalidISO('File structure version expected to be 1') # According to Ecma-119, 8.4.31, the second unused field should be 0. if unused2 != 0: raise pycdlibexception.PyCdlibInvalidISO('data in 2nd unused field not zero') # According to Ecma-119, the last 653 bytes of the VD should be all 0. # However, we have seen ISOs in the wild that do not follow this, so # relax the check. # Check to make sure that the little-endian and big-endian versions # of the parsed data agree with each other. if space_size_le != utils.swab_32bit(space_size_be): raise pycdlibexception.PyCdlibInvalidISO('Little-endian and big-endian space size disagree') self.space_size = space_size_le if set_size_le != utils.swab_16bit(set_size_be): raise pycdlibexception.PyCdlibInvalidISO('Little-endian and big-endian set size disagree') self.set_size = set_size_le if seqnum_le != utils.swab_16bit(seqnum_be): raise pycdlibexception.PyCdlibInvalidISO('Little-endian and big-endian seqnum disagree') self.seqnum = seqnum_le if logical_block_size_le != utils.swab_16bit(logical_block_size_be): raise pycdlibexception.PyCdlibInvalidISO('Little-endian and big-endian logical block size disagree') self.log_block_size = logical_block_size_le if path_table_size_le != utils.swab_32bit(path_table_size_be): raise pycdlibexception.PyCdlibInvalidISO('Little-endian and big-endian path table size disagree') self.path_tbl_size = path_table_size_le self.path_table_num_extents = utils.ceiling_div(self.path_tbl_size, 4096) * 2 self.path_table_location_be = utils.swab_32bit(self.path_table_location_be) self.publisher_identifier = FileOrTextIdentifier() self.publisher_identifier.parse(pub_ident_str) self.preparer_identifier = FileOrTextIdentifier() self.preparer_identifier.parse(prepare_ident_str) self.application_identifier = FileOrTextIdentifier() self.application_identifier.parse(app_ident_str) self.volume_creation_date = dates.VolumeDescriptorDate() self.volume_creation_date.parse(vol_create_date_str) self.volume_modification_date = dates.VolumeDescriptorDate() self.volume_modification_date.parse(vol_mod_date_str) self.volume_expiration_date = dates.VolumeDescriptorDate() self.volume_expiration_date.parse(vol_expire_date_str) self.volume_effective_date = dates.VolumeDescriptorDate() self.volume_effective_date.parse(vol_effective_date_str) self.root_dir_record.parse(self, root_dir_record, None) self.orig_extent_loc = extent_loc self._initialized = True
[]
Please provide a description of the function:def new(self, flags, sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa, version, escape_sequence): # type: (int, bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool, int, bytes) -> None ''' Create a new Volume Descriptor. Parameters: flags - The flags to set for this Volume Descriptor (must be 0 for a Primay Volume Descriptor). sys_ident - The system identification string to use on the new ISO. vol_ident - The volume identification string to use on the new ISO. set_size - The size of the set of ISOs this ISO is a part of. seqnum - The sequence number of the set of this ISO. log_block_size - The logical block size to use for the ISO. While ISO9660 technically supports sizes other than 2048 (the default), this almost certainly doesn't work. vol_set_ident - The volume set identification string to use on the new ISO. pub_ident_str - The publisher identification string to use on the new ISO. preparer_ident_str - The preparer identification string to use on the new ISO. app_ident_str - The application identification string to use on the new ISO. copyright_file - The name of a file at the root of the ISO to use as the copyright file. abstract_file - The name of a file at the root of the ISO to use as the abstract file. bibli_file - The name of a file at the root of the ISO to use as the bibliographic file. vol_expire_date - The date that this ISO will expire at. app_use - Arbitrary data that the application can stuff into the primary volume descriptor of this ISO. xa - Whether to embed XA data into the volume descriptor. version - What version to assign to the header (ignored). escape_sequence - The escape sequence to assign to this volume descriptor (must be empty for a PVD, or empty or a valid Joliet escape sequence for an SVD). Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is already initialized') encoding = 'ascii' if self._vd_type == VOLUME_DESCRIPTOR_TYPE_PRIMARY: if flags != 0: raise pycdlibexception.PyCdlibInvalidInput('Non-zero flags not allowed for a PVD') if escape_sequence != b'': raise pycdlibexception.PyCdlibInvalidInput('Non-empty escape sequence not allowed for a PVD') if version != 1: raise pycdlibexception.PyCdlibInvalidInput('Only version 1 supported for a PVD') self.escape_sequences = b'\x00' * 32 elif self._vd_type == VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY: if version not in (1, 2): raise pycdlibexception.PyCdlibInvalidInput('Only version 1 and version 2 supported for a Supplementary Volume Descriptor') if escape_sequence in (b'%/@', b'%/C', b'%/E'): encoding = 'utf-16_be' self.escape_sequences = escape_sequence.ljust(32, b'\x00') self.file_structure_version = version self.version = version self.flags = 0 if len(sys_ident) > 32: raise pycdlibexception.PyCdlibInvalidInput('The system identifer has a maximum length of 32') self.system_identifier = utils.encode_space_pad(sys_ident, 32, encoding) if len(vol_ident) > 32: raise pycdlibexception.PyCdlibInvalidInput('The volume identifier has a maximum length of 32') self.volume_identifier = utils.encode_space_pad(vol_ident, 32, encoding) # The space_size is the number of extents (2048-byte blocks) in the # ISO. We know we will at least have the system area (16 extents), # and this VD (1 extent) to start with; the rest will be added later. self.space_size = 17 self.set_size = set_size if seqnum > set_size: raise pycdlibexception.PyCdlibInvalidInput('Sequence number must be less than or equal to set size') self.seqnum = seqnum self.log_block_size = log_block_size # The path table size is in bytes, and is always at least 10 bytes # (for the root directory record). self.path_tbl_size = 10 self.path_table_num_extents = utils.ceiling_div(self.path_tbl_size, 4096) * 2 # By default the Little Endian Path Table record starts at extent 19 # (right after the Volume Terminator). self.path_table_location_le = 19 # By default the Big Endian Path Table record starts at extent 21 # (two extents after the Little Endian Path Table Record). self.path_table_location_be = 21 # FIXME: we don't support the optional path table location right now self.optional_path_table_location_le = 0 self.optional_path_table_location_be = 0 self.root_dir_record.new_root(self, seqnum, self.log_block_size) if len(vol_set_ident) > 128: raise pycdlibexception.PyCdlibInvalidInput('The maximum length for the volume set identifier is 128') self.volume_set_identifier = utils.encode_space_pad(vol_set_ident, 128, encoding) self.publisher_identifier = FileOrTextIdentifier() self.publisher_identifier.new(utils.encode_space_pad(pub_ident_str, 128, encoding)) self.preparer_identifier = FileOrTextIdentifier() self.preparer_identifier.new(utils.encode_space_pad(preparer_ident_str, 128, encoding)) self.application_identifier = FileOrTextIdentifier() self.application_identifier.new(utils.encode_space_pad(app_ident_str, 128, encoding)) self.copyright_file_identifier = utils.encode_space_pad(copyright_file, 37, encoding) self.abstract_file_identifier = utils.encode_space_pad(abstract_file, 37, encoding) self.bibliographic_file_identifier = utils.encode_space_pad(bibli_file, 37, encoding) now = time.time() self.volume_creation_date = dates.VolumeDescriptorDate() self.volume_creation_date.new(now) # We make a valid volume modification date here, but it will get # overwritten during record(). self.volume_modification_date = dates.VolumeDescriptorDate() self.volume_modification_date.new(now) self.volume_expiration_date = dates.VolumeDescriptorDate() self.volume_expiration_date.new(vol_expire_date) self.volume_effective_date = dates.VolumeDescriptorDate() self.volume_effective_date.new(now) if xa: if len(app_use) > 141: raise pycdlibexception.PyCdlibInvalidInput('Cannot have XA and an app_use of > 140 bytes') self.application_use = app_use.ljust(141, b' ') self.application_use += b'CD-XA001' + b'\x00' * 18 self.application_use = self.application_use.ljust(512, b' ') else: if len(app_use) > 512: raise pycdlibexception.PyCdlibInvalidInput('The maximum length for the application use is 512') self.application_use = app_use.ljust(512, b' ') self._initialized = True
[]
Please provide a description of the function:def copy(self, orig): # type: (PrimaryOrSupplementaryVD) -> None ''' A method to populate and initialize this VD object from the contents of an old VD. Parameters: orig_pvd - The original VD to copy data from. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is already initialized') self.version = orig.version self.flags = orig.flags self.system_identifier = orig.system_identifier self.volume_identifier = orig.volume_identifier self.escape_sequences = orig.escape_sequences self.space_size = orig.space_size self.set_size = orig.set_size self.seqnum = orig.seqnum self.log_block_size = orig.log_block_size self.path_tbl_size = orig.path_tbl_size self.path_table_location_le = orig.path_table_location_le self.optional_path_table_location_le = orig.optional_path_table_location_le self.path_table_location_be = orig.path_table_location_be self.optional_path_table_location_be = orig.optional_path_table_location_be # Root dir record is a DirectoryRecord object, and we want this copy to hold # onto exactly the same reference as the original self.root_dir_record = orig.root_dir_record self.volume_set_identifier = orig.volume_set_identifier # publisher_identifier is a FileOrTextIdentifier object, and we want this copy to # hold onto exactly the same reference as the original self.publisher_identifier = orig.publisher_identifier # preparer_identifier is a FileOrTextIdentifier object, and we want this copy to # hold onto exactly the same reference as the original self.preparer_identifier = orig.preparer_identifier # application_identifier is a FileOrTextIdentifier object, and we want this copy to # hold onto exactly the same reference as the original self.application_identifier = orig.application_identifier self.copyright_file_identifier = orig.copyright_file_identifier self.abstract_file_identifier = orig.abstract_file_identifier self.bibliographic_file_identifier = orig.bibliographic_file_identifier # volume_creation_date is a VolumeDescriptorDate object, and we want this copy to # hold onto exactly the same reference as the original self.volume_creation_date = orig.volume_creation_date # volume_expiration_date is a VolumeDescriptorDate object, and we want this copy to # hold onto exactly the same reference as the original self.volume_expiration_date = orig.volume_expiration_date # volume_effective_date is a VolumeDescriptorDate object, and we want this copy to # hold onto exactly the same reference as the original self.volume_effective_date = orig.volume_effective_date self.file_structure_version = orig.file_structure_version self.application_use = orig.application_use self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate the string representing this Volume Descriptor. Parameters: None. Returns: A string representing this Volume Descriptor. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') vol_mod_date = dates.VolumeDescriptorDate() vol_mod_date.new(time.time()) return struct.pack(self.FMT, self._vd_type, b'CD001', self.version, self.flags, self.system_identifier, self.volume_identifier, 0, self.space_size, utils.swab_32bit(self.space_size), self.escape_sequences, self.set_size, utils.swab_16bit(self.set_size), self.seqnum, utils.swab_16bit(self.seqnum), self.log_block_size, utils.swab_16bit(self.log_block_size), self.path_tbl_size, utils.swab_32bit(self.path_tbl_size), self.path_table_location_le, self.optional_path_table_location_le, utils.swab_32bit(self.path_table_location_be), self.optional_path_table_location_be, self.root_dir_record.record(), self.volume_set_identifier, self.publisher_identifier.record(), self.preparer_identifier.record(), self.application_identifier.record(), self.copyright_file_identifier, self.abstract_file_identifier, self.bibliographic_file_identifier, self.volume_creation_date.record(), vol_mod_date.record(), self.volume_expiration_date.record(), self.volume_effective_date.record(), self.file_structure_version, 0, self.application_use, b'\x00' * 653)
[]
Please provide a description of the function:def track_rr_ce_entry(self, extent, offset, length): # type: (int, int, int) -> rockridge.RockRidgeContinuationBlock ''' Start tracking a new Rock Ridge Continuation Entry entry in this Volume Descriptor, at the extent, offset, and length provided. Since Rock Ridge Continuation Blocks are shared across multiple Rock Ridge Directory Records, the most logical place to track them is in the PVD. This method is expected to be used during parse time, when an extent, offset and length are already assigned to the entry. Parameters: extent - The extent that this Continuation Entry lives at. offset - The offset within the extent that this Continuation Entry lives at. length - The length of this Continuation Entry. Returns: The object representing the block in which the Continuation Entry was placed in. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized') for block in self.rr_ce_blocks: if block.extent_location() == extent: break else: # We didn't find it in the list, add it block = rockridge.RockRidgeContinuationBlock(extent, self.log_block_size) self.rr_ce_blocks.append(block) block.track_entry(offset, length) return block
[]
Please provide a description of the function:def add_rr_ce_entry(self, length): # type: (int) -> Tuple[bool, rockridge.RockRidgeContinuationBlock, int] ''' Add a new Rock Ridge Continuation Entry to this PVD; see track_rr_ce_entry() above for why we track these in the PVD. This method is used to add a new Continuation Entry anywhere it fits in the list of Continuation Blocks. If it doesn't fit in any of the existing blocks, a new block for it is allocated. Parameters: length - The length of the Continuation Entry that should be added. Returns: A 3-tuple consisting of whether we added a new block, the object representing the block that this entry was added to, and the offset within the block that the entry was added to. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized') added_block = False for block in self.rr_ce_blocks: offset = block.add_entry(length) if offset is not None: break else: # We didn't find a block this would fit in; add one. block = rockridge.RockRidgeContinuationBlock(0, self.log_block_size) self.rr_ce_blocks.append(block) offset = block.add_entry(length) added_block = True return (added_block, block, offset)
[]
Please provide a description of the function:def clear_rr_ce_entries(self): # type: () -> None ''' A method to clear out all of the extent locations of all Rock Ridge Continuation Entries that the PVD is tracking. This can be used to reset all data before assigning new data. Parameters: None. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized') for block in self.rr_ce_blocks: block.set_extent_location(-1)
[]
Please provide a description of the function:def add_to_space_size(self, addition_bytes): # type: (int) -> None ''' A method to add bytes to the space size tracked by this Volume Descriptor. Parameters: addition_bytes - The number of bytes to add to the space size. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') # The 'addition' parameter is expected to be in bytes, but the space # size we track is in extents. Round up to the next extent. self.space_size += utils.ceiling_div(addition_bytes, self.log_block_size)
[]
Please provide a description of the function:def remove_from_space_size(self, removal_bytes): # type: (int) -> None ''' Remove bytes from the volume descriptor. Parameters: removal_bytes - The number of bytes to remove. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') # The 'removal' parameter is expected to be in bytes, but the space # size we track is in extents. Round up to the next extent. self.space_size -= utils.ceiling_div(removal_bytes, self.log_block_size)
[]
Please provide a description of the function:def add_to_ptr_size(self, ptr_size): # type: (int) -> bool ''' Add the space for a path table record to the volume descriptor. Parameters: ptr_size - The length of the Path Table Record being added to this Volume Descriptor. Returns: True if extents need to be added to the Volume Descriptor, False otherwise. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') # First add to the path table size. self.path_tbl_size += ptr_size if (utils.ceiling_div(self.path_tbl_size, 4096) * 2) > self.path_table_num_extents: # If we overflowed the path table size, then we need to update the # space size. Since we always add two extents for the little and # two for the big, add four total extents. The locations will be # fixed up during reshuffle_extents. self.path_table_num_extents += 2 return True return False
[]
Please provide a description of the function:def remove_from_ptr_size(self, ptr_size): # type: (int) -> bool ''' Remove the space for a path table record from the volume descriptor. Parameters: ptr_size - The length of the Path Table Record being removed from this Volume Descriptor. Returns: True if extents need to be removed from the Volume Descriptor, False otherwise. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') # Next remove from the Path Table Record size. self.path_tbl_size -= ptr_size new_extents = utils.ceiling_div(self.path_tbl_size, 4096) * 2 need_remove_extents = False if new_extents > self.path_table_num_extents: # This should never happen. raise pycdlibexception.PyCdlibInvalidInput('This should never happen') elif new_extents < self.path_table_num_extents: self.path_table_num_extents -= 2 need_remove_extents = True return need_remove_extents
[]
Please provide a description of the function:def copy_sizes(self, othervd): # type: (PrimaryOrSupplementaryVD) -> None ''' Copy the path_tbl_size, path_table_num_extents, and space_size from another volume descriptor. Parameters: othervd - The other volume descriptor to copy from. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized') self.space_size = othervd.space_size self.path_tbl_size = othervd.path_tbl_size self.path_table_num_extents = othervd.path_table_num_extents
[]
Please provide a description of the function:def parse(self, ident_str): # type: (bytes) -> None ''' Parse a file or text identifier out of a string. Parameters: ident_str - The string to parse the file or text identifier from. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('This File or Text identifier is already initialized') self.text = ident_str # FIXME: we do not support a file identifier here. In the future, we # might want to implement this. self._initialized = True
[]
Please provide a description of the function:def new(self, text): # type: (bytes) -> None ''' Create a new file or text identifier. Parameters: text - The text to store into the identifier. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('This File or Text identifier is already initialized') if len(text) != 128: raise pycdlibexception.PyCdlibInvalidInput('Length of text must be 128') self.text = text self._initialized = True
[]
Please provide a description of the function:def parse(self, vd, extent_loc): # type: (bytes, int) -> None ''' A method to parse a Volume Descriptor Set Terminator out of a string. Parameters: vd - The string to parse. extent_loc - The extent this VDST is currently located at. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('Volume Descriptor Set Terminator already initialized') (descriptor_type, identifier, version, zero_unused) = struct.unpack_from(self.FMT, vd, 0) # According to Ecma-119, 8.3.1, the volume descriptor set terminator # type should be 255 if descriptor_type != VOLUME_DESCRIPTOR_TYPE_SET_TERMINATOR: raise pycdlibexception.PyCdlibInvalidISO('Invalid VDST descriptor type') # According to Ecma-119, 8.3.2, the identifier should be 'CD001' if identifier != b'CD001': raise pycdlibexception.PyCdlibInvalidISO('Invalid VDST identifier') # According to Ecma-119, 8.3.3, the version should be 1 if version != 1: raise pycdlibexception.PyCdlibInvalidISO('Invalid VDST version') # According to Ecma-119, 8.3.4, the rest of the terminator should be 0; # however, we have seen ISOs in the wild that put stuff into this field. # Just ignore it. self.orig_extent_loc = extent_loc self._initialized = True
[]
Please provide a description of the function:def parse(self, vd, extent_loc): # type: (bytes, int) -> None ''' A method to parse a Boot Record out of a string. Parameters: vd - The string to parse the Boot Record out of. extent_loc - The extent location this Boot Record is current at. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('Boot Record already initialized') (descriptor_type, identifier, version, self.boot_system_identifier, self.boot_identifier, self.boot_system_use) = struct.unpack_from(self.FMT, vd, 0) # According to Ecma-119, 8.2.1, the boot record type should be 0 if descriptor_type != VOLUME_DESCRIPTOR_TYPE_BOOT_RECORD: raise pycdlibexception.PyCdlibInvalidISO('Invalid boot record descriptor type') # According to Ecma-119, 8.2.2, the identifier should be 'CD001' if identifier != b'CD001': raise pycdlibexception.PyCdlibInvalidISO('Invalid boot record identifier') # According to Ecma-119, 8.2.3, the version should be 1 if version != 1: raise pycdlibexception.PyCdlibInvalidISO('Invalid boot record version') self.orig_extent_loc = extent_loc self._initialized = True
[]
Please provide a description of the function:def new(self, boot_system_id): # type: (bytes) -> None ''' A method to create a new Boot Record. Parameters: boot_system_id - The system identifier to associate with this Boot Record. Returns: Nothing. ''' if self._initialized: raise Exception('Boot Record already initialized') self.boot_system_identifier = boot_system_id.ljust(32, b'\x00') self.boot_identifier = b'\x00' * 32 self.boot_system_use = b'\x00' * 197 # This will be set later self._initialized = True
[]
Please provide a description of the function:def record(self): # type: () -> bytes ''' A method to generate a string representing this Boot Record. Parameters: None. Returns: A string representing this Boot Record. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('Boot Record not yet initialized') return struct.pack(self.FMT, VOLUME_DESCRIPTOR_TYPE_BOOT_RECORD, b'CD001', 1, self.boot_system_identifier, self.boot_identifier, self.boot_system_use)
[]
Please provide a description of the function:def update_boot_system_use(self, boot_sys_use): # type: (bytes) -> None ''' A method to update the boot system use field of this Boot Record. Parameters: boot_sys_use - The new boot system use field for this Boot Record. Returns: Nothing. ''' if not self._initialized: raise pycdlibexception.PyCdlibInternalError('Boot Record not yet initialized') self.boot_system_use = boot_sys_use.ljust(197, b'\x00')
[]
Please provide a description of the function:def parse(self, data, extent): # type: (bytes, int) -> bool ''' Do a parse of a Version Volume Descriptor. This consists of seeing whether the data is either all zero or starts with 'MKI', and if so, setting the extent location of the Version Volume Descriptor properly. Parameters: data - The potential version data. extent - The location of the extent on the original ISO of this Version Volume Descriptor. Returns: True if the data passed in is a Version Descriptor, False otherwise. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('This Version Volume Descriptor is already initialized') if data[:3] == b'MKI' or data == allzero: # OK, we have a version descriptor. self._data = data self.orig_extent_loc = extent self._initialized = True return True return False
[]