id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
21,700 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionMap.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Map already initialized'",
")",
"(",
"map_type",
",",
"map_length",
... | Parse the passed in data into a UDF Partition Map.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Partition",
"Map",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1582-L1605 |
21,701 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionMap.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Map already initialized'",
")",
"self",
".",
"part_num",
"=",
"0",
"# FIXME: we should let... | A method to create a new UDF Partition Map.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Partition",
"Map",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1622-L1637 |
21,702 | clalancette/pycdlib | pycdlib/udf.py | UDFLongAD.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long Allocation descriptor already initialized'",
")",
"(",
"self",
".",
"extent... | Parse the passed in data into a UDF Long AD.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Long",
"AD",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1653-L1668 |
21,703 | clalancette/pycdlib | pycdlib/udf.py | UDFLongAD.record | 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) | python | 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) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long AD not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
... | A method to generate the string representing this UDF Long AD.
Parameters:
None.
Returns:
A string representing this UDF Long AD. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Long",
"AD",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1670-L1684 |
21,704 | clalancette/pycdlib | pycdlib/udf.py | UDFLongAD.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
",",
"length",
",",
"blocknum",
")",
":",
"# type: (int, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long AD already initialized'",
")",
"self",
".",
"extent_l... | A method to create a new UDF Long AD.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Long",
"AD",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1686-L1704 |
21,705 | clalancette/pycdlib | pycdlib/udf.py | UDFLongAD.set_extent_location | 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) | python | 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) | [
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
",",
"tag_location",
")",
":",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long AD not initialized'",
")... | 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. | [
"A",
"method",
"to",
"set",
"the",
"location",
"fields",
"of",
"this",
"UDF",
"Long",
"AD",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1706-L1721 |
21,706 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor already ini... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1741-L1790 |
21,707 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeDescriptor.record | 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 | python | 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 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(... | A method to generate the string representing this UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Logical",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1792-L1814 |
21,708 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeDescriptor.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
... | A method to create a new UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1834-L1871 |
21,709 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeDescriptor.set_integrity_location | 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 | python | 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 | [
"def",
"set_integrity_location",
"(",
"self",
",",
"integrity_extent",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor not initialized'",
")",
... | 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. | [
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"the",
"UDF",
"Integrity",
"sequence",
"that",
"this",
"descriptor",
"references",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1889-L1902 |
21,710 | clalancette/pycdlib | pycdlib/udf.py | UDFUnallocatedSpaceDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Unallocated Space Descriptor already ... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Unallocated",
"Space",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1919-L1944 |
21,711 | clalancette/pycdlib | pycdlib/udf.py | UDFTerminatingDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor already initialized'",
")",
"self"... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Terminating",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2033-L2051 |
21,712 | clalancette/pycdlib | pycdlib/udf.py | UDFTerminatingDescriptor.record | 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 | python | 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 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
... | A method to generate the string representing this UDF Terminating
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Terminating Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Terminating",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2053-L2068 |
21,713 | clalancette/pycdlib | pycdlib/udf.py | UDFTerminatingDescriptor.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")... | A method to create a new UDF Terminating Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Terminating",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2087-L2103 |
21,714 | clalancette/pycdlib | pycdlib/udf.py | UDFTerminatingDescriptor.set_extent_location | 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 | python | 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 | [
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
",",
"tag_location",
"=",
"None",
")",
":",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating De... | 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. | [
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"this",
"UDF",
"Terminating",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2105-L2122 |
21,715 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeHeaderDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Header Descriptor already initialized'",
")",
"(",
"self",
".",
"... | Parse the passed in data into a UDF Logical Volume Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Header",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2137-L2151 |
21,716 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeHeaderDescriptor.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Header Descriptor already initialized'",
")",
"self",
".",
"unique_id",
"=",
"261",
"... | A method to create a new UDF Logical Volume Header Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Header",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2169-L2184 |
21,717 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeImplementationUse.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Implementation Use already initialized'",
")",
"(",
"impl_id",
",",... | Parse the passed in data into a UDF Logical Volume Implementation Use.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Implementation",
"Use",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2201-L2223 |
21,718 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeImplementationUse.record | 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 | python | 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 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Implementation Use not initialized'",
")",
"return",
"struct",
".",
"pack",
... | 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. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Logical",
"Volume",
"Implementation",
"Use",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2225-L2243 |
21,719 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeImplementationUse.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Implementation Use already initialized'",
")",
"self",
".",
"impl_id",
"=",
"UDFEntityI... | A method to create a new UDF Logical Volume Implementation Use.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Implementation",
"Use",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2245-L2269 |
21,720 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeIntegrityDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor a... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2288-L2341 |
21,721 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeIntegrityDescriptor.record | 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 | python | 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 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"p... | 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. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2343-L2363 |
21,722 | clalancette/pycdlib | pycdlib/udf.py | UDFLogicalVolumeIntegrityDescriptor.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag"... | A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2383-L2412 |
21,723 | clalancette/pycdlib | pycdlib/udf.py | UDFFileSetDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor already initializ... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"File",
"Set",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2448-L2499 |
21,724 | clalancette/pycdlib | pycdlib/udf.py | UDFFileSetDescriptor.record | 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 | python | 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 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"... | A method to generate the string representing this UDF File Set
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Set Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"File",
"Set",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2501-L2523 |
21,725 | clalancette/pycdlib | pycdlib/udf.py | UDFFileSetDescriptor.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
... | A method to create a new UDF File Set Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"File",
"Set",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2542-L2575 |
21,726 | clalancette/pycdlib | pycdlib/udf.py | UDFFileSetDescriptor.set_extent_location | 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 | python | 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 | [
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor not initialized'",
")",
"self",
"."... | 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. | [
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"this",
"UDF",
"File",
"Set",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2577-L2590 |
21,727 | clalancette/pycdlib | pycdlib/udf.py | UDFICBTag.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF ICB Tag already initialized'",
")",
"(",
"self",
".",
"prior_num_direct_entries"... | Parse the passed in data into a UDF ICB Tag.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"ICB",
"Tag",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2607-L2631 |
21,728 | clalancette/pycdlib | pycdlib/udf.py | UDFICBTag.record | 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) | python | 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) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF ICB Tag not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
... | A method to generate the string representing this UDF ICB Tag.
Parameters:
None.
Returns:
A string representing this UDF ICB Tag. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"ICB",
"Tag",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2633-L2650 |
21,729 | clalancette/pycdlib | pycdlib/udf.py | UDFICBTag.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
",",
"file_type",
")",
":",
"# type: (str) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF ICB Tag already initialized'",
")",
"self",
".",
"prior_num_direct_entries",
"=... | 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. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"ICB",
"Tag",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2652-L2682 |
21,730 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"parent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, Optional[UDFFileEntry], UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"File",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2709-L2777 |
21,731 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.record | 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 | python | 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 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
... | A method to generate the string representing this UDF File Entry.
Parameters:
None.
Returns:
A string representing this UDF File Entry. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"File",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2779-L2805 |
21,732 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
",",
"length",
",",
"file_type",
",",
"parent",
",",
"log_block_size",
")",
":",
"# type: (int, str, Optional[UDFFileEntry], int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"("... | 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. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"File",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2824-L2903 |
21,733 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.add_file_ident_desc | 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 | python | 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 | [
"def",
"add_file_ident_desc",
"(",
"self",
",",
"new_fi_desc",
",",
"logical_block_size",
")",
":",
"# type: (UDFFileIdentifierDescriptor, int) -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Fil... | 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. | [
"A",
"method",
"to",
"add",
"a",
"new",
"UDF",
"File",
"Identifier",
"Descriptor",
"to",
"this",
"UDF",
"File",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2923-L2960 |
21,734 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.remove_file_ident_desc_by_name | 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 | python | 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 | [
"def",
"remove_file_ident_desc_by_name",
"(",
"self",
",",
"name",
",",
"logical_block_size",
")",
":",
"# type: (bytes, int) -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initia... | 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. | [
"A",
"method",
"to",
"remove",
"a",
"UDF",
"File",
"Identifier",
"Descriptor",
"from",
"this",
"UDF",
"File",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2962-L3005 |
21,735 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.set_data_location | 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 | python | 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 | [
"def",
"set_data_location",
"(",
"self",
",",
"current_extent",
",",
"start_extent",
")",
":",
"# pylint: disable=unused-argument",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
... | 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. | [
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"the",
"data",
"that",
"this",
"UDF",
"File",
"Entry",
"points",
"to",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3007-L3025 |
21,736 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.set_data_length | 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 | python | 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 | [
"def",
"set_data_length",
"(",
"self",
",",
"length",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Directory Record not yet initialized'",
")",
"len_diff",
"=",
"leng... | 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. | [
"A",
"method",
"to",
"set",
"the",
"length",
"of",
"the",
"data",
"that",
"this",
"UDF",
"File",
"Entry",
"points",
"to",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3042-L3080 |
21,737 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.file_identifier | 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 | python | 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 | [
"def",
"file_identifier",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"if",
"self",
".",
"file_ident",
"is",
"Non... | 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. | [
"A",
"method",
"to",
"get",
"the",
"name",
"of",
"this",
"UDF",
"File",
"Entry",
"as",
"a",
"byte",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3124-L3140 |
21,738 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.find_file_ident_desc_by_name | 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 | python | 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 | [
"def",
"find_file_ident_desc_by_name",
"(",
"self",
",",
"currpath",
")",
":",
"# type: (bytes) -> UDFFileIdentifierDescriptor",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
... | 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. | [
"A",
"method",
"to",
"find",
"a",
"UDF",
"File",
"Identifier",
"descriptor",
"by",
"its",
"name",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3142-L3182 |
21,739 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.track_file_ident_desc | 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) | python | 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) | [
"def",
"track_file_ident_desc",
"(",
"self",
",",
"file_ident",
")",
":",
"# type: (UDFFileIdentifierDescriptor) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
... | 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. | [
"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",
... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3184-L3200 |
21,740 | clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.finish_directory_parse | 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') | python | 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') | [
"def",
"finish_directory_parse",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"if",
"self",
".",
"icb_tag",
".",
"f... | 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. | [
"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",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3202-L3218 |
21,741 | clalancette/pycdlib | pycdlib/udf.py | UDFFileIdentifierDescriptor.length | 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) | python | 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) | [
"def",
"length",
"(",
"cls",
",",
"namelen",
")",
":",
"# type: (Type[UDFFileIdentifierDescriptor], int) -> int",
"if",
"namelen",
">",
"0",
":",
"namelen",
"+=",
"1",
"to_add",
"=",
"struct",
".",
"calcsize",
"(",
"cls",
".",
"FMT",
")",
"+",
"namelen",
"re... | 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. | [
"A",
"class",
"method",
"to",
"calculate",
"the",
"size",
"this",
"UDFFileIdentifierDescriptor",
"would",
"take",
"up",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3276-L3291 |
21,742 | clalancette/pycdlib | pycdlib/udf.py | UDFFileIdentifierDescriptor.parse | 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) | python | 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) | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
",",
"parent",
")",
":",
"# type: (bytes, int, UDFTag, UDFFileEntry) -> int",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File ... | 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. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"File",
"Identifier",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3309-L3371 |
21,743 | clalancette/pycdlib | pycdlib/udf.py | UDFFileIdentifierDescriptor.record | 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:] | python | 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:] | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Identifier Descriptor not initialized'",
")",
"if",
"self",
".",
"len_fi",
">",
"0... | A method to generate the string representing this UDF File Identifier Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Identifier Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"File",
"Identifier",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3401-L3429 |
21,744 | clalancette/pycdlib | pycdlib/udf.py | UDFFileIdentifierDescriptor.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
",",
"isdir",
",",
"isparent",
",",
"name",
",",
"parent",
")",
":",
"# type: (bool, bool, bytes, Optional[UDFFileEntry]) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UD... | 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. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"File",
"Identifier",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3448-L3494 |
21,745 | clalancette/pycdlib | pycdlib/udf.py | UDFFileIdentifierDescriptor.set_icb | 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) | python | 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) | [
"def",
"set_icb",
"(",
"self",
",",
"new_location",
",",
"tag_location",
")",
":",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Identifier not initialized'",
")",
... | 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. | [
"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",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3515-L3531 |
21,746 | clalancette/pycdlib | pycdlib/headervd.py | pvd_factory | 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 | python | 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 | [
"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_fil... | 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. | [
"An",
"internal",
"function",
"to",
"create",
"a",
"Primary",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L746-L785 |
21,747 | clalancette/pycdlib | pycdlib/headervd.py | enhanced_vd_factory | 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 | python | 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 | [
"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",
",",
"b... | 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. | [
"An",
"internal",
"function",
"to",
"create",
"an",
"Enhanced",
"Volume",
"Descriptor",
"for",
"ISO",
"1999",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L788-L828 |
21,748 | clalancette/pycdlib | pycdlib/headervd.py | joliet_vd_factory | 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 | python | 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 | [
"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_f... | 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. | [
"An",
"internal",
"function",
"to",
"create",
"an",
"Joliet",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L831-L880 |
21,749 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.copy | 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 | python | 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 | [
"def",
"copy",
"(",
"self",
",",
"orig",
")",
":",
"# type: (PrimaryOrSupplementaryVD) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is already initialized'",
")",
"self",
".",
"... | 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. | [
"A",
"method",
"to",
"populate",
"and",
"initialize",
"this",
"VD",
"object",
"from",
"the",
"contents",
"of",
"an",
"old",
"VD",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L336-L392 |
21,750 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.record | 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) | python | 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) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"vol_mod_date",
"=",
"dates",
".",
"Vol... | A method to generate the string representing this Volume Descriptor.
Parameters:
None.
Returns:
A string representing this Volume Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L394-L446 |
21,751 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.track_rr_ce_entry | 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 | python | 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 | [
"def",
"track_rr_ce_entry",
"(",
"self",
",",
"extent",
",",
"offset",
",",
"length",
")",
":",
"# type: (int, int, int) -> rockridge.RockRidgeContinuationBlock",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(... | 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. | [
"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",
"a... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L448-L480 |
21,752 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.clear_rr_ce_entries | 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) | python | 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) | [
"def",
"clear_rr_ce_entries",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Primary Volume Descriptor is not yet initialized'",
")",
"for",
"block",
"in",
... | 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. | [
"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",
"as... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L515-L531 |
21,753 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.add_to_space_size | 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) | python | 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) | [
"def",
"add_to_space_size",
"(",
"self",
",",
"addition_bytes",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# The ... | 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. | [
"A",
"method",
"to",
"add",
"bytes",
"to",
"the",
"space",
"size",
"tracked",
"by",
"this",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L548-L563 |
21,754 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.remove_from_space_size | 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) | python | 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) | [
"def",
"remove_from_space_size",
"(",
"self",
",",
"removal_bytes",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# ... | Remove bytes from the volume descriptor.
Parameters:
removal_bytes - The number of bytes to remove.
Returns:
Nothing. | [
"Remove",
"bytes",
"from",
"the",
"volume",
"descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L565-L579 |
21,755 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.add_to_ptr_size | 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 | python | 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 | [
"def",
"add_to_ptr_size",
"(",
"self",
",",
"ptr_size",
")",
":",
"# type: (int) -> bool",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# First add to... | 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. | [
"Add",
"the",
"space",
"for",
"a",
"path",
"table",
"record",
"to",
"the",
"volume",
"descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L613-L635 |
21,756 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.remove_from_ptr_size | 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 | python | 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 | [
"def",
"remove_from_ptr_size",
"(",
"self",
",",
"ptr_size",
")",
":",
"# type: (int) -> bool",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# Next re... | 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. | [
"Remove",
"the",
"space",
"for",
"a",
"path",
"table",
"record",
"from",
"the",
"volume",
"descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L637-L662 |
21,757 | clalancette/pycdlib | pycdlib/headervd.py | PrimaryOrSupplementaryVD.copy_sizes | 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 | python | 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 | [
"def",
"copy_sizes",
"(",
"self",
",",
"othervd",
")",
":",
"# type: (PrimaryOrSupplementaryVD) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
... | 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. | [
"Copy",
"the",
"path_tbl_size",
"path_table_num_extents",
"and",
"space_size",
"from",
"another",
"volume",
"descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L679-L695 |
21,758 | clalancette/pycdlib | pycdlib/headervd.py | FileOrTextIdentifier.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"ident_str",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This File or Text identifier is already initialized'",
")",
"self",
".",
"text",
... | 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. | [
"Parse",
"a",
"file",
"or",
"text",
"identifier",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L904-L921 |
21,759 | clalancette/pycdlib | pycdlib/headervd.py | FileOrTextIdentifier.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
",",
"text",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This File or Text identifier is already initialized'",
")",
"if",
"len",
"(",
"text",
... | Create a new file or text identifier.
Parameters:
text - The text to store into the identifier.
Returns:
Nothing. | [
"Create",
"a",
"new",
"file",
"or",
"text",
"identifier",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L923-L941 |
21,760 | clalancette/pycdlib | pycdlib/headervd.py | VolumeDescriptorSetTerminator.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"vd",
",",
"extent_loc",
")",
":",
"# type: (bytes, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Volume Descriptor Set Terminator already initialized'",
")",
"("... | 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. | [
"A",
"method",
"to",
"parse",
"a",
"Volume",
"Descriptor",
"Set",
"Terminator",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L978-L1011 |
21,761 | clalancette/pycdlib | pycdlib/headervd.py | BootRecord.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"vd",
",",
"extent_loc",
")",
":",
"# type: (bytes, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Boot Record already initialized'",
")",
"(",
"descriptor_type"... | 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. | [
"A",
"method",
"to",
"parse",
"a",
"Boot",
"Record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L1105-L1135 |
21,762 | clalancette/pycdlib | pycdlib/headervd.py | BootRecord.new | 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 | python | 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 | [
"def",
"new",
"(",
"self",
",",
"boot_system_id",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"Exception",
"(",
"'Boot Record already initialized'",
")",
"self",
".",
"boot_system_identifier",
"=",
"boot_system_id",
".",
"lj... | A method to create a new Boot Record.
Parameters:
boot_system_id - The system identifier to associate with this Boot
Record.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"Boot",
"Record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L1137-L1155 |
21,763 | clalancette/pycdlib | pycdlib/headervd.py | BootRecord.record | 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) | python | 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) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Boot Record not yet initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
"."... | A method to generate a string representing this Boot Record.
Parameters:
None.
Returns:
A string representing this Boot Record. | [
"A",
"method",
"to",
"generate",
"a",
"string",
"representing",
"this",
"Boot",
"Record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L1157-L1172 |
21,764 | clalancette/pycdlib | pycdlib/headervd.py | BootRecord.update_boot_system_use | 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') | python | 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') | [
"def",
"update_boot_system_use",
"(",
"self",
",",
"boot_sys_use",
")",
":",
"# type: (bytes) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Boot Record not yet initialized'",
")",
"self",
".",
... | 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. | [
"A",
"method",
"to",
"update",
"the",
"boot",
"system",
"use",
"field",
"of",
"this",
"Boot",
"Record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L1174-L1187 |
21,765 | clalancette/pycdlib | pycdlib/headervd.py | VersionVolumeDescriptor.parse | 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 | python | 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 | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
")",
":",
"# type: (bytes, int) -> bool",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Version Volume Descriptor is already initialized'",
")",
"if"... | 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. | [
"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",
... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L1234-L1258 |
21,766 | clalancette/pycdlib | pycdlib/headervd.py | VersionVolumeDescriptor.new | def new(self, log_block_size):
# type: (int) -> None
'''
Create a new Version Volume Descriptor.
Parameters:
log_block_size - The size of one extent.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Version Volume Descriptor is already initialized')
self._data = b'\x00' * log_block_size
self._initialized = True | python | def new(self, log_block_size):
# type: (int) -> None
'''
Create a new Version Volume Descriptor.
Parameters:
log_block_size - The size of one extent.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Version Volume Descriptor is already initialized')
self._data = b'\x00' * log_block_size
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"log_block_size",
")",
":",
"# type: (int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Version Volume Descriptor is already initialized'",
")",
"self",
".",
"_dat... | Create a new Version Volume Descriptor.
Parameters:
log_block_size - The size of one extent.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Version",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L1260-L1274 |
21,767 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootInfoTable.parse | def parse(self, vd, datastr, ino):
# type: (headervd.PrimaryOrSupplementaryVD, bytes, inode.Inode) -> bool
'''
A method to parse a boot info table out of a string.
Parameters:
vd - The Volume Descriptor associated with this Boot Info Table.
datastr - The string to parse the boot info table out of.
ino - The Inode associated with the boot file.
Returns:
True if this is a valid El Torito Boot Info Table, False otherwise.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table is already initialized')
(pvd_extent, rec_extent, self.orig_len,
self.csum) = struct.unpack_from('=LLLL', datastr, 0)
if pvd_extent != vd.extent_location() or rec_extent != ino.extent_location():
return False
self.vd = vd
self.inode = ino
self._initialized = True
return True | python | def parse(self, vd, datastr, ino):
# type: (headervd.PrimaryOrSupplementaryVD, bytes, inode.Inode) -> bool
'''
A method to parse a boot info table out of a string.
Parameters:
vd - The Volume Descriptor associated with this Boot Info Table.
datastr - The string to parse the boot info table out of.
ino - The Inode associated with the boot file.
Returns:
True if this is a valid El Torito Boot Info Table, False otherwise.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table is already initialized')
(pvd_extent, rec_extent, self.orig_len,
self.csum) = struct.unpack_from('=LLLL', datastr, 0)
if pvd_extent != vd.extent_location() or rec_extent != ino.extent_location():
return False
self.vd = vd
self.inode = ino
self._initialized = True
return True | [
"def",
"parse",
"(",
"self",
",",
"vd",
",",
"datastr",
",",
"ino",
")",
":",
"# type: (headervd.PrimaryOrSupplementaryVD, bytes, inode.Inode) -> bool",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Eltorit... | A method to parse a boot info table out of a string.
Parameters:
vd - The Volume Descriptor associated with this Boot Info Table.
datastr - The string to parse the boot info table out of.
ino - The Inode associated with the boot file.
Returns:
True if this is a valid El Torito Boot Info Table, False otherwise. | [
"A",
"method",
"to",
"parse",
"a",
"boot",
"info",
"table",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L52-L76 |
21,768 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootInfoTable.new | def new(self, vd, ino, orig_len, csum):
# type: (headervd.PrimaryOrSupplementaryVD, inode.Inode, int, int) -> None
'''
A method to create a new boot info table.
Parameters:
vd - The volume descriptor to associate with this boot info table.
ino - The Inode associated with this Boot Info Table.
orig_len - The original length of the file before the boot info table was patched into it.
csum - The checksum for the boot file, starting at the byte after the boot info table.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table is already initialized')
self.vd = vd
self.orig_len = orig_len
self.csum = csum
self.inode = ino
self._initialized = True | python | def new(self, vd, ino, orig_len, csum):
# type: (headervd.PrimaryOrSupplementaryVD, inode.Inode, int, int) -> None
'''
A method to create a new boot info table.
Parameters:
vd - The volume descriptor to associate with this boot info table.
ino - The Inode associated with this Boot Info Table.
orig_len - The original length of the file before the boot info table was patched into it.
csum - The checksum for the boot file, starting at the byte after the boot info table.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table is already initialized')
self.vd = vd
self.orig_len = orig_len
self.csum = csum
self.inode = ino
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"vd",
",",
"ino",
",",
"orig_len",
",",
"csum",
")",
":",
"# type: (headervd.PrimaryOrSupplementaryVD, inode.Inode, int, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(... | A method to create a new boot info table.
Parameters:
vd - The volume descriptor to associate with this boot info table.
ino - The Inode associated with this Boot Info Table.
orig_len - The original length of the file before the boot info table was patched into it.
csum - The checksum for the boot file, starting at the byte after the boot info table.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"boot",
"info",
"table",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L78-L97 |
21,769 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootInfoTable.record | def record(self):
# type: () -> bytes
'''
A method to generate a string representing this boot info table.
Parameters:
None.
Returns:
A string representing this boot info table.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table not yet initialized')
return struct.pack('=LLLL', self.vd.extent_location(),
self.inode.extent_location(), self.orig_len,
self.csum) + b'\x00' * 40 | python | def record(self):
# type: () -> bytes
'''
A method to generate a string representing this boot info table.
Parameters:
None.
Returns:
A string representing this boot info table.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table not yet initialized')
return struct.pack('=LLLL', self.vd.extent_location(),
self.inode.extent_location(), self.orig_len,
self.csum) + b'\x00' * 40 | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Eltorito Boot Info Table not yet initialized'",
")",
"return",
"struct",
".",
"pack",
"(... | A method to generate a string representing this boot info table.
Parameters:
None.
Returns:
A string representing this boot info table. | [
"A",
"method",
"to",
"generate",
"a",
"string",
"representing",
"this",
"boot",
"info",
"table",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L99-L114 |
21,770 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoValidationEntry.parse | def parse(self, valstr):
# type: (bytes) -> None
'''
A method to parse an El Torito Validation Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Validation Entry out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Validation Entry already initialized')
(header_id, self.platform_id, reserved_unused, self.id_string,
self.checksum, keybyte1,
keybyte2) = struct.unpack_from(self.FMT, valstr, 0)
if header_id != 1:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry header ID not 1')
if self.platform_id not in (0, 1, 2):
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry platform ID not valid')
if keybyte1 != 0x55:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry first keybyte not 0x55')
if keybyte2 != 0xaa:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry second keybyte not 0xaa')
# Now that we've done basic checking, calculate the checksum of the
# validation entry and make sure it is right.
if self._checksum(valstr) != 0:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry checksum not correct')
self._initialized = True | python | def parse(self, valstr):
# type: (bytes) -> None
'''
A method to parse an El Torito Validation Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Validation Entry out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Validation Entry already initialized')
(header_id, self.platform_id, reserved_unused, self.id_string,
self.checksum, keybyte1,
keybyte2) = struct.unpack_from(self.FMT, valstr, 0)
if header_id != 1:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry header ID not 1')
if self.platform_id not in (0, 1, 2):
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry platform ID not valid')
if keybyte1 != 0x55:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry first keybyte not 0x55')
if keybyte2 != 0xaa:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry second keybyte not 0xaa')
# Now that we've done basic checking, calculate the checksum of the
# validation entry and make sure it is right.
if self._checksum(valstr) != 0:
raise pycdlibexception.PyCdlibInvalidISO('El Torito Validation entry checksum not correct')
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"valstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Validation Entry already initialized'",
")",
"(",
"header_id",
",",
"sel... | A method to parse an El Torito Validation Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Validation Entry out of.
Returns:
Nothing. | [
"A",
"method",
"to",
"parse",
"an",
"El",
"Torito",
"Validation",
"Entry",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L183-L216 |
21,771 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoValidationEntry.new | def new(self, platform_id):
# type: (int) -> None
'''
A method to create a new El Torito Validation Entry.
Parameters:
platform_id - The platform ID to set for this validation entry.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Validation Entry already initialized')
self.platform_id = platform_id
self.id_string = b'\x00' * 24 # FIXME: let the user set this
self.checksum = 0
self.checksum = utils.swab_16bit(self._checksum(self._record()) - 1)
self._initialized = True | python | def new(self, platform_id):
# type: (int) -> None
'''
A method to create a new El Torito Validation Entry.
Parameters:
platform_id - The platform ID to set for this validation entry.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Validation Entry already initialized')
self.platform_id = platform_id
self.id_string = b'\x00' * 24 # FIXME: let the user set this
self.checksum = 0
self.checksum = utils.swab_16bit(self._checksum(self._record()) - 1)
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"platform_id",
")",
":",
"# type: (int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Validation Entry already initialized'",
")",
"self",
".",
"platform_id",
... | A method to create a new El Torito Validation Entry.
Parameters:
platform_id - The platform ID to set for this validation entry.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"El",
"Torito",
"Validation",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L218-L235 |
21,772 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoValidationEntry._record | def _record(self):
# type: () -> bytes
'''
An internal method to generate a string representing this El Torito
Validation Entry.
Parameters:
None.
Returns:
String representing this El Torito Validation Entry.
'''
return struct.pack(self.FMT, 1, self.platform_id, 0, self.id_string,
self.checksum, 0x55, 0xaa) | python | def _record(self):
# type: () -> bytes
'''
An internal method to generate a string representing this El Torito
Validation Entry.
Parameters:
None.
Returns:
String representing this El Torito Validation Entry.
'''
return struct.pack(self.FMT, 1, self.platform_id, 0, self.id_string,
self.checksum, 0x55, 0xaa) | [
"def",
"_record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"1",
",",
"self",
".",
"platform_id",
",",
"0",
",",
"self",
".",
"id_string",
",",
"self",
".",
"checksum",
",",
"0x55",
"... | An internal method to generate a string representing this El Torito
Validation Entry.
Parameters:
None.
Returns:
String representing this El Torito Validation Entry. | [
"An",
"internal",
"method",
"to",
"generate",
"a",
"string",
"representing",
"this",
"El",
"Torito",
"Validation",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L237-L249 |
21,773 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoEntry.parse | def parse(self, valstr):
# type: (bytes) -> None
'''
A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry already initialized')
(self.boot_indicator, self.boot_media_type, self.load_segment,
self.system_type, unused1, self.sector_count, self.load_rba,
self.selection_criteria_type,
self.selection_criteria) = struct.unpack_from(self.FMT, valstr, 0)
if self.boot_indicator not in (0x88, 0x00):
raise pycdlibexception.PyCdlibInvalidISO('Invalid El Torito initial entry boot indicator')
if self.boot_media_type > 4:
raise pycdlibexception.PyCdlibInvalidISO('Invalid El Torito boot media type')
# FIXME: check that the system type matches the partition table
if unused1 != 0:
raise pycdlibexception.PyCdlibInvalidISO('El Torito unused field must be 0')
# According to the specification, the El Torito unused end field (bytes
# 0xc - 0x1f, unused2 field) should be all zero. However, we have found
# ISOs in the wild where that is not the case, so skip that particular
# check here.
self._initialized = True | python | def parse(self, valstr):
# type: (bytes) -> None
'''
A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry already initialized')
(self.boot_indicator, self.boot_media_type, self.load_segment,
self.system_type, unused1, self.sector_count, self.load_rba,
self.selection_criteria_type,
self.selection_criteria) = struct.unpack_from(self.FMT, valstr, 0)
if self.boot_indicator not in (0x88, 0x00):
raise pycdlibexception.PyCdlibInvalidISO('Invalid El Torito initial entry boot indicator')
if self.boot_media_type > 4:
raise pycdlibexception.PyCdlibInvalidISO('Invalid El Torito boot media type')
# FIXME: check that the system type matches the partition table
if unused1 != 0:
raise pycdlibexception.PyCdlibInvalidISO('El Torito unused field must be 0')
# According to the specification, the El Torito unused end field (bytes
# 0xc - 0x1f, unused2 field) should be all zero. However, we have found
# ISOs in the wild where that is not the case, so skip that particular
# check here.
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"valstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Entry already initialized'",
")",
"(",
"self",
".",
"boot_indicator",
... | A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing. | [
"A",
"method",
"to",
"parse",
"an",
"El",
"Torito",
"Entry",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L306-L339 |
21,774 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoEntry.new | def new(self, sector_count, load_seg, media_name, system_type, bootable):
# type: (int, int, str, int, bool) -> None
'''
A method to create a new El Torito Entry.
Parameters:
sector_count - The number of sectors to assign to this El Torito Entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type to assign to the entry.
bootable - Whether this entry is bootable.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry already initialized')
if media_name == 'noemul':
media_type = self.MEDIA_NO_EMUL
elif media_name == 'floppy':
if sector_count == 2400:
media_type = self.MEDIA_12FLOPPY
elif sector_count == 2880:
media_type = self.MEDIA_144FLOPPY
elif sector_count == 5760:
media_type = self.MEDIA_288FLOPPY
else:
raise pycdlibexception.PyCdlibInvalidInput('Invalid sector count for floppy media type; must be 2400, 2880, or 5760')
# With floppy booting, the sector_count always ends up being 1
sector_count = 1
elif media_name == 'hdemul':
media_type = self.MEDIA_HD_EMUL
# With HD emul booting, the sector_count always ends up being 1
sector_count = 1
else:
raise pycdlibexception.PyCdlibInvalidInput("Invalid media name '%s'" % (media_name))
if bootable:
self.boot_indicator = 0x88
else:
self.boot_indicator = 0
self.boot_media_type = media_type
self.load_segment = load_seg
self.system_type = system_type
self.sector_count = sector_count
self.load_rba = 0 # This will get set later
self.selection_criteria_type = 0 # FIXME: allow the user to set this
self.selection_criteria = b''.ljust(19, b'\x00')
self._initialized = True | python | def new(self, sector_count, load_seg, media_name, system_type, bootable):
# type: (int, int, str, int, bool) -> None
'''
A method to create a new El Torito Entry.
Parameters:
sector_count - The number of sectors to assign to this El Torito Entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type to assign to the entry.
bootable - Whether this entry is bootable.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry already initialized')
if media_name == 'noemul':
media_type = self.MEDIA_NO_EMUL
elif media_name == 'floppy':
if sector_count == 2400:
media_type = self.MEDIA_12FLOPPY
elif sector_count == 2880:
media_type = self.MEDIA_144FLOPPY
elif sector_count == 5760:
media_type = self.MEDIA_288FLOPPY
else:
raise pycdlibexception.PyCdlibInvalidInput('Invalid sector count for floppy media type; must be 2400, 2880, or 5760')
# With floppy booting, the sector_count always ends up being 1
sector_count = 1
elif media_name == 'hdemul':
media_type = self.MEDIA_HD_EMUL
# With HD emul booting, the sector_count always ends up being 1
sector_count = 1
else:
raise pycdlibexception.PyCdlibInvalidInput("Invalid media name '%s'" % (media_name))
if bootable:
self.boot_indicator = 0x88
else:
self.boot_indicator = 0
self.boot_media_type = media_type
self.load_segment = load_seg
self.system_type = system_type
self.sector_count = sector_count
self.load_rba = 0 # This will get set later
self.selection_criteria_type = 0 # FIXME: allow the user to set this
self.selection_criteria = b''.ljust(19, b'\x00')
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"sector_count",
",",
"load_seg",
",",
"media_name",
",",
"system_type",
",",
"bootable",
")",
":",
"# type: (int, int, str, int, bool) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInterna... | A method to create a new El Torito Entry.
Parameters:
sector_count - The number of sectors to assign to this El Torito Entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type to assign to the entry.
bootable - Whether this entry is bootable.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"El",
"Torito",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L341-L390 |
21,775 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoEntry.set_inode | def set_inode(self, ino):
# type: (inode.Inode) -> None
'''
A method to set the Inode associated with this El Torito Entry.
Parameters:
ino - The Inode object corresponding to this entry.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not yet initialized')
self.inode = ino | python | def set_inode(self, ino):
# type: (inode.Inode) -> None
'''
A method to set the Inode associated with this El Torito Entry.
Parameters:
ino - The Inode object corresponding to this entry.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not yet initialized')
self.inode = ino | [
"def",
"set_inode",
"(",
"self",
",",
"ino",
")",
":",
"# type: (inode.Inode) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Entry not yet initialized'",
")",
"self",
".",
"inode",
... | A method to set the Inode associated with this El Torito Entry.
Parameters:
ino - The Inode object corresponding to this entry.
Returns:
Nothing. | [
"A",
"method",
"to",
"set",
"the",
"Inode",
"associated",
"with",
"this",
"El",
"Torito",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L422-L434 |
21,776 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoEntry.record | def record(self):
# type: () -> bytes
'''
A method to generate a string representing this El Torito Entry.
Parameters:
None.
Returns:
String representing this El Torito Entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not yet initialized')
return struct.pack(self.FMT, self.boot_indicator, self.boot_media_type,
self.load_segment, self.system_type, 0,
self.sector_count, self.load_rba,
self.selection_criteria_type,
self.selection_criteria) | python | def record(self):
# type: () -> bytes
'''
A method to generate a string representing this El Torito Entry.
Parameters:
None.
Returns:
String representing this El Torito Entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not yet initialized')
return struct.pack(self.FMT, self.boot_indicator, self.boot_media_type,
self.load_segment, self.system_type, 0,
self.sector_count, self.load_rba,
self.selection_criteria_type,
self.selection_criteria) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Entry not yet initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
... | A method to generate a string representing this El Torito Entry.
Parameters:
None.
Returns:
String representing this El Torito Entry. | [
"A",
"method",
"to",
"generate",
"a",
"string",
"representing",
"this",
"El",
"Torito",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L436-L453 |
21,777 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoEntry.set_data_length | def set_data_length(self, length):
# type: (int) -> None
'''
A method to set the length of data for this El Torito Entry.
Parameters:
length - The new length for the El Torito Entry.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not initialized')
self.sector_count = utils.ceiling_div(length, 512) | python | def set_data_length(self, length):
# type: (int) -> None
'''
A method to set the length of data for this El Torito Entry.
Parameters:
length - The new length for the El Torito Entry.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not initialized')
self.sector_count = utils.ceiling_div(length, 512) | [
"def",
"set_data_length",
"(",
"self",
",",
"length",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Entry not initialized'",
")",
"self",
".",
"sector_count"... | A method to set the length of data for this El Torito Entry.
Parameters:
length - The new length for the El Torito Entry.
Returns:
Nothing. | [
"A",
"method",
"to",
"set",
"the",
"length",
"of",
"data",
"for",
"this",
"El",
"Torito",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L471-L483 |
21,778 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoSectionHeader.parse | def parse(self, valstr):
# type: (bytes) -> None
'''
Parse an El Torito section header from a string.
Parameters:
valstr - The string to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header already initialized')
(self.header_indicator, self.platform_id, self.num_section_entries,
self.id_string) = struct.unpack_from(self.FMT, valstr, 0)
self._initialized = True | python | def parse(self, valstr):
# type: (bytes) -> None
'''
Parse an El Torito section header from a string.
Parameters:
valstr - The string to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header already initialized')
(self.header_indicator, self.platform_id, self.num_section_entries,
self.id_string) = struct.unpack_from(self.FMT, valstr, 0)
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"valstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Section Header already initialized'",
")",
"(",
"self",
".",
"header_ind... | Parse an El Torito section header from a string.
Parameters:
valstr - The string to parse.
Returns:
Nothing. | [
"Parse",
"an",
"El",
"Torito",
"section",
"header",
"from",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L500-L516 |
21,779 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoSectionHeader.new | def new(self, id_string, platform_id):
# type: (bytes, int) -> None
'''
Create a new El Torito section header.
Parameters:
id_string - The ID to use for this section header.
platform_id - The platform ID for this section header.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header already initialized')
# We always assume this is the last section, until we are told otherwise
# via set_record_not_last.
self.header_indicator = 0x91
self.platform_id = platform_id
self.num_section_entries = 0
self.id_string = id_string
self._initialized = True | python | def new(self, id_string, platform_id):
# type: (bytes, int) -> None
'''
Create a new El Torito section header.
Parameters:
id_string - The ID to use for this section header.
platform_id - The platform ID for this section header.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header already initialized')
# We always assume this is the last section, until we are told otherwise
# via set_record_not_last.
self.header_indicator = 0x91
self.platform_id = platform_id
self.num_section_entries = 0
self.id_string = id_string
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"id_string",
",",
"platform_id",
")",
":",
"# type: (bytes, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Section Header already initialized'",
")",
"# We... | Create a new El Torito section header.
Parameters:
id_string - The ID to use for this section header.
platform_id - The platform ID for this section header.
Returns:
Nothing. | [
"Create",
"a",
"new",
"El",
"Torito",
"section",
"header",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L518-L538 |
21,780 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoSectionHeader.add_parsed_entry | def add_parsed_entry(self, entry):
# type: (EltoritoEntry) -> None
'''
A method to add a parsed entry to the list of entries of this header.
If the number of parsed entries exceeds what was expected from the
initial parsing of the header, this method will throw an Exception.
Parameters:
entry - The EltoritoEntry object to add to the list of entries.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
if len(self.section_entries) >= self.num_section_entries:
raise pycdlibexception.PyCdlibInvalidInput('Eltorito section had more entries than expected by section header; ISO is corrupt')
self.section_entries.append(entry) | python | def add_parsed_entry(self, entry):
# type: (EltoritoEntry) -> None
'''
A method to add a parsed entry to the list of entries of this header.
If the number of parsed entries exceeds what was expected from the
initial parsing of the header, this method will throw an Exception.
Parameters:
entry - The EltoritoEntry object to add to the list of entries.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
if len(self.section_entries) >= self.num_section_entries:
raise pycdlibexception.PyCdlibInvalidInput('Eltorito section had more entries than expected by section header; ISO is corrupt')
self.section_entries.append(entry) | [
"def",
"add_parsed_entry",
"(",
"self",
",",
"entry",
")",
":",
"# type: (EltoritoEntry) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Section Header not yet initialized'",
")",
"if",
... | A method to add a parsed entry to the list of entries of this header.
If the number of parsed entries exceeds what was expected from the
initial parsing of the header, this method will throw an Exception.
Parameters:
entry - The EltoritoEntry object to add to the list of entries.
Returns:
Nothing. | [
"A",
"method",
"to",
"add",
"a",
"parsed",
"entry",
"to",
"the",
"list",
"of",
"entries",
"of",
"this",
"header",
".",
"If",
"the",
"number",
"of",
"parsed",
"entries",
"exceeds",
"what",
"was",
"expected",
"from",
"the",
"initial",
"parsing",
"of",
"the... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L540-L558 |
21,781 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoSectionHeader.add_new_entry | def add_new_entry(self, entry):
# type: (EltoritoEntry) -> None
'''
A method to add a completely new entry to the list of entries of this
header.
Parameters:
entry - The new EltoritoEntry object to add to the list of entries.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
self.num_section_entries += 1
self.section_entries.append(entry) | python | def add_new_entry(self, entry):
# type: (EltoritoEntry) -> None
'''
A method to add a completely new entry to the list of entries of this
header.
Parameters:
entry - The new EltoritoEntry object to add to the list of entries.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
self.num_section_entries += 1
self.section_entries.append(entry) | [
"def",
"add_new_entry",
"(",
"self",
",",
"entry",
")",
":",
"# type: (EltoritoEntry) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Section Header not yet initialized'",
")",
"self",
"... | A method to add a completely new entry to the list of entries of this
header.
Parameters:
entry - The new EltoritoEntry object to add to the list of entries.
Returns:
Nothing. | [
"A",
"method",
"to",
"add",
"a",
"completely",
"new",
"entry",
"to",
"the",
"list",
"of",
"entries",
"of",
"this",
"header",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L560-L576 |
21,782 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoSectionHeader.record | def record(self):
# type: () -> bytes
'''
Get a string representing this El Torito section header.
Parameters:
None.
Returns:
A string representing this El Torito section header.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
outlist = [struct.pack(self.FMT, self.header_indicator,
self.platform_id, self.num_section_entries,
self.id_string)]
for entry in self.section_entries:
outlist.append(entry.record())
return b''.join(outlist) | python | def record(self):
# type: () -> bytes
'''
Get a string representing this El Torito section header.
Parameters:
None.
Returns:
A string representing this El Torito section header.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
outlist = [struct.pack(self.FMT, self.header_indicator,
self.platform_id, self.num_section_entries,
self.id_string)]
for entry in self.section_entries:
outlist.append(entry.record())
return b''.join(outlist) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Section Header not yet initialized'",
")",
"outlist",
"=",
"[",
"struct",
".",
"p... | Get a string representing this El Torito section header.
Parameters:
None.
Returns:
A string representing this El Torito section header. | [
"Get",
"a",
"string",
"representing",
"this",
"El",
"Torito",
"section",
"header",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L594-L614 |
21,783 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootCatalog.parse | def parse(self, valstr):
# type: (bytes) -> bool
'''
A method to parse an El Torito Boot Catalog out of a string.
Parameters:
valstr - The string to parse the El Torito Boot Catalog out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog already initialized')
if self.state == self.EXPECTING_VALIDATION_ENTRY:
# The first entry in an El Torito boot catalog is the Validation
# Entry. A Validation entry consists of 32 bytes (described in
# detail in the parse_eltorito_validation_entry() method).
self.validation_entry.parse(valstr)
self.state = self.EXPECTING_INITIAL_ENTRY
elif self.state == self.EXPECTING_INITIAL_ENTRY:
# The next entry is the Initial/Default entry. An Initial/Default
# entry consists of 32 bytes (described in detail in the
# parse_eltorito_initial_entry() method).
self.initial_entry.parse(valstr)
self.state = self.EXPECTING_SECTION_HEADER_OR_DONE
else:
val = bytes(bytearray([valstr[0]]))
if val == b'\x00':
# An empty entry tells us we are done parsing El Torito. Do
# some sanity checks.
last_section_index = len(self.sections) - 1
for index, sec in enumerate(self.sections):
if sec.num_section_entries != len(sec.section_entries):
raise pycdlibexception.PyCdlibInvalidISO('El Torito section header specified %d entries, only saw %d' % (sec.num_section_entries, len(sec.section_entries)))
if index != last_section_index:
if sec.header_indicator != 0x90:
raise pycdlibexception.PyCdlibInvalidISO('Intermediate El Torito section header not properly specified')
# In theory, we should also make sure that the very last
# section has a header_indicator of 0x91. However, we
# have seen ISOs in the wild (FreeBSD 11.0 amd64) in which
# this is not the case, so we skip that check.
self._initialized = True
elif val in (b'\x90', b'\x91'):
# A Section Header Entry
section_header = EltoritoSectionHeader()
section_header.parse(valstr)
self.sections.append(section_header)
elif val in (b'\x88', b'\x00'):
# A Section Entry. According to El Torito 2.4, a Section Entry
# must follow a Section Header, but we have seen ISOs in the
# wild that do not follow this (Mageia 4 ISOs, for instance).
# To deal with this, we get a little complicated here. If there
# is a previous section header, and the length of the entries
# attached to it is less than the number of entries it should
# have, then we attach this entry to that header. If there is
# no previous section header, or if the previous section header
# is already 'full', then we make this a standalone entry.
secentry = EltoritoEntry()
secentry.parse(valstr)
if self.sections and len(self.sections[-1].section_entries) < self.sections[-1].num_section_entries:
self.sections[-1].add_parsed_entry(secentry)
else:
self.standalone_entries.append(secentry)
elif val == b'\x44':
# A Section Entry Extension
self.sections[-1].section_entries[-1].selection_criteria += valstr[2:]
else:
raise pycdlibexception.PyCdlibInvalidISO('Invalid El Torito Boot Catalog entry')
return self._initialized | python | def parse(self, valstr):
# type: (bytes) -> bool
'''
A method to parse an El Torito Boot Catalog out of a string.
Parameters:
valstr - The string to parse the El Torito Boot Catalog out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog already initialized')
if self.state == self.EXPECTING_VALIDATION_ENTRY:
# The first entry in an El Torito boot catalog is the Validation
# Entry. A Validation entry consists of 32 bytes (described in
# detail in the parse_eltorito_validation_entry() method).
self.validation_entry.parse(valstr)
self.state = self.EXPECTING_INITIAL_ENTRY
elif self.state == self.EXPECTING_INITIAL_ENTRY:
# The next entry is the Initial/Default entry. An Initial/Default
# entry consists of 32 bytes (described in detail in the
# parse_eltorito_initial_entry() method).
self.initial_entry.parse(valstr)
self.state = self.EXPECTING_SECTION_HEADER_OR_DONE
else:
val = bytes(bytearray([valstr[0]]))
if val == b'\x00':
# An empty entry tells us we are done parsing El Torito. Do
# some sanity checks.
last_section_index = len(self.sections) - 1
for index, sec in enumerate(self.sections):
if sec.num_section_entries != len(sec.section_entries):
raise pycdlibexception.PyCdlibInvalidISO('El Torito section header specified %d entries, only saw %d' % (sec.num_section_entries, len(sec.section_entries)))
if index != last_section_index:
if sec.header_indicator != 0x90:
raise pycdlibexception.PyCdlibInvalidISO('Intermediate El Torito section header not properly specified')
# In theory, we should also make sure that the very last
# section has a header_indicator of 0x91. However, we
# have seen ISOs in the wild (FreeBSD 11.0 amd64) in which
# this is not the case, so we skip that check.
self._initialized = True
elif val in (b'\x90', b'\x91'):
# A Section Header Entry
section_header = EltoritoSectionHeader()
section_header.parse(valstr)
self.sections.append(section_header)
elif val in (b'\x88', b'\x00'):
# A Section Entry. According to El Torito 2.4, a Section Entry
# must follow a Section Header, but we have seen ISOs in the
# wild that do not follow this (Mageia 4 ISOs, for instance).
# To deal with this, we get a little complicated here. If there
# is a previous section header, and the length of the entries
# attached to it is less than the number of entries it should
# have, then we attach this entry to that header. If there is
# no previous section header, or if the previous section header
# is already 'full', then we make this a standalone entry.
secentry = EltoritoEntry()
secentry.parse(valstr)
if self.sections and len(self.sections[-1].section_entries) < self.sections[-1].num_section_entries:
self.sections[-1].add_parsed_entry(secentry)
else:
self.standalone_entries.append(secentry)
elif val == b'\x44':
# A Section Entry Extension
self.sections[-1].section_entries[-1].selection_criteria += valstr[2:]
else:
raise pycdlibexception.PyCdlibInvalidISO('Invalid El Torito Boot Catalog entry')
return self._initialized | [
"def",
"parse",
"(",
"self",
",",
"valstr",
")",
":",
"# type: (bytes) -> bool",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Boot Catalog already initialized'",
")",
"if",
"self",
".",
"state",
"... | A method to parse an El Torito Boot Catalog out of a string.
Parameters:
valstr - The string to parse the El Torito Boot Catalog out of.
Returns:
Nothing. | [
"A",
"method",
"to",
"parse",
"an",
"El",
"Torito",
"Boot",
"Catalog",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L641-L710 |
21,784 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootCatalog.new | def new(self, br, ino, sector_count, load_seg, media_name, system_type,
platform_id, bootable):
# type: (headervd.BootRecord, inode.Inode, int, int, str, int, int, bool) -> None
'''
A method to create a new El Torito Boot Catalog.
Parameters:
br - The boot record that this El Torito Boot Catalog is associated with.
ino - The Inode to associate with the initial entry.
sector_count - The number of sectors for the initial entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type the entry should be.
platform_id - The platform id to set in the validation entry.
bootable - Whether this entry should be bootable.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog already initialized')
# Create the El Torito validation entry
self.validation_entry.new(platform_id)
self.initial_entry.new(sector_count, load_seg, media_name, system_type,
bootable)
self.initial_entry.set_inode(ino)
ino.linked_records.append(self.initial_entry)
self.br = br
self._initialized = True | python | def new(self, br, ino, sector_count, load_seg, media_name, system_type,
platform_id, bootable):
# type: (headervd.BootRecord, inode.Inode, int, int, str, int, int, bool) -> None
'''
A method to create a new El Torito Boot Catalog.
Parameters:
br - The boot record that this El Torito Boot Catalog is associated with.
ino - The Inode to associate with the initial entry.
sector_count - The number of sectors for the initial entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type the entry should be.
platform_id - The platform id to set in the validation entry.
bootable - Whether this entry should be bootable.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog already initialized')
# Create the El Torito validation entry
self.validation_entry.new(platform_id)
self.initial_entry.new(sector_count, load_seg, media_name, system_type,
bootable)
self.initial_entry.set_inode(ino)
ino.linked_records.append(self.initial_entry)
self.br = br
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"br",
",",
"ino",
",",
"sector_count",
",",
"load_seg",
",",
"media_name",
",",
"system_type",
",",
"platform_id",
",",
"bootable",
")",
":",
"# type: (headervd.BootRecord, inode.Inode, int, int, str, int, int, bool) -> None",
"if",
"se... | A method to create a new El Torito Boot Catalog.
Parameters:
br - The boot record that this El Torito Boot Catalog is associated with.
ino - The Inode to associate with the initial entry.
sector_count - The number of sectors for the initial entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type the entry should be.
platform_id - The platform id to set in the validation entry.
bootable - Whether this entry should be bootable.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"El",
"Torito",
"Boot",
"Catalog",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L712-L743 |
21,785 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootCatalog.add_section | def add_section(self, ino, sector_count, load_seg, media_name, system_type,
efi, bootable):
# type: (inode.Inode, int, int, str, int, bool, bool) -> None
'''
A method to add an section header and entry to this Boot Catalog.
Parameters:
ino - The Inode object to associate with the new Entry.
sector_count - The number of sectors to assign to the new Entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The type of partition this entry should be.
efi - Whether this section is an EFI section.
bootable - Whether this entry should be bootable.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
# The Eltorito Boot Catalog can only be 2048 bytes (1 extent). By
# default, the first 64 bytes are used by the Validation Entry and the
# Initial Entry, which leaves 1984 bytes. Each section takes up 32
# bytes for the Section Header and 32 bytes for the Section Entry, for
# a total of 64 bytes, so we can have a maximum of 1984/64 = 31
# sections.
if len(self.sections) == 31:
raise pycdlibexception.PyCdlibInvalidInput('Too many Eltorito sections')
sec = EltoritoSectionHeader()
platform_id = self.validation_entry.platform_id
if efi:
platform_id = 0xef
sec.new(b'\x00' * 28, platform_id)
secentry = EltoritoEntry()
secentry.new(sector_count, load_seg, media_name, system_type, bootable)
secentry.set_inode(ino)
ino.linked_records.append(secentry)
sec.add_new_entry(secentry)
if self.sections:
self.sections[-1].set_record_not_last()
self.sections.append(sec) | python | def add_section(self, ino, sector_count, load_seg, media_name, system_type,
efi, bootable):
# type: (inode.Inode, int, int, str, int, bool, bool) -> None
'''
A method to add an section header and entry to this Boot Catalog.
Parameters:
ino - The Inode object to associate with the new Entry.
sector_count - The number of sectors to assign to the new Entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The type of partition this entry should be.
efi - Whether this section is an EFI section.
bootable - Whether this entry should be bootable.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
# The Eltorito Boot Catalog can only be 2048 bytes (1 extent). By
# default, the first 64 bytes are used by the Validation Entry and the
# Initial Entry, which leaves 1984 bytes. Each section takes up 32
# bytes for the Section Header and 32 bytes for the Section Entry, for
# a total of 64 bytes, so we can have a maximum of 1984/64 = 31
# sections.
if len(self.sections) == 31:
raise pycdlibexception.PyCdlibInvalidInput('Too many Eltorito sections')
sec = EltoritoSectionHeader()
platform_id = self.validation_entry.platform_id
if efi:
platform_id = 0xef
sec.new(b'\x00' * 28, platform_id)
secentry = EltoritoEntry()
secentry.new(sector_count, load_seg, media_name, system_type, bootable)
secentry.set_inode(ino)
ino.linked_records.append(secentry)
sec.add_new_entry(secentry)
if self.sections:
self.sections[-1].set_record_not_last()
self.sections.append(sec) | [
"def",
"add_section",
"(",
"self",
",",
"ino",
",",
"sector_count",
",",
"load_seg",
",",
"media_name",
",",
"system_type",
",",
"efi",
",",
"bootable",
")",
":",
"# type: (inode.Inode, int, int, str, int, bool, bool) -> None",
"if",
"not",
"self",
".",
"_initialize... | A method to add an section header and entry to this Boot Catalog.
Parameters:
ino - The Inode object to associate with the new Entry.
sector_count - The number of sectors to assign to the new Entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The type of partition this entry should be.
efi - Whether this section is an EFI section.
bootable - Whether this entry should be bootable.
Returns:
Nothing. | [
"A",
"method",
"to",
"add",
"an",
"section",
"header",
"and",
"entry",
"to",
"this",
"Boot",
"Catalog",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L745-L790 |
21,786 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootCatalog.record | def record(self):
# type: () -> bytes
'''
A method to generate a string representing this El Torito Boot Catalog.
Parameters:
None.
Returns:
A string representing this El Torito Boot Catalog.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
outlist = [self.validation_entry.record(), self.initial_entry.record()]
for sec in self.sections:
outlist.append(sec.record())
for entry in self.standalone_entries:
outlist.append(entry.record())
return b''.join(outlist) | python | def record(self):
# type: () -> bytes
'''
A method to generate a string representing this El Torito Boot Catalog.
Parameters:
None.
Returns:
A string representing this El Torito Boot Catalog.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
outlist = [self.validation_entry.record(), self.initial_entry.record()]
for sec in self.sections:
outlist.append(sec.record())
for entry in self.standalone_entries:
outlist.append(entry.record())
return b''.join(outlist) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Boot Catalog not yet initialized'",
")",
"outlist",
"=",
"[",
"self",
".",
"valid... | A method to generate a string representing this El Torito Boot Catalog.
Parameters:
None.
Returns:
A string representing this El Torito Boot Catalog. | [
"A",
"method",
"to",
"generate",
"a",
"string",
"representing",
"this",
"El",
"Torito",
"Boot",
"Catalog",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L792-L813 |
21,787 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootCatalog.add_dirrecord | def add_dirrecord(self, rec):
# type: (Union[dr.DirectoryRecord, udfmod.UDFFileEntry]) -> None
'''
A method to set the Directory Record associated with this Boot Catalog.
Parameters:
rec - The DirectoryRecord object to associate with this Boot Catalog.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
self.dirrecords.append(rec) | python | def add_dirrecord(self, rec):
# type: (Union[dr.DirectoryRecord, udfmod.UDFFileEntry]) -> None
'''
A method to set the Directory Record associated with this Boot Catalog.
Parameters:
rec - The DirectoryRecord object to associate with this Boot Catalog.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
self.dirrecords.append(rec) | [
"def",
"add_dirrecord",
"(",
"self",
",",
"rec",
")",
":",
"# type: (Union[dr.DirectoryRecord, udfmod.UDFFileEntry]) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Boot Catalog not yet initia... | A method to set the Directory Record associated with this Boot Catalog.
Parameters:
rec - The DirectoryRecord object to associate with this Boot Catalog.
Returns:
Nothing. | [
"A",
"method",
"to",
"set",
"the",
"Directory",
"Record",
"associated",
"with",
"this",
"Boot",
"Catalog",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L815-L828 |
21,788 | clalancette/pycdlib | pycdlib/eltorito.py | EltoritoBootCatalog.update_catalog_extent | def update_catalog_extent(self, current_extent):
# type: (int) -> None
'''
A method to update the extent associated with this Boot Catalog.
Parameters:
current_extent - New extent to associate with this Boot Catalog
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
self.br.update_boot_system_use(struct.pack('=L', current_extent)) | python | def update_catalog_extent(self, current_extent):
# type: (int) -> None
'''
A method to update the extent associated with this Boot Catalog.
Parameters:
current_extent - New extent to associate with this Boot Catalog
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')
self.br.update_boot_system_use(struct.pack('=L', current_extent)) | [
"def",
"update_catalog_extent",
"(",
"self",
",",
"current_extent",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Boot Catalog not yet initialized'",
")",
"self"... | A method to update the extent associated with this Boot Catalog.
Parameters:
current_extent - New extent to associate with this Boot Catalog
Returns:
Nothing. | [
"A",
"method",
"to",
"update",
"the",
"extent",
"associated",
"with",
"this",
"Boot",
"Catalog",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L857-L870 |
21,789 | clalancette/pycdlib | pycdlib/pycdlib.py | _check_d1_characters | def _check_d1_characters(name):
# type: (bytes) -> None
'''
A function to check that a name only uses d1 characters as defined by ISO9660.
Parameters:
name - The name to check.
Returns:
Nothing.
'''
bytename = bytearray(name)
for char in bytename:
if char not in _allowed_d1_characters:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must consist of characters A-Z, 0-9, and _') | python | def _check_d1_characters(name):
# type: (bytes) -> None
'''
A function to check that a name only uses d1 characters as defined by ISO9660.
Parameters:
name - The name to check.
Returns:
Nothing.
'''
bytename = bytearray(name)
for char in bytename:
if char not in _allowed_d1_characters:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must consist of characters A-Z, 0-9, and _') | [
"def",
"_check_d1_characters",
"(",
"name",
")",
":",
"# type: (bytes) -> None",
"bytename",
"=",
"bytearray",
"(",
"name",
")",
"for",
"char",
"in",
"bytename",
":",
"if",
"char",
"not",
"in",
"_allowed_d1_characters",
":",
"raise",
"pycdlibexception",
".",
"Py... | A function to check that a name only uses d1 characters as defined by ISO9660.
Parameters:
name - The name to check.
Returns:
Nothing. | [
"A",
"function",
"to",
"check",
"that",
"a",
"name",
"only",
"uses",
"d1",
"characters",
"as",
"defined",
"by",
"ISO9660",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L68-L81 |
21,790 | clalancette/pycdlib | pycdlib/pycdlib.py | _split_iso9660_filename | def _split_iso9660_filename(fullname):
# type: (bytes) -> Tuple[bytes, bytes, bytes]
'''
A function to split an ISO 9660 filename into its constituent parts. This
is the name, the extension, and the version number.
Parameters:
fullname - The name to split.
Returns:
A tuple containing the name, extension, and version.
'''
namesplit = fullname.split(b';')
version = b''
if len(namesplit) > 1:
version = namesplit.pop()
rest = b';'.join(namesplit)
dotsplit = rest.split(b'.')
if len(dotsplit) == 1:
name = dotsplit[0]
extension = b''
else:
name = b'.'.join(dotsplit[:-1])
extension = dotsplit[-1]
return (name, extension, version) | python | def _split_iso9660_filename(fullname):
# type: (bytes) -> Tuple[bytes, bytes, bytes]
'''
A function to split an ISO 9660 filename into its constituent parts. This
is the name, the extension, and the version number.
Parameters:
fullname - The name to split.
Returns:
A tuple containing the name, extension, and version.
'''
namesplit = fullname.split(b';')
version = b''
if len(namesplit) > 1:
version = namesplit.pop()
rest = b';'.join(namesplit)
dotsplit = rest.split(b'.')
if len(dotsplit) == 1:
name = dotsplit[0]
extension = b''
else:
name = b'.'.join(dotsplit[:-1])
extension = dotsplit[-1]
return (name, extension, version) | [
"def",
"_split_iso9660_filename",
"(",
"fullname",
")",
":",
"# type: (bytes) -> Tuple[bytes, bytes, bytes]",
"namesplit",
"=",
"fullname",
".",
"split",
"(",
"b';'",
")",
"version",
"=",
"b''",
"if",
"len",
"(",
"namesplit",
")",
">",
"1",
":",
"version",
"=",
... | A function to split an ISO 9660 filename into its constituent parts. This
is the name, the extension, and the version number.
Parameters:
fullname - The name to split.
Returns:
A tuple containing the name, extension, and version. | [
"A",
"function",
"to",
"split",
"an",
"ISO",
"9660",
"filename",
"into",
"its",
"constituent",
"parts",
".",
"This",
"is",
"the",
"name",
"the",
"extension",
"and",
"the",
"version",
"number",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L84-L110 |
21,791 | clalancette/pycdlib | pycdlib/pycdlib.py | _check_iso9660_filename | def _check_iso9660_filename(fullname, interchange_level):
# type: (bytes, int) -> None
'''
A function to check that a file identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Nothing.
'''
# Check to ensure the name is a valid filename for the ISO according to
# Ecma-119 7.5.
(name, extension, version) = _split_iso9660_filename(fullname)
# Ecma-119 says that filenames must end with a semicolon-number, but I have
# found CDs (Ubuntu 14.04 Desktop i386, for instance) that do not follow
# this. Thus we allow for names both with and without the semi+version.
# Ecma-119 says that filenames must have a version number, but I have
# found CDs (FreeBSD 10.1 amd64) that do not have any version number.
# Allow for this.
if version != b'' and (int(version) < 1 or int(version) > 32767):
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must have a version between 1 and 32767')
# Ecma-119 section 7.5.1 specifies that filenames must have at least one
# character in either the name or the extension.
if not name and not extension:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must have a non-empty name or extension')
if b';' in name or b';' in extension:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must contain exactly one semicolon')
if interchange_level == 1:
# According to Ecma-119, section 10.1, at level 1 the filename can
# only be up to 8 d-characters or d1-characters, and the extension can
# only be up to 3 d-characters or 3 d1-characters.
if len(name) > 8 or len(extension) > 3:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames at interchange level 1 cannot have more than 8 characters or 3 characters in the extension')
else:
# For all other interchange levels, the maximum filename length is
# specified in Ecma-119 7.5.2. However, I have found CDs (Ubuntu 14.04
# Desktop i386, for instance) that don't conform to this. Skip the
# check until we know how long is allowed.
pass
# Ecma-119 section 7.5.1 says that the file name and extension each contain
# zero or more d-characters or d1-characters. While the definition of
# d-characters and d1-characters is not specified in Ecma-119,
# http://wiki.osdev.org/ISO_9660 suggests that this consists of A-Z, 0-9, _
# which seems to correlate with empirical evidence. Thus we check for that
# here.
if interchange_level < 4:
_check_d1_characters(name)
_check_d1_characters(extension) | python | def _check_iso9660_filename(fullname, interchange_level):
# type: (bytes, int) -> None
'''
A function to check that a file identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Nothing.
'''
# Check to ensure the name is a valid filename for the ISO according to
# Ecma-119 7.5.
(name, extension, version) = _split_iso9660_filename(fullname)
# Ecma-119 says that filenames must end with a semicolon-number, but I have
# found CDs (Ubuntu 14.04 Desktop i386, for instance) that do not follow
# this. Thus we allow for names both with and without the semi+version.
# Ecma-119 says that filenames must have a version number, but I have
# found CDs (FreeBSD 10.1 amd64) that do not have any version number.
# Allow for this.
if version != b'' and (int(version) < 1 or int(version) > 32767):
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must have a version between 1 and 32767')
# Ecma-119 section 7.5.1 specifies that filenames must have at least one
# character in either the name or the extension.
if not name and not extension:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must have a non-empty name or extension')
if b';' in name or b';' in extension:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames must contain exactly one semicolon')
if interchange_level == 1:
# According to Ecma-119, section 10.1, at level 1 the filename can
# only be up to 8 d-characters or d1-characters, and the extension can
# only be up to 3 d-characters or 3 d1-characters.
if len(name) > 8 or len(extension) > 3:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 filenames at interchange level 1 cannot have more than 8 characters or 3 characters in the extension')
else:
# For all other interchange levels, the maximum filename length is
# specified in Ecma-119 7.5.2. However, I have found CDs (Ubuntu 14.04
# Desktop i386, for instance) that don't conform to this. Skip the
# check until we know how long is allowed.
pass
# Ecma-119 section 7.5.1 says that the file name and extension each contain
# zero or more d-characters or d1-characters. While the definition of
# d-characters and d1-characters is not specified in Ecma-119,
# http://wiki.osdev.org/ISO_9660 suggests that this consists of A-Z, 0-9, _
# which seems to correlate with empirical evidence. Thus we check for that
# here.
if interchange_level < 4:
_check_d1_characters(name)
_check_d1_characters(extension) | [
"def",
"_check_iso9660_filename",
"(",
"fullname",
",",
"interchange_level",
")",
":",
"# type: (bytes, int) -> None",
"# Check to ensure the name is a valid filename for the ISO according to",
"# Ecma-119 7.5.",
"(",
"name",
",",
"extension",
",",
"version",
")",
"=",
"_split_... | A function to check that a file identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Nothing. | [
"A",
"function",
"to",
"check",
"that",
"a",
"file",
"identifier",
"conforms",
"to",
"the",
"ISO9660",
"rules",
"for",
"a",
"particular",
"interchange",
"level",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L113-L171 |
21,792 | clalancette/pycdlib | pycdlib/pycdlib.py | _check_iso9660_directory | def _check_iso9660_directory(fullname, interchange_level):
# type: (bytes, int) -> None
'''
A function to check that an directory identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Nothing.
'''
# Check to ensure the directory name is valid for the ISO according to
# Ecma-119 7.6.
# Ecma-119 section 7.6.1 says that a directory identifier needs at least one
# character
if not fullname:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 directory names must be at least 1 character long')
maxlen = float('inf')
if interchange_level == 1:
# Ecma-119 section 10.1 says that directory identifiers lengths cannot
# exceed 8 at interchange level 1.
maxlen = 8
elif interchange_level in (2, 3):
# Ecma-119 section 7.6.3 says that directory identifiers lengths cannot
# exceed 207.
maxlen = 207
# for interchange_level 4, we allow any length
if len(fullname) > maxlen:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 directory names at interchange level %d cannot exceed %d characters' % (interchange_level, maxlen))
# Ecma-119 section 7.6.1 says that directory names consist of one or more
# d-characters or d1-characters. While the definition of d-characters and
# d1-characters is not specified in Ecma-119,
# http://wiki.osdev.org/ISO_9660 suggests that this consists of A-Z, 0-9, _
# which seems to correlate with empirical evidence. Thus we check for that
# here.
if interchange_level < 4:
_check_d1_characters(fullname) | python | def _check_iso9660_directory(fullname, interchange_level):
# type: (bytes, int) -> None
'''
A function to check that an directory identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Nothing.
'''
# Check to ensure the directory name is valid for the ISO according to
# Ecma-119 7.6.
# Ecma-119 section 7.6.1 says that a directory identifier needs at least one
# character
if not fullname:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 directory names must be at least 1 character long')
maxlen = float('inf')
if interchange_level == 1:
# Ecma-119 section 10.1 says that directory identifiers lengths cannot
# exceed 8 at interchange level 1.
maxlen = 8
elif interchange_level in (2, 3):
# Ecma-119 section 7.6.3 says that directory identifiers lengths cannot
# exceed 207.
maxlen = 207
# for interchange_level 4, we allow any length
if len(fullname) > maxlen:
raise pycdlibexception.PyCdlibInvalidInput('ISO9660 directory names at interchange level %d cannot exceed %d characters' % (interchange_level, maxlen))
# Ecma-119 section 7.6.1 says that directory names consist of one or more
# d-characters or d1-characters. While the definition of d-characters and
# d1-characters is not specified in Ecma-119,
# http://wiki.osdev.org/ISO_9660 suggests that this consists of A-Z, 0-9, _
# which seems to correlate with empirical evidence. Thus we check for that
# here.
if interchange_level < 4:
_check_d1_characters(fullname) | [
"def",
"_check_iso9660_directory",
"(",
"fullname",
",",
"interchange_level",
")",
":",
"# type: (bytes, int) -> None",
"# Check to ensure the directory name is valid for the ISO according to",
"# Ecma-119 7.6.",
"# Ecma-119 section 7.6.1 says that a directory identifier needs at least one",
... | A function to check that an directory identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Nothing. | [
"A",
"function",
"to",
"check",
"that",
"an",
"directory",
"identifier",
"conforms",
"to",
"the",
"ISO9660",
"rules",
"for",
"a",
"particular",
"interchange",
"level",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L174-L215 |
21,793 | clalancette/pycdlib | pycdlib/pycdlib.py | _interchange_level_from_filename | def _interchange_level_from_filename(fullname):
# type: (bytes) -> int
'''
A function to determine the ISO interchange level from the filename.
In theory, there are 3 levels, but in practice we only deal with level 1
and level 3.
Parameters:
name - The name to use to determine the interchange level.
Returns:
The interchange level determined from this filename.
'''
(name, extension, version) = _split_iso9660_filename(fullname)
interchange_level = 1
if version != b'' and (int(version) < 1 or int(version) > 32767):
interchange_level = 3
if b';' in name or b';' in extension:
interchange_level = 3
if len(name) > 8 or len(extension) > 3:
interchange_level = 3
try:
_check_d1_characters(name)
_check_d1_characters(extension)
except pycdlibexception.PyCdlibInvalidInput:
interchange_level = 3
return interchange_level | python | def _interchange_level_from_filename(fullname):
# type: (bytes) -> int
'''
A function to determine the ISO interchange level from the filename.
In theory, there are 3 levels, but in practice we only deal with level 1
and level 3.
Parameters:
name - The name to use to determine the interchange level.
Returns:
The interchange level determined from this filename.
'''
(name, extension, version) = _split_iso9660_filename(fullname)
interchange_level = 1
if version != b'' and (int(version) < 1 or int(version) > 32767):
interchange_level = 3
if b';' in name or b';' in extension:
interchange_level = 3
if len(name) > 8 or len(extension) > 3:
interchange_level = 3
try:
_check_d1_characters(name)
_check_d1_characters(extension)
except pycdlibexception.PyCdlibInvalidInput:
interchange_level = 3
return interchange_level | [
"def",
"_interchange_level_from_filename",
"(",
"fullname",
")",
":",
"# type: (bytes) -> int",
"(",
"name",
",",
"extension",
",",
"version",
")",
"=",
"_split_iso9660_filename",
"(",
"fullname",
")",
"interchange_level",
"=",
"1",
"if",
"version",
"!=",
"b''",
"... | A function to determine the ISO interchange level from the filename.
In theory, there are 3 levels, but in practice we only deal with level 1
and level 3.
Parameters:
name - The name to use to determine the interchange level.
Returns:
The interchange level determined from this filename. | [
"A",
"function",
"to",
"determine",
"the",
"ISO",
"interchange",
"level",
"from",
"the",
"filename",
".",
"In",
"theory",
"there",
"are",
"3",
"levels",
"but",
"in",
"practice",
"we",
"only",
"deal",
"with",
"level",
"1",
"and",
"level",
"3",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L218-L249 |
21,794 | clalancette/pycdlib | pycdlib/pycdlib.py | _interchange_level_from_directory | def _interchange_level_from_directory(name):
# type: (bytes) -> int
'''
A function to determine the ISO interchange level from the directory name.
In theory, there are 3 levels, but in practice we only deal with level 1
and level 3.
Parameters:
name - The name to use to determine the interchange level.
Returns:
The interchange level determined from this filename.
'''
interchange_level = 1
if len(name) > 8:
interchange_level = 3
try:
_check_d1_characters(name)
except pycdlibexception.PyCdlibInvalidInput:
interchange_level = 3
return interchange_level | python | def _interchange_level_from_directory(name):
# type: (bytes) -> int
'''
A function to determine the ISO interchange level from the directory name.
In theory, there are 3 levels, but in practice we only deal with level 1
and level 3.
Parameters:
name - The name to use to determine the interchange level.
Returns:
The interchange level determined from this filename.
'''
interchange_level = 1
if len(name) > 8:
interchange_level = 3
try:
_check_d1_characters(name)
except pycdlibexception.PyCdlibInvalidInput:
interchange_level = 3
return interchange_level | [
"def",
"_interchange_level_from_directory",
"(",
"name",
")",
":",
"# type: (bytes) -> int",
"interchange_level",
"=",
"1",
"if",
"len",
"(",
"name",
")",
">",
"8",
":",
"interchange_level",
"=",
"3",
"try",
":",
"_check_d1_characters",
"(",
"name",
")",
"except... | A function to determine the ISO interchange level from the directory name.
In theory, there are 3 levels, but in practice we only deal with level 1
and level 3.
Parameters:
name - The name to use to determine the interchange level.
Returns:
The interchange level determined from this filename. | [
"A",
"function",
"to",
"determine",
"the",
"ISO",
"interchange",
"level",
"from",
"the",
"directory",
"name",
".",
"In",
"theory",
"there",
"are",
"3",
"levels",
"but",
"in",
"practice",
"we",
"only",
"deal",
"with",
"level",
"1",
"and",
"level",
"3",
".... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L252-L273 |
21,795 | clalancette/pycdlib | pycdlib/pycdlib.py | _yield_children | def _yield_children(rec):
# type: (dr.DirectoryRecord) -> Generator
'''
An internal function to gather and yield all of the children of a Directory
Record.
Parameters:
rec - The Directory Record to get all of the children from (must be a
directory)
Yields:
Children of this Directory Record.
Returns:
Nothing.
'''
if not rec.is_dir():
raise pycdlibexception.PyCdlibInvalidInput('Record is not a directory!')
last = b''
for child in rec.children:
# Check to see if the filename of this child is the same as the
# last one, and if so, skip the child. This can happen if we
# have very large files with more than one directory entry.
fi = child.file_identifier()
if fi == last:
continue
last = fi
if child.rock_ridge is not None and child.rock_ridge.child_link_record_exists() and child.rock_ridge.cl_to_moved_dr is not None and child.rock_ridge.cl_to_moved_dr.parent is not None:
# If this is the case, this is a relocated entry. We actually
# want to go find the entry this was relocated to; we do that
# by following the child_link, then going up to the parent and
# finding the entry that links to the same one as this one.
cl_parent = child.rock_ridge.cl_to_moved_dr.parent
for cl_child in cl_parent.children:
if cl_child.rock_ridge is not None and cl_child.rock_ridge.name() == child.rock_ridge.name():
child = cl_child
break
# If we ended up not finding the right one in the parent of the
# moved entry, weird, but just return the one we would have
# anyway.
yield child | python | def _yield_children(rec):
# type: (dr.DirectoryRecord) -> Generator
'''
An internal function to gather and yield all of the children of a Directory
Record.
Parameters:
rec - The Directory Record to get all of the children from (must be a
directory)
Yields:
Children of this Directory Record.
Returns:
Nothing.
'''
if not rec.is_dir():
raise pycdlibexception.PyCdlibInvalidInput('Record is not a directory!')
last = b''
for child in rec.children:
# Check to see if the filename of this child is the same as the
# last one, and if so, skip the child. This can happen if we
# have very large files with more than one directory entry.
fi = child.file_identifier()
if fi == last:
continue
last = fi
if child.rock_ridge is not None and child.rock_ridge.child_link_record_exists() and child.rock_ridge.cl_to_moved_dr is not None and child.rock_ridge.cl_to_moved_dr.parent is not None:
# If this is the case, this is a relocated entry. We actually
# want to go find the entry this was relocated to; we do that
# by following the child_link, then going up to the parent and
# finding the entry that links to the same one as this one.
cl_parent = child.rock_ridge.cl_to_moved_dr.parent
for cl_child in cl_parent.children:
if cl_child.rock_ridge is not None and cl_child.rock_ridge.name() == child.rock_ridge.name():
child = cl_child
break
# If we ended up not finding the right one in the parent of the
# moved entry, weird, but just return the one we would have
# anyway.
yield child | [
"def",
"_yield_children",
"(",
"rec",
")",
":",
"# type: (dr.DirectoryRecord) -> Generator",
"if",
"not",
"rec",
".",
"is_dir",
"(",
")",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Record is not a directory!'",
")",
"last",
"=",
"b''",
"for... | An internal function to gather and yield all of the children of a Directory
Record.
Parameters:
rec - The Directory Record to get all of the children from (must be a
directory)
Yields:
Children of this Directory Record.
Returns:
Nothing. | [
"An",
"internal",
"function",
"to",
"gather",
"and",
"yield",
"all",
"of",
"the",
"children",
"of",
"a",
"Directory",
"Record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L417-L458 |
21,796 | clalancette/pycdlib | pycdlib/pycdlib.py | _assign_udf_desc_extents | def _assign_udf_desc_extents(descs, start_extent):
# type: (PyCdlib._UDFDescriptors, int) -> None
'''
An internal function to assign a consecutive sequence of extents for the
given set of UDF Descriptors, starting at the given extent.
Parameters:
descs - The PyCdlib._UDFDescriptors object to assign extents for.
start_extent - The starting extent to assign from.
Returns:
Nothing.
'''
current_extent = start_extent
descs.pvd.set_extent_location(current_extent)
current_extent += 1
descs.impl_use.set_extent_location(current_extent)
current_extent += 1
descs.partition.set_extent_location(current_extent)
current_extent += 1
descs.logical_volume.set_extent_location(current_extent)
current_extent += 1
descs.unallocated_space.set_extent_location(current_extent)
current_extent += 1
descs.terminator.set_extent_location(current_extent)
current_extent += 1 | python | def _assign_udf_desc_extents(descs, start_extent):
# type: (PyCdlib._UDFDescriptors, int) -> None
'''
An internal function to assign a consecutive sequence of extents for the
given set of UDF Descriptors, starting at the given extent.
Parameters:
descs - The PyCdlib._UDFDescriptors object to assign extents for.
start_extent - The starting extent to assign from.
Returns:
Nothing.
'''
current_extent = start_extent
descs.pvd.set_extent_location(current_extent)
current_extent += 1
descs.impl_use.set_extent_location(current_extent)
current_extent += 1
descs.partition.set_extent_location(current_extent)
current_extent += 1
descs.logical_volume.set_extent_location(current_extent)
current_extent += 1
descs.unallocated_space.set_extent_location(current_extent)
current_extent += 1
descs.terminator.set_extent_location(current_extent)
current_extent += 1 | [
"def",
"_assign_udf_desc_extents",
"(",
"descs",
",",
"start_extent",
")",
":",
"# type: (PyCdlib._UDFDescriptors, int) -> None",
"current_extent",
"=",
"start_extent",
"descs",
".",
"pvd",
".",
"set_extent_location",
"(",
"current_extent",
")",
"current_extent",
"+=",
"1... | An internal function to assign a consecutive sequence of extents for the
given set of UDF Descriptors, starting at the given extent.
Parameters:
descs - The PyCdlib._UDFDescriptors object to assign extents for.
start_extent - The starting extent to assign from.
Returns:
Nothing. | [
"An",
"internal",
"function",
"to",
"assign",
"a",
"consecutive",
"sequence",
"of",
"extents",
"for",
"the",
"given",
"set",
"of",
"UDF",
"Descriptors",
"starting",
"at",
"the",
"given",
"extent",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L461-L491 |
21,797 | clalancette/pycdlib | pycdlib/pycdlib.py | _find_dr_record_by_name | def _find_dr_record_by_name(vd, path, encoding):
# type: (headervd.PrimaryOrSupplementaryVD, bytes, str) -> dr.DirectoryRecord
'''
An internal function to find an directory record on the ISO given an ISO
or Joliet path. If the entry is found, it returns the directory record
object corresponding to that entry. If the entry could not be found,
a pycdlibexception.PyCdlibInvalidInput exception is raised.
Parameters:
vd - The Volume Descriptor to look in for the Directory Record.
path - The ISO or Joliet entry to find the Directory Record for.
encoding - The string encoding used for the path.
Returns:
The directory record entry representing the entry on the ISO.
'''
if not utils.starts_with_slash(path):
raise pycdlibexception.PyCdlibInvalidInput('Must be a path starting with /')
root_dir_record = vd.root_directory_record()
# If the path is just the slash, we just want the root directory, so
# get the child there and quit.
if path == b'/':
return root_dir_record
# Split the path along the slashes
splitpath = utils.split_path(path)
currpath = splitpath.pop(0).decode('utf-8').encode(encoding)
entry = root_dir_record
tmpdr = dr.DirectoryRecord()
while True:
child = None
thelist = entry.children
lo = 2
hi = len(thelist)
while lo < hi:
mid = (lo + hi) // 2
tmpdr.file_ident = currpath
if thelist[mid] < tmpdr:
lo = mid + 1
else:
hi = mid
index = lo
if index != len(thelist) and thelist[index].file_ident == currpath:
child = thelist[index]
if child is None:
# We failed to find this component of the path, so break out of the
# loop and fail
break
if child.rock_ridge is not None and child.rock_ridge.child_link_record_exists():
# Here, the rock ridge extension has a child link, so we
# need to follow it.
child = child.rock_ridge.cl_to_moved_dr
if child is None:
break
# We found the child, and it is the last one we are looking for;
# return it.
if not splitpath:
return child
if not child.is_dir():
break
entry = child
currpath = splitpath.pop(0).decode('utf-8').encode(encoding)
raise pycdlibexception.PyCdlibInvalidInput('Could not find path') | python | def _find_dr_record_by_name(vd, path, encoding):
# type: (headervd.PrimaryOrSupplementaryVD, bytes, str) -> dr.DirectoryRecord
'''
An internal function to find an directory record on the ISO given an ISO
or Joliet path. If the entry is found, it returns the directory record
object corresponding to that entry. If the entry could not be found,
a pycdlibexception.PyCdlibInvalidInput exception is raised.
Parameters:
vd - The Volume Descriptor to look in for the Directory Record.
path - The ISO or Joliet entry to find the Directory Record for.
encoding - The string encoding used for the path.
Returns:
The directory record entry representing the entry on the ISO.
'''
if not utils.starts_with_slash(path):
raise pycdlibexception.PyCdlibInvalidInput('Must be a path starting with /')
root_dir_record = vd.root_directory_record()
# If the path is just the slash, we just want the root directory, so
# get the child there and quit.
if path == b'/':
return root_dir_record
# Split the path along the slashes
splitpath = utils.split_path(path)
currpath = splitpath.pop(0).decode('utf-8').encode(encoding)
entry = root_dir_record
tmpdr = dr.DirectoryRecord()
while True:
child = None
thelist = entry.children
lo = 2
hi = len(thelist)
while lo < hi:
mid = (lo + hi) // 2
tmpdr.file_ident = currpath
if thelist[mid] < tmpdr:
lo = mid + 1
else:
hi = mid
index = lo
if index != len(thelist) and thelist[index].file_ident == currpath:
child = thelist[index]
if child is None:
# We failed to find this component of the path, so break out of the
# loop and fail
break
if child.rock_ridge is not None and child.rock_ridge.child_link_record_exists():
# Here, the rock ridge extension has a child link, so we
# need to follow it.
child = child.rock_ridge.cl_to_moved_dr
if child is None:
break
# We found the child, and it is the last one we are looking for;
# return it.
if not splitpath:
return child
if not child.is_dir():
break
entry = child
currpath = splitpath.pop(0).decode('utf-8').encode(encoding)
raise pycdlibexception.PyCdlibInvalidInput('Could not find path') | [
"def",
"_find_dr_record_by_name",
"(",
"vd",
",",
"path",
",",
"encoding",
")",
":",
"# type: (headervd.PrimaryOrSupplementaryVD, bytes, str) -> dr.DirectoryRecord",
"if",
"not",
"utils",
".",
"starts_with_slash",
"(",
"path",
")",
":",
"raise",
"pycdlibexception",
".",
... | An internal function to find an directory record on the ISO given an ISO
or Joliet path. If the entry is found, it returns the directory record
object corresponding to that entry. If the entry could not be found,
a pycdlibexception.PyCdlibInvalidInput exception is raised.
Parameters:
vd - The Volume Descriptor to look in for the Directory Record.
path - The ISO or Joliet entry to find the Directory Record for.
encoding - The string encoding used for the path.
Returns:
The directory record entry representing the entry on the ISO. | [
"An",
"internal",
"function",
"to",
"find",
"an",
"directory",
"record",
"on",
"the",
"ISO",
"given",
"an",
"ISO",
"or",
"Joliet",
"path",
".",
"If",
"the",
"entry",
"is",
"found",
"it",
"returns",
"the",
"directory",
"record",
"object",
"corresponding",
"... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L494-L567 |
21,798 | clalancette/pycdlib | pycdlib/pycdlib.py | PyCdlibIO.read | def read(self, size=None):
# type: (Optional[int]) -> bytes
'''
A method to read and return up to size bytes.
Parameters:
size - Optional parameter to read size number of bytes; if None or
negative, all remaining bytes in the file will be read
Returns:
The number of bytes requested or the rest of the data left in the file,
whichever is smaller. If the file is at or past EOF, returns an empty
bytestring.
'''
if not self._open:
raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')
if self._offset >= self._length:
return b''
if size is None or size < 0:
data = self.readall()
else:
readsize = min(self._length - self._offset, size)
data = self._fp.read(readsize)
self._offset += readsize
return data | python | def read(self, size=None):
# type: (Optional[int]) -> bytes
'''
A method to read and return up to size bytes.
Parameters:
size - Optional parameter to read size number of bytes; if None or
negative, all remaining bytes in the file will be read
Returns:
The number of bytes requested or the rest of the data left in the file,
whichever is smaller. If the file is at or past EOF, returns an empty
bytestring.
'''
if not self._open:
raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')
if self._offset >= self._length:
return b''
if size is None or size < 0:
data = self.readall()
else:
readsize = min(self._length - self._offset, size)
data = self._fp.read(readsize)
self._offset += readsize
return data | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"# type: (Optional[int]) -> bytes",
"if",
"not",
"self",
".",
"_open",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'I/O operation on closed file.'",
")",
"if",
"self",
".",
"... | A method to read and return up to size bytes.
Parameters:
size - Optional parameter to read size number of bytes; if None or
negative, all remaining bytes in the file will be read
Returns:
The number of bytes requested or the rest of the data left in the file,
whichever is smaller. If the file is at or past EOF, returns an empty
bytestring. | [
"A",
"method",
"to",
"read",
"and",
"return",
"up",
"to",
"size",
"bytes",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L594-L620 |
21,799 | clalancette/pycdlib | pycdlib/pycdlib.py | PyCdlibIO.readall | def readall(self):
# type: () -> bytes
'''
A method to read and return the remaining bytes in the file.
Parameters:
None.
Returns:
The rest of the data left in the file. If the file is at or past EOF,
returns an empty bytestring.
'''
if not self._open:
raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')
readsize = self._length - self._offset
if readsize > 0:
data = self._fp.read(readsize)
self._offset += readsize
else:
data = b''
return data | python | def readall(self):
# type: () -> bytes
'''
A method to read and return the remaining bytes in the file.
Parameters:
None.
Returns:
The rest of the data left in the file. If the file is at or past EOF,
returns an empty bytestring.
'''
if not self._open:
raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')
readsize = self._length - self._offset
if readsize > 0:
data = self._fp.read(readsize)
self._offset += readsize
else:
data = b''
return data | [
"def",
"readall",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_open",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'I/O operation on closed file.'",
")",
"readsize",
"=",
"self",
".",
"_length",
"-",
"self",
".... | A method to read and return the remaining bytes in the file.
Parameters:
None.
Returns:
The rest of the data left in the file. If the file is at or past EOF,
returns an empty bytestring. | [
"A",
"method",
"to",
"read",
"and",
"return",
"the",
"remaining",
"bytes",
"in",
"the",
"file",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L622-L643 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.