docstring stringlengths 52 499 | function stringlengths 67 35.2k | __index_level_0__ int64 52.6k 1.16M |
|---|---|---|
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. | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized')
(tag_unused, recording_date, integrity_type,
next_integrit... | 511,155 |
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. | def record(self):
# type: () -> bytes
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,
... | 511,156 |
A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing. | def new(self):
# type: () -> None
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
... | 511,157 |
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. | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized')
(tag_unused, recording_date, interchange_level, max_interchange_level,
cha... | 511,158 |
A method to generate the string representing this UDF File Set
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Set Descriptor. | def record(self):
# type: () -> bytes
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,
... | 511,159 |
A method to create a new UDF File Set Descriptor.
Parameters:
None.
Returns:
Nothing. | def new(self):
# type: () -> None
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.record... | 511,160 |
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. | def set_extent_location(self, new_location):
# type: (int) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized')
self.new_extent_loc = new_location | 511,161 |
Parse the passed in data into a UDF ICB Tag.
Parameters:
data - The data to parse.
Returns:
Nothing. | def parse(self, data):
# type: (bytes) -> None
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_ty... | 511,162 |
A method to generate the string representing this UDF ICB Tag.
Parameters:
None.
Returns:
A string representing this UDF ICB Tag. | def record(self):
# type: () -> bytes
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,
... | 511,163 |
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. | def new(self, file_type):
# type: (str) -> None
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 ... | 511,164 |
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.
... | def parse(self, data, extent, parent, desc_tag):
# type: (bytes, int, Optional[UDFFileEntry], UDFTag) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized')
(tag_unused, icb_tag, self.uid, self.gid, self.perms, self.f... | 511,166 |
A method to generate the string representing this UDF File Entry.
Parameters:
None.
Returns:
A string representing this UDF File Entry. | def record(self):
# type: () -> bytes
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,
... | 511,167 |
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 Fi... | def new(self, length, file_type, parent, log_block_size):
# type: (int, str, Optional[UDFFileEntry], int) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized')
if file_type not in ('dir', 'file', 'symlink'):
... | 511,168 |
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 Ident... | def add_file_ident_desc(self, new_fi_desc, logical_block_size):
# type: (UDFFileIdentifierDescriptor, int) -> int
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.icb_tag.file_type != 4:
raise pycdli... | 511,169 |
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 F... | 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 initialized')
tmp_fi_desc = UDFFileIdentifierDescriptor()
tmp_fi_desc.isparent =... | 511,170 |
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. | def set_data_location(self, current_extent, start_extent): # pylint: disable=unused-argument
# type: (int, int) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
current_assignment = start_extent
for ind... | 511,171 |
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. | def set_data_length(self, length):
# type: (int) -> None
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, u... | 511,172 |
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. | def file_identifier(self):
# type: () -> bytes
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 | 511,173 |
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. | def find_file_ident_desc_by_name(self, currpath):
# type: (bytes) -> UDFFileIdentifierDescriptor
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
#... | 511,174 |
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 Id... | def track_file_ident_desc(self, file_ident):
# type: (UDFFileIdentifierDescriptor) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
self.fi_descs.append(file_ident) | 511,175 |
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. | def finish_directory_parse(self):
# type: () -> None
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 fo... | 511,176 |
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. | def length(cls, namelen):
# type: (Type[UDFFileIdentifierDescriptor], int) -> int
if namelen > 0:
namelen += 1
to_add = struct.calcsize(cls.FMT) + namelen
return to_add + UDFFileIdentifierDescriptor.pad(to_add) | 511,178 |
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 pare... | def parse(self, data, extent, desc_tag, parent):
# type: (bytes, int, UDFTag, UDFFileEntry) -> int
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor already initialized')
(tag_unused, file_version_num, self.file_characteristic... | 511,179 |
A method to generate the string representing this UDF File Identifier Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Identifier Descriptor. | def record(self):
# type: () -> bytes
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 sel... | 511,180 |
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.
Ret... | def new(self, isdir, isparent, name, parent):
# type: (bool, bool, bytes, Optional[UDFFileEntry]) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(257) # ... | 511,181 |
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 exte... | def set_icb(self, new_location, tag_location):
# type: (int, int) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier not initialized')
self.icb.set_extent_location(new_location, tag_location) | 511,182 |
Parse a Volume Descriptor out of a string.
Parameters:
vd - The string containing the Volume Descriptor.
extent_loc - The location on the ISO of this Volume Descriptor.
Returns:
Nothing. | def parse(self, vd, extent_loc):
# type: (bytes, int) -> None
################ PVD VERSION ######################
(descriptor_type, identifier, self.version, self.flags,
self.system_identifier, self.volume_identifier, unused1,
space_size_le, space_size_be, self.escape_... | 511,189 |
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. | def copy(self, orig):
# type: (PrimaryOrSupplementaryVD) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is already initialized')
self.version = orig.version
self.flags = orig.flags
self.system_identifier = o... | 511,191 |
A method to generate the string representing this Volume Descriptor.
Parameters:
None.
Returns:
A string representing this Volume Descriptor. | def record(self):
# type: () -> bytes
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.FM... | 511,192 |
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. | 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 self.rr_ce_blocks:
block.set_extent_location(-1) | 511,195 |
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. | 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 'addition' parameter is expected to be in bytes, but the space
# size we tr... | 511,196 |
Remove bytes from the volume descriptor.
Parameters:
removal_bytes - The number of bytes to remove.
Returns:
Nothing. | 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')
# The 'removal' parameter is expected to be in bytes, but the space
# size we... | 511,197 |
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. | 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 the path table size.
self.path_tbl_size += ptr_size
if (utils.cei... | 511,198 |
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. | 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 remove from the Path Table Record size.
self.path_tbl_size -= ptr_size
... | 511,199 |
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. | def copy_sizes(self, othervd):
# type: (PrimaryOrSupplementaryVD) -> None
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_tb... | 511,200 |
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. | def parse(self, ident_str):
# type: (bytes) -> None
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
... | 511,202 |
Create a new file or text identifier.
Parameters:
text - The text to store into the identifier.
Returns:
Nothing. | def new(self, text):
# type: (bytes) -> None
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')
... | 511,203 |
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. | def parse(self, vd, extent_loc):
# type: (bytes, int) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('Volume Descriptor Set Terminator already initialized')
(descriptor_type, identifier, version,
zero_unused) = struct.unpack_from(self.FMT... | 511,204 |
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. | def parse(self, vd, extent_loc):
# type: (bytes, int) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('Boot Record already initialized')
(descriptor_type, identifier, version,
self.boot_system_identifier, self.boot_identifier,
sel... | 511,205 |
A method to create a new Boot Record.
Parameters:
boot_system_id - The system identifier to associate with this Boot
Record.
Returns:
Nothing. | 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.ljust(32, b'\x00')
self.boot_identifier = b'\x00' * 32
self.boot_system_use = b'\x00'... | 511,206 |
A method to generate a string representing this Boot Record.
Parameters:
None.
Returns:
A string representing this Boot Record. | def record(self):
# type: () -> bytes
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_identifie... | 511,207 |
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. | 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.boot_system_use = boot_sys_use.ljust(197, b'\x00') | 511,208 |
Create a new Version Volume Descriptor.
Parameters:
log_block_size - The size of one extent.
Returns:
Nothing. | def new(self, log_block_size):
# type: (int) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Version Volume Descriptor is already initialized')
self._data = b'\x00' * log_block_size
self._initialized = True | 511,210 |
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... | def parse(self, vd, datastr, ino):
# type: (headervd.PrimaryOrSupplementaryVD, bytes, inode.Inode) -> bool
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table is already initialized')
(pvd_extent, rec_extent, self.orig_len,
... | 511,212 |
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 - Th... | def new(self, vd, ino, orig_len, csum):
# type: (headervd.PrimaryOrSupplementaryVD, inode.Inode, int, int) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Eltorito Boot Info Table is already initialized')
self.vd = vd
self.orig_len = o... | 511,213 |
A method to generate a string representing this boot info table.
Parameters:
None.
Returns:
A string representing this boot info table. | def record(self):
# type: () -> bytes
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(), s... | 511,214 |
A static method to compute the checksum on the ISO. Note that this is
*not* a 1's complement checksum; when an addition overflows, the carry
bit is discarded, not added to the end.
Parameters:
data - The data to compute the checksum over.
Returns:
The checksum of the ... | def _checksum(data):
# type: (bytes) -> int
def identity(x):
# type: (int) -> int
return x
if isinstance(data, str):
myord = ord
elif isinstance(data, bytes):
myord = identity
s = 0
for i in range(0, l... | 511,215 |
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. | def parse(self, valstr):
# type: (bytes) -> None
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,
key... | 511,216 |
A method to create a new El Torito Validation Entry.
Parameters:
platform_id - The platform ID to set for this validation entry.
Returns:
Nothing. | def new(self, platform_id):
# type: (int) -> None
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
... | 511,217 |
An internal method to generate a string representing this El Torito
Validation Entry.
Parameters:
None.
Returns:
String representing this El Torito Validation Entry. | def _record(self):
# type: () -> bytes
return struct.pack(self.FMT, 1, self.platform_id, 0, self.id_string,
self.checksum, 0x55, 0xaa) | 511,218 |
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. | def parse(self, valstr):
# type: (bytes) -> None
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, se... | 511,219 |
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 -... | def new(self, sector_count, load_seg, media_name, system_type, bootable):
# type: (int, int, str, int, bool) -> None
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry already initialized')
if media_name == 'noemul':
media_type = ... | 511,220 |
A method to update the extent (and RBA) for this entry.
Parameters:
current_extent - The new extent to set for this entry.
Returns:
Nothing. | def set_data_location(self, current_extent, tag_location): # pylint: disable=unused-argument
# type: (int, int) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not yet initialized')
self.load_rba = current_extent | 511,221 |
A method to set the Inode associated with this El Torito Entry.
Parameters:
ino - The Inode object corresponding to this entry.
Returns:
Nothing. | def set_inode(self, ino):
# type: (inode.Inode) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not yet initialized')
self.inode = ino | 511,222 |
A method to generate a string representing this El Torito Entry.
Parameters:
None.
Returns:
String representing this El Torito Entry. | def record(self):
# type: () -> bytes
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.syst... | 511,223 |
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. | def set_data_length(self, length):
# type: (int) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Entry not initialized')
self.sector_count = utils.ceiling_div(length, 512) | 511,224 |
Parse an El Torito section header from a string.
Parameters:
valstr - The string to parse.
Returns:
Nothing. | def parse(self, valstr):
# type: (bytes) -> None
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_fr... | 511,225 |
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. | def new(self, id_string, platform_id):
# type: (bytes, int) -> None
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_r... | 511,226 |
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.
... | def add_parsed_entry(self, entry):
# type: (EltoritoEntry) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
if len(self.section_entries) >= self.num_section_entries:
raise pycdlibexcept... | 511,227 |
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. | def add_new_entry(self, entry):
# type: (EltoritoEntry) -> None
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Section Header not yet initialized')
self.num_section_entries += 1
self.section_entries.append(entry) | 511,228 |
Get a string representing this El Torito section header.
Parameters:
None.
Returns:
A string representing this El Torito section header. | def record(self):
# type: () -> bytes
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_sect... | 511,229 |
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. | def parse(self, valstr):
# type: (bytes) -> bool
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 t... | 511,231 |
A method to generate a string representing this El Torito Boot Catalog.
Parameters:
None.
Returns:
A string representing this El Torito Boot Catalog. | def record(self):
# type: () -> bytes
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:
o... | 511,234 |
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. | 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 initialized')
self.dirrecords.append(rec) | 511,235 |
A method to update the extent associated with this Boot Catalog.
Parameters:
current_extent - New extent to associate with this Boot Catalog
Returns:
Nothing. | 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.br.update_boot_system_use(struct.pack('=L', current_extent)) | 511,236 |
A function to check that a name only uses d1 characters as defined by ISO9660.
Parameters:
name - The name to check.
Returns:
Nothing. | def _check_d1_characters(name):
# type: (bytes) -> None
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 _') | 511,237 |
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. | def _split_iso9660_filename(fullname):
# type: (bytes) -> Tuple[bytes, bytes, bytes]
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 = do... | 511,238 |
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. | 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_iso9660_filename(fullname)
# Ecma-119 says that filenames must end with a semicol... | 511,239 |
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. | 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
# character
if not fullname:
r... | 511,240 |
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. | def _interchange_level_from_filename(fullname):
# type: (bytes) -> int
(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:
... | 511,241 |
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. | 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 pycdlibexception.PyCdlibInvalidInput:
interchange_level = 3
return interchange_level | 511,242 |
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. | def _yield_children(rec):
# type: (dr.DirectoryRecord) -> Generator
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... | 511,244 |
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. | 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
descs.impl_use.set_extent_location(current_extent)
current_extent += 1
descs.partition.set... | 511,245 |
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,
... | def read(self, size=None):
# type: (Optional[int]) -> bytes
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.r... | 511,249 |
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. | def readall(self):
# type: () -> bytes
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 += reads... | 511,250 |
An internal method to parse the volume descriptors on an ISO.
Parameters:
None.
Returns:
Nothing. | def _parse_volume_descriptors(self):
# type: () -> None
# Ecma-119 says that the Volume Descriptor set is a sequence of volume
# descriptors recorded in consecutively numbered Logical Sectors
# starting with Logical Sector Number 16. Since sectors are 2048 bytes
# in le... | 511,253 |
An internal method to seek to a particular extent on the input ISO.
Parameters:
extent - The extent to seek to.
Returns:
Nothing. | def _seek_to_extent(self, extent):
# type: (int) -> None
self._cdfp.seek(extent * self.pvd.logical_block_size()) | 511,254 |
An internal method to find an directory record on the ISO given a Rock
Ridge 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 is raised.
Parameters:
rr_path... | def _find_rr_record(self, rr_path):
# type: (bytes) -> dr.DirectoryRecord
if not utils.starts_with_slash(rr_path):
raise pycdlibexception.PyCdlibInvalidInput('Must be a path starting with /')
root_dir_record = self.pvd.root_directory_record()
# If the path is just ... | 511,255 |
An internal method to find an directory record on the ISO given a 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 is raised.
Parameters:
joliet_path... | def _find_joliet_record(self, joliet_path):
# type: (bytes) -> dr.DirectoryRecord
if self.joliet_vd is None:
raise pycdlibexception.PyCdlibInternalError('Joliet path requested on non-Joliet ISO')
return _find_dr_record_by_name(self.joliet_vd, joliet_path, 'utf-16_be') | 511,256 |
An internal method to find an directory record on the ISO given a UDF
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 is raised.
Parameters:
udf_path - The... | def _find_udf_record(self, udf_path):
# type: (bytes) -> Tuple[Optional[udfmod.UDFFileIdentifierDescriptor], udfmod.UDFFileEntry]
# If the path is just the slash, we just want the root directory, so
# get the child there and quit.
if udf_path == b'/':
return None, se... | 511,257 |
An internal method to find the parent directory record and name given an
ISO path. If the parent is found, return a tuple containing the
basename of the path and the parent directory record object.
Parameters:
iso_path - The absolute ISO path to the entry on the ISO.
Returns:
... | def _iso_name_and_parent_from_path(self, iso_path):
# type: (bytes) -> Tuple[bytes, dr.DirectoryRecord]
splitpath = utils.split_path(iso_path)
name = splitpath.pop()
parent = self._find_iso_record(b'/' + b'/'.join(splitpath))
return (name.decode('utf-8').encode('utf-8... | 511,258 |
An internal method to find the parent directory record and name given a
Joliet path. If the parent is found, return a tuple containing the
basename of the path and the parent directory record object.
Parameters:
joliet_path - The absolute Joliet path to the entry on the ISO.
R... | def _joliet_name_and_parent_from_path(self, joliet_path):
# type: (bytes) -> Tuple[bytes, dr.DirectoryRecord]
splitpath = utils.split_path(joliet_path)
name = splitpath.pop()
if len(name) > 64:
raise pycdlibexception.PyCdlibInvalidInput('Joliet names can be a maxim... | 511,259 |
An internal method to find the parent directory record and name given a
UDF path. If the parent is found, return a tuple containing the basename
of the path and the parent UDF File Entry object.
Parameters:
udf_path - The absolute UDF path to the entry on the ISO.
Returns:
... | def _udf_name_and_parent_from_path(self, udf_path):
# type: (bytes) -> Tuple[bytes, udfmod.UDFFileEntry]
splitpath = utils.split_path(udf_path)
name = splitpath.pop()
(parent_ident_unused, parent) = self._find_udf_record(b'/' + b'/'.join(splitpath))
return (name.decode(... | 511,260 |
An internal method to set the Rock Ridge version of the ISO given the
Rock Ridge version of the previous entry.
Parameters:
rr - The version of rr from the last directory record.
Returns:
Nothing. | def _set_rock_ridge(self, rr):
# type: (str) -> None
# We don't allow mixed Rock Ridge versions on the ISO, so apply some
# checking. If the current overall Rock Ridge version on the ISO is
# None, we upgrade it to whatever version we were given. Once we have
# seen a ... | 511,261 |
An internal method to re-initialize the object. Called from
both __init__ and close.
Parameters:
None.
Returns:
Nothing. | def _initialize(self):
# type: () -> None
self._cdfp = BytesIO()
self.svds = [] # type: List[headervd.PrimaryOrSupplementaryVD]
self.brs = [] # type: List[headervd.BootRecord]
self.vdsts = [] # type: List[headervd.VolumeDescriptorSetTerminator]
self.eltorito_b... | 511,263 |
An internal method to examine a Boot Record and see if it is an
El Torito Boot Record. If it is, parse the El Torito Boot Catalog,
verification entry, initial entry, and any additional section entries.
Parameters:
br - The boot record to examine for an El Torito signature.
Ret... | def _check_and_parse_eltorito(self, br):
# type: (headervd.BootRecord) -> None
if br.boot_system_identifier != b'EL TORITO SPECIFICATION'.ljust(32, b'\x00'):
return
if self.eltorito_boot_catalog is not None:
raise pycdlibexception.PyCdlibInvalidISO('Only one El ... | 511,265 |
An internal method to add a child to a directory record, expanding the
space in the Volume Descriptor(s) if necessary.
Parameters:
child - The new child.
logical_block_size - The size of one logical block.
Returns:
The number of bytes to add for this directory record ... | def _add_child_to_dr(self, child, logical_block_size):
# type: (dr.DirectoryRecord, int) -> int
if child.parent is None:
raise pycdlibexception.PyCdlibInternalError('Trying to add child without a parent')
try_long_entry = False
try:
ret = child.parent.ad... | 511,267 |
An internal method to remove a child from a directory record, shrinking
the space in the Volume Descriptor if necessary.
Parameters:
child - The child to remove.
index - The index of the child into the parent's child array.
logical_block_size - The size of one logical block.
... | def _remove_child_from_dr(self, child, index, logical_block_size):
# type: (dr.DirectoryRecord, int, int) -> int
if child.parent is None:
raise pycdlibexception.PyCdlibInternalError('Trying to remove child from non-existent parent')
self._find_iso_record.cache_clear() # p... | 511,268 |
An internal method to add a PTR to a VD, adding space to the VD if
necessary.
Parameters:
ptr - The PTR to add to the vd.
Returns:
The number of additional bytes that are needed to fit the new PTR
(this may be zero). | def _add_to_ptr_size(self, ptr):
# type: (path_table_record.PathTableRecord) -> int
num_bytes_to_add = 0
for pvd in self.pvds:
# The add_to_ptr_size() method returns True if the PVD needs
# additional space in the PTR to store this directory. We always
... | 511,269 |
An internal method to remove a PTR from a VD, removing space from the VD if
necessary.
Parameters:
ptr - The PTR to remove from the VD.
Returns:
The number of bytes to remove from the VDs (this may be zero). | def _remove_from_ptr_size(self, ptr):
# type: (path_table_record.PathTableRecord) -> int
num_bytes_to_remove = 0
for pvd in self.pvds:
# The remove_from_ptr_size() returns True if the PVD no longer
# needs the extra extents in the PTR that stored this directory.
... | 511,270 |
An internal method to find the /RR_MOVED directory on the ISO. If it
already exists, the directory record to it is returned. If it doesn't
yet exist, it is created and the directory record to it is returned.
Parameters:
None.
Returns:
The number of additional bytes n... | def _find_or_create_rr_moved(self):
# type: () -> int
if self._rr_moved_record is not None:
return 0
if self._rr_moved_name is None:
self._rr_moved_name = b'RR_MOVED'
if self._rr_moved_rr_name is None:
self._rr_moved_rr_name = b'rr_moved'
... | 511,271 |
An internal method to calculate the checksum for an El Torito Boot Info
Table. This checksum is a simple 32-bit checksum over all of the data
in the boot file, starting right after the Boot Info Table itself.
Parameters:
data_fp - The file object to read the input data from.
... | def _calculate_eltorito_boot_info_table_csum(self, data_fp, data_len):
# type: (BinaryIO, int) -> int
# Here we want to read the boot file so we can calculate the checksum
# over it.
num_sectors = utils.ceiling_div(data_len, self.pvd.logical_block_size())
csum = 0
... | 511,272 |
An internal method to check a boot directory record to see if it has
an El Torito Boot Info Table embedded inside of it.
Parameters:
ino - The Inode to check for a Boot Info Table.
Returns:
Nothing. | def _check_for_eltorito_boot_info_table(self, ino):
# type: (inode.Inode) -> None
orig = self._cdfp.tell()
with inode.InodeOpenData(ino, self.pvd.logical_block_size()) as (data_fp, data_len):
data_fp.seek(8, os.SEEK_CUR)
bi_table = eltorito.EltoritoBootInfoTable(... | 511,273 |
An internal method to check whether this ISO requires or does not
require a Rock Ridge path.
Parameters:
rr_name - The Rock Ridge name.
Returns:
The Rock Ridge name in bytes if this is a Rock Ridge ISO, None otherwise. | def _check_rr_name(self, rr_name):
# type: (Optional[str]) -> bytes
if self.rock_ridge:
if not rr_name:
raise pycdlibexception.PyCdlibInvalidInput('A rock ridge name must be passed for a rock-ridge ISO')
if rr_name.count('/') != 0:
raise ... | 511,274 |
An internal method to check whether this ISO does or does not require
a Joliet path. If a Joliet path is required, the path is normalized
and returned.
Parameters:
joliet_path - The joliet_path to normalize (if necessary).
Returns:
The normalized joliet_path if this I... | def _normalize_joliet_path(self, joliet_path):
# type: (str) -> bytes
tmp_path = b''
if self.joliet_vd is not None:
if not joliet_path:
raise pycdlibexception.PyCdlibInvalidInput('A Joliet path must be passed for a Joliet ISO')
tmp_path = utils.no... | 511,275 |
An internal method to link the El Torito entries into their
corresponding Directory Records, creating new ones if they are
'hidden'. Should only be called on an El Torito ISO.
Parameters:
extent_to_inode - The map that maps extents to Inodes.
Returns:
Nothing. | def _link_eltorito(self, extent_to_inode):
# type: (Dict[int, inode.Inode]) -> None
if self.eltorito_boot_catalog is None:
raise pycdlibexception.PyCdlibInternalError('Trying to link El Torito entries on a non-El Torito ISO')
log_block_size = self.pvd.logical_block_size()
... | 511,276 |
An internal method to parse a set of UDF Volume Descriptors.
Parameters:
extent - The extent at which to start parsing.
length - The number of bytes to read from the incoming ISO.
descs - The _UDFDescriptors object to store parsed objects into.
Returns:
Nothing. | def _parse_udf_vol_descs(self, extent, length, descs):
# type: (int, int, PyCdlib._UDFDescriptors) -> None
# Read in the Volume Descriptor Sequence
self._seek_to_extent(extent)
vd_data = self._cdfp.read(length)
# And parse it. Since the sequence doesn't have to be in a... | 511,277 |
An internal method to parse the UDF descriptors on the ISO. This should
only be called if it the ISO has a valid UDF Volume Recognition Sequence
at the beginning of the ISO.
Parameters:
None.
Returns:
Nothing. | def _parse_udf_descriptors(self):
# type: () -> None
block_size = self.pvd.logical_block_size()
# Parse the anchors
anchor_locations = [(256 * block_size, os.SEEK_SET), (-2048, os.SEEK_END)]
for loc, whence in anchor_locations:
self._cdfp.seek(loc, whence)
... | 511,278 |
An internal method to parse a single UDF File Entry and return the
corresponding object.
Parameters:
part_start - The extent number the partition starts at.
icb - The ICB object for the data.
parent - The parent of the UDF File Entry.
Returns:
A UDF File Entr... | def _parse_udf_file_entry(self, abs_file_entry_extent, icb, parent):
# type: (int, udfmod.UDFLongAD, Optional[udfmod.UDFFileEntry]) -> Optional[udfmod.UDFFileEntry]
self._seek_to_extent(abs_file_entry_extent)
icbdata = self._cdfp.read(icb.extent_length)
if all(v == 0 for v in b... | 511,279 |
An internal method to walk a UDF filesystem and add all the metadata
to this object.
Parameters:
extent_to_inode - A map from extent numbers to Inodes.
Returns:
Nothing. | def _walk_udf_directories(self, extent_to_inode):
# type: (Dict[int, inode.Inode]) -> None
part_start = self.udf_main_descs.partition.part_start_location
self.udf_root = self._parse_udf_file_entry(part_start + self.udf_file_set.root_dir_icb.log_block_num,
... | 511,280 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.