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,600 | clalancette/pycdlib | pycdlib/rockridge.py | RRRRRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Rock Ridge record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('RR record not yet initialized!')
return b'RR' + struct.pack('=BBB', RRRRRecord.length(), SU_ENTRY_VERSION, self.rr_flags) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Rock Ridge record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('RR record not yet initialized!')
return b'RR' + struct.pack('=BBB', RRRRRecord.length(), SU_ENTRY_VERSION, self.rr_flags) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'RR record not yet initialized!'",
")",
"return",
"b'RR'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Rock Ridge record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Rock",
"Ridge",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L218-L231 |
21,601 | clalancette/pycdlib | pycdlib/rockridge.py | RRCERecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Continuation Entry record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record already initialized!')
(su_len, su_entry_version_unused, bl_cont_area_le, bl_cont_area_be,
offset_cont_area_le, offset_cont_area_be,
len_cont_area_le, len_cont_area_be) = struct.unpack_from('=BBLLLLLL', rrstr[:28], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if su_len != RRCERecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if bl_cont_area_le != utils.swab_32bit(bl_cont_area_be):
raise pycdlibexception.PyCdlibInvalidISO('CE record big and little endian continuation area do not agree')
if offset_cont_area_le != utils.swab_32bit(offset_cont_area_be):
raise pycdlibexception.PyCdlibInvalidISO('CE record big and little endian continuation area offset do not agree')
if len_cont_area_le != utils.swab_32bit(len_cont_area_be):
raise pycdlibexception.PyCdlibInvalidISO('CE record big and little endian continuation area length do not agree')
self.bl_cont_area = bl_cont_area_le
self.offset_cont_area = offset_cont_area_le
self.len_cont_area = len_cont_area_le
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Continuation Entry record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record already initialized!')
(su_len, su_entry_version_unused, bl_cont_area_le, bl_cont_area_be,
offset_cont_area_le, offset_cont_area_be,
len_cont_area_le, len_cont_area_be) = struct.unpack_from('=BBLLLLLL', rrstr[:28], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if su_len != RRCERecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if bl_cont_area_le != utils.swab_32bit(bl_cont_area_be):
raise pycdlibexception.PyCdlibInvalidISO('CE record big and little endian continuation area do not agree')
if offset_cont_area_le != utils.swab_32bit(offset_cont_area_be):
raise pycdlibexception.PyCdlibInvalidISO('CE record big and little endian continuation area offset do not agree')
if len_cont_area_le != utils.swab_32bit(len_cont_area_be):
raise pycdlibexception.PyCdlibInvalidISO('CE record big and little endian continuation area length do not agree')
self.bl_cont_area = bl_cont_area_le
self.offset_cont_area = offset_cont_area_le
self.len_cont_area = len_cont_area_le
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CE record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused... | Parse a Rock Ridge Continuation Entry record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Continuation",
"Entry",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L261-L297 |
21,602 | clalancette/pycdlib | pycdlib/rockridge.py | RRCERecord.new | def new(self):
# type: () -> None
'''
Create a new Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record already initialized!')
self.bl_cont_area = 0 # This will get set during reshuffle_extents
self.offset_cont_area = 0 # This will get set during reshuffle_extents
self.len_cont_area = 0 # This will be calculated based on fields put in
self._initialized = True | python | def new(self):
# type: () -> None
'''
Create a new Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record already initialized!')
self.bl_cont_area = 0 # This will get set during reshuffle_extents
self.offset_cont_area = 0 # This will get set during reshuffle_extents
self.len_cont_area = 0 # This will be calculated based on fields put in
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CE record already initialized!'",
")",
"self",
".",
"bl_cont_area",
"=",
"0",
"# This will get set durin... | Create a new Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Continuation",
"Entry",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L299-L316 |
21,603 | clalancette/pycdlib | pycdlib/rockridge.py | RRCERecord.update_extent | def update_extent(self, extent):
# type: (int) -> None
'''
Update the extent for this CE record.
Parameters:
extent - The new extent for this CE record.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')
self.bl_cont_area = extent | python | def update_extent(self, extent):
# type: (int) -> None
'''
Update the extent for this CE record.
Parameters:
extent - The new extent for this CE record.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')
self.bl_cont_area = extent | [
"def",
"update_extent",
"(",
"self",
",",
"extent",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CE record not yet initialized!'",
")",
"self",
".",
"bl_cont_area",
... | Update the extent for this CE record.
Parameters:
extent - The new extent for this CE record.
Returns:
Nothing. | [
"Update",
"the",
"extent",
"for",
"this",
"CE",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L318-L331 |
21,604 | clalancette/pycdlib | pycdlib/rockridge.py | RRCERecord.update_offset | def update_offset(self, offset):
# type: (int) -> None
'''
Update the offset for this CE record.
Parameters:
extent - The new offset for this CE record.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')
self.offset_cont_area = offset | python | def update_offset(self, offset):
# type: (int) -> None
'''
Update the offset for this CE record.
Parameters:
extent - The new offset for this CE record.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')
self.offset_cont_area = offset | [
"def",
"update_offset",
"(",
"self",
",",
"offset",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CE record not yet initialized!'",
")",
"self",
".",
"offset_cont_area... | Update the offset for this CE record.
Parameters:
extent - The new offset for this CE record.
Returns:
Nothing. | [
"Update",
"the",
"offset",
"for",
"this",
"CE",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L333-L346 |
21,605 | clalancette/pycdlib | pycdlib/rockridge.py | RRCERecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')
return b'CE' + struct.pack('=BBLLLLLL',
RRCERecord.length(),
SU_ENTRY_VERSION,
self.bl_cont_area,
utils.swab_32bit(self.bl_cont_area),
self.offset_cont_area,
utils.swab_32bit(self.offset_cont_area),
self.len_cont_area,
utils.swab_32bit(self.len_cont_area)) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')
return b'CE' + struct.pack('=BBLLLLLL',
RRCERecord.length(),
SU_ENTRY_VERSION,
self.bl_cont_area,
utils.swab_32bit(self.bl_cont_area),
self.offset_cont_area,
utils.swab_32bit(self.offset_cont_area),
self.len_cont_area,
utils.swab_32bit(self.len_cont_area)) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CE record not yet initialized!'",
")",
"return",
"b'CE'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Continuation",
"Entry",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L364-L385 |
21,606 | clalancette/pycdlib | pycdlib/rockridge.py | RRPXRecord.parse | def parse(self, rrstr):
# type: (bytes) -> int
'''
Parse a Rock Ridge POSIX File Attributes record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
A string representing the RR version, either 1.09 or 1.12.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PX record already initialized!')
(su_len, su_entry_version_unused, posix_file_mode_le, posix_file_mode_be,
posix_file_links_le, posix_file_links_be, posix_file_user_id_le,
posix_file_user_id_be, posix_file_group_id_le,
posix_file_group_id_be) = struct.unpack_from('=BBLLLLLLLL', rrstr[:38], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if posix_file_mode_le != utils.swab_32bit(posix_file_mode_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file mode do not agree')
if posix_file_links_le != utils.swab_32bit(posix_file_links_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file links do not agree')
if posix_file_user_id_le != utils.swab_32bit(posix_file_user_id_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file user ID do not agree')
if posix_file_group_id_le != utils.swab_32bit(posix_file_group_id_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file group ID do not agree')
# In Rock Ridge 1.09 and 1.10, there is no serial number so the su_len
# is 36, while in Rock Ridge 1.12, there is an 8-byte serial number so
# su_len is 44.
if su_len == 36:
posix_file_serial_number_le = 0
elif su_len == 44:
(posix_file_serial_number_le,
posix_file_serial_number_be) = struct.unpack_from('=LL',
rrstr[:44], 36)
if posix_file_serial_number_le != utils.swab_32bit(posix_file_serial_number_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file serial number do not agree')
else:
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on Rock Ridge PX record')
self.posix_file_mode = posix_file_mode_le
self.posix_file_links = posix_file_links_le
self.posix_user_id = posix_file_user_id_le
self.posix_group_id = posix_file_group_id_le
self.posix_serial_number = posix_file_serial_number_le
self._initialized = True
return su_len | python | def parse(self, rrstr):
# type: (bytes) -> int
'''
Parse a Rock Ridge POSIX File Attributes record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
A string representing the RR version, either 1.09 or 1.12.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PX record already initialized!')
(su_len, su_entry_version_unused, posix_file_mode_le, posix_file_mode_be,
posix_file_links_le, posix_file_links_be, posix_file_user_id_le,
posix_file_user_id_be, posix_file_group_id_le,
posix_file_group_id_be) = struct.unpack_from('=BBLLLLLLLL', rrstr[:38], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if posix_file_mode_le != utils.swab_32bit(posix_file_mode_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file mode do not agree')
if posix_file_links_le != utils.swab_32bit(posix_file_links_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file links do not agree')
if posix_file_user_id_le != utils.swab_32bit(posix_file_user_id_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file user ID do not agree')
if posix_file_group_id_le != utils.swab_32bit(posix_file_group_id_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file group ID do not agree')
# In Rock Ridge 1.09 and 1.10, there is no serial number so the su_len
# is 36, while in Rock Ridge 1.12, there is an 8-byte serial number so
# su_len is 44.
if su_len == 36:
posix_file_serial_number_le = 0
elif su_len == 44:
(posix_file_serial_number_le,
posix_file_serial_number_be) = struct.unpack_from('=LL',
rrstr[:44], 36)
if posix_file_serial_number_le != utils.swab_32bit(posix_file_serial_number_be):
raise pycdlibexception.PyCdlibInvalidISO('PX record big and little-endian file serial number do not agree')
else:
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on Rock Ridge PX record')
self.posix_file_mode = posix_file_mode_le
self.posix_file_links = posix_file_links_le
self.posix_user_id = posix_file_user_id_le
self.posix_group_id = posix_file_group_id_le
self.posix_serial_number = posix_file_serial_number_le
self._initialized = True
return su_len | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> int",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PX record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused"... | Parse a Rock Ridge POSIX File Attributes record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
A string representing the RR version, either 1.09 or 1.12. | [
"Parse",
"a",
"Rock",
"Ridge",
"POSIX",
"File",
"Attributes",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L421-L476 |
21,607 | clalancette/pycdlib | pycdlib/rockridge.py | RRPXRecord.new | def new(self, mode):
# type: (int) -> None
'''
Create a new Rock Ridge POSIX File Attributes record.
Parameters:
mode - The Unix file mode for this record.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PX record already initialized!')
self.posix_file_mode = mode
self.posix_file_links = 1
self.posix_user_id = 0
self.posix_group_id = 0
self.posix_serial_number = 0
self._initialized = True | python | def new(self, mode):
# type: (int) -> None
'''
Create a new Rock Ridge POSIX File Attributes record.
Parameters:
mode - The Unix file mode for this record.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PX record already initialized!')
self.posix_file_mode = mode
self.posix_file_links = 1
self.posix_user_id = 0
self.posix_group_id = 0
self.posix_serial_number = 0
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"mode",
")",
":",
"# type: (int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PX record already initialized!'",
")",
"self",
".",
"posix_file_mode",
"=",
"mode",
... | Create a new Rock Ridge POSIX File Attributes record.
Parameters:
mode - The Unix file mode for this record.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"POSIX",
"File",
"Attributes",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L478-L497 |
21,608 | clalancette/pycdlib | pycdlib/rockridge.py | RRPXRecord.record | def record(self, rr_version):
# type: (str) -> bytes
'''
Generate a string representing the Rock Ridge POSIX File Attributes
record.
Parameters:
rr_version - The Rock Ridge version to use.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PX record not yet initialized!')
outlist = [b'PX', struct.pack('=BBLLLLLLLL', RRPXRecord.length(rr_version),
SU_ENTRY_VERSION, self.posix_file_mode,
utils.swab_32bit(self.posix_file_mode),
self.posix_file_links,
utils.swab_32bit(self.posix_file_links),
self.posix_user_id,
utils.swab_32bit(self.posix_user_id),
self.posix_group_id,
utils.swab_32bit(self.posix_group_id))]
if rr_version == '1.12':
outlist.append(struct.pack('=LL', self.posix_serial_number,
utils.swab_32bit(self.posix_serial_number)))
# The rr_version can never be "wrong" at this point; if it was, it would
# have thrown an exception earlier when calling length(). So just skip
# any potential checks here.
return b''.join(outlist) | python | def record(self, rr_version):
# type: (str) -> bytes
'''
Generate a string representing the Rock Ridge POSIX File Attributes
record.
Parameters:
rr_version - The Rock Ridge version to use.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PX record not yet initialized!')
outlist = [b'PX', struct.pack('=BBLLLLLLLL', RRPXRecord.length(rr_version),
SU_ENTRY_VERSION, self.posix_file_mode,
utils.swab_32bit(self.posix_file_mode),
self.posix_file_links,
utils.swab_32bit(self.posix_file_links),
self.posix_user_id,
utils.swab_32bit(self.posix_user_id),
self.posix_group_id,
utils.swab_32bit(self.posix_group_id))]
if rr_version == '1.12':
outlist.append(struct.pack('=LL', self.posix_serial_number,
utils.swab_32bit(self.posix_serial_number)))
# The rr_version can never be "wrong" at this point; if it was, it would
# have thrown an exception earlier when calling length(). So just skip
# any potential checks here.
return b''.join(outlist) | [
"def",
"record",
"(",
"self",
",",
"rr_version",
")",
":",
"# type: (str) -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PX record not yet initialized!'",
")",
"outlist",
"=",
"[",
"b'PX'",
... | Generate a string representing the Rock Ridge POSIX File Attributes
record.
Parameters:
rr_version - The Rock Ridge version to use.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"POSIX",
"File",
"Attributes",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L499-L529 |
21,609 | clalancette/pycdlib | pycdlib/rockridge.py | RRERRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Extensions Reference record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ER record already initialized!')
(su_len, su_entry_version_unused, len_id, len_des, len_src,
self.ext_ver) = struct.unpack_from('=BBBBBB', rrstr[:8], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
# Ensure that the length isn't crazy
if su_len > len(rrstr):
raise pycdlibexception.PyCdlibInvalidISO('Length of ER record much too long')
# Also ensure that the combination of len_id, len_des, and len_src
# doesn't overrun su_len; because of the check above, this means it
# can't overrun len(rrstr) either
total_length = len_id + len_des + len_src
if total_length > su_len:
raise pycdlibexception.PyCdlibInvalidISO('Combined length of ER ID, des, and src longer than record')
fmtstr = '=%ds%ds%ds' % (len_id, len_des, len_src)
(self.ext_id, self.ext_des, self.ext_src) = struct.unpack_from(fmtstr, rrstr, 8)
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Extensions Reference record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ER record already initialized!')
(su_len, su_entry_version_unused, len_id, len_des, len_src,
self.ext_ver) = struct.unpack_from('=BBBBBB', rrstr[:8], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
# Ensure that the length isn't crazy
if su_len > len(rrstr):
raise pycdlibexception.PyCdlibInvalidISO('Length of ER record much too long')
# Also ensure that the combination of len_id, len_des, and len_src
# doesn't overrun su_len; because of the check above, this means it
# can't overrun len(rrstr) either
total_length = len_id + len_des + len_src
if total_length > su_len:
raise pycdlibexception.PyCdlibInvalidISO('Combined length of ER ID, des, and src longer than record')
fmtstr = '=%ds%ds%ds' % (len_id, len_des, len_src)
(self.ext_id, self.ext_des, self.ext_src) = struct.unpack_from(fmtstr, rrstr, 8)
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ER record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused... | Parse a Rock Ridge Extensions Reference record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Extensions",
"Reference",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L566-L599 |
21,610 | clalancette/pycdlib | pycdlib/rockridge.py | RRERRecord.new | def new(self, ext_id, ext_des, ext_src):
# type: (bytes, bytes, bytes) -> None
'''
Create a new Rock Ridge Extensions Reference record.
Parameters:
ext_id - The extension identifier to use.
ext_des - The extension descriptor to use.
ext_src - The extension specification source to use.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ER record already initialized!')
self.ext_id = ext_id
self.ext_des = ext_des
self.ext_src = ext_src
self.ext_ver = 1
self._initialized = True | python | def new(self, ext_id, ext_des, ext_src):
# type: (bytes, bytes, bytes) -> None
'''
Create a new Rock Ridge Extensions Reference record.
Parameters:
ext_id - The extension identifier to use.
ext_des - The extension descriptor to use.
ext_src - The extension specification source to use.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ER record already initialized!')
self.ext_id = ext_id
self.ext_des = ext_des
self.ext_src = ext_src
self.ext_ver = 1
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"ext_id",
",",
"ext_des",
",",
"ext_src",
")",
":",
"# type: (bytes, bytes, bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ER record already initialized!'",
")",... | Create a new Rock Ridge Extensions Reference record.
Parameters:
ext_id - The extension identifier to use.
ext_des - The extension descriptor to use.
ext_src - The extension specification source to use.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Extensions",
"Reference",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L601-L621 |
21,611 | clalancette/pycdlib | pycdlib/rockridge.py | RRERRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Extensions Reference
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('ER record not yet initialized!')
return b'ER' + struct.pack('=BBBBBB', RRERRecord.length(self.ext_id, self.ext_des, self.ext_src), SU_ENTRY_VERSION, len(self.ext_id), len(self.ext_des), len(self.ext_src), self.ext_ver) + self.ext_id + self.ext_des + self.ext_src | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Extensions Reference
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('ER record not yet initialized!')
return b'ER' + struct.pack('=BBBBBB', RRERRecord.length(self.ext_id, self.ext_des, self.ext_src), SU_ENTRY_VERSION, len(self.ext_id), len(self.ext_des), len(self.ext_src), self.ext_ver) + self.ext_id + self.ext_des + self.ext_src | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ER record not yet initialized!'",
")",
"return",
"b'ER'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Extensions Reference
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Extensions",
"Reference",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L623-L637 |
21,612 | clalancette/pycdlib | pycdlib/rockridge.py | RRERRecord.length | def length(ext_id, ext_des, ext_src):
# type: (bytes, bytes, bytes) -> int
'''
Static method to return the length of the Rock Ridge Extensions Reference
record.
Parameters:
ext_id - The extension identifier to use.
ext_des - The extension descriptor to use.
ext_src - The extension specification source to use.
Returns:
The length of this record in bytes.
'''
return 8 + len(ext_id) + len(ext_des) + len(ext_src) | python | def length(ext_id, ext_des, ext_src):
# type: (bytes, bytes, bytes) -> int
'''
Static method to return the length of the Rock Ridge Extensions Reference
record.
Parameters:
ext_id - The extension identifier to use.
ext_des - The extension descriptor to use.
ext_src - The extension specification source to use.
Returns:
The length of this record in bytes.
'''
return 8 + len(ext_id) + len(ext_des) + len(ext_src) | [
"def",
"length",
"(",
"ext_id",
",",
"ext_des",
",",
"ext_src",
")",
":",
"# type: (bytes, bytes, bytes) -> int",
"return",
"8",
"+",
"len",
"(",
"ext_id",
")",
"+",
"len",
"(",
"ext_des",
")",
"+",
"len",
"(",
"ext_src",
")"
] | Static method to return the length of the Rock Ridge Extensions Reference
record.
Parameters:
ext_id - The extension identifier to use.
ext_des - The extension descriptor to use.
ext_src - The extension specification source to use.
Returns:
The length of this record in bytes. | [
"Static",
"method",
"to",
"return",
"the",
"length",
"of",
"the",
"Rock",
"Ridge",
"Extensions",
"Reference",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L640-L653 |
21,613 | clalancette/pycdlib | pycdlib/rockridge.py | RRESRecord.new | def new(self, extension_sequence):
# type: (int) -> None
'''
Create a new Rock Ridge Extension Selector record.
Parameters:
extension_sequence - The sequence number of this extension.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ES record already initialized!')
self.extension_sequence = extension_sequence
self._initialized = True | python | def new(self, extension_sequence):
# type: (int) -> None
'''
Create a new Rock Ridge Extension Selector record.
Parameters:
extension_sequence - The sequence number of this extension.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ES record already initialized!')
self.extension_sequence = extension_sequence
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"extension_sequence",
")",
":",
"# type: (int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ES record already initialized!'",
")",
"self",
".",
"extension_sequence",
... | Create a new Rock Ridge Extension Selector record.
Parameters:
extension_sequence - The sequence number of this extension.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Extension",
"Selector",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L689-L703 |
21,614 | clalancette/pycdlib | pycdlib/rockridge.py | RRESRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Extension Selector record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('ES record not yet initialized!')
return b'ES' + struct.pack('=BBB', RRESRecord.length(), SU_ENTRY_VERSION, self.extension_sequence) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Extension Selector record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('ES record not yet initialized!')
return b'ES' + struct.pack('=BBB', RRESRecord.length(), SU_ENTRY_VERSION, self.extension_sequence) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ES record not yet initialized!'",
")",
"return",
"b'ES'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Extension Selector record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Extension",
"Selector",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L705-L718 |
21,615 | clalancette/pycdlib | pycdlib/rockridge.py | RRPNRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge POSIX Device Number record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PN record already initialized!')
(su_len, su_entry_version_unused, dev_t_high_le, dev_t_high_be,
dev_t_low_le, dev_t_low_be) = struct.unpack_from('=BBLLLL', rrstr[:20], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if su_len != RRPNRecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if dev_t_high_le != utils.swab_32bit(dev_t_high_be):
raise pycdlibexception.PyCdlibInvalidISO('Dev_t high little-endian does not match big-endian')
if dev_t_low_le != utils.swab_32bit(dev_t_low_be):
raise pycdlibexception.PyCdlibInvalidISO('Dev_t low little-endian does not match big-endian')
self.dev_t_high = dev_t_high_le
self.dev_t_low = dev_t_low_le
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge POSIX Device Number record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PN record already initialized!')
(su_len, su_entry_version_unused, dev_t_high_le, dev_t_high_be,
dev_t_low_le, dev_t_low_be) = struct.unpack_from('=BBLLLL', rrstr[:20], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if su_len != RRPNRecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if dev_t_high_le != utils.swab_32bit(dev_t_high_be):
raise pycdlibexception.PyCdlibInvalidISO('Dev_t high little-endian does not match big-endian')
if dev_t_low_le != utils.swab_32bit(dev_t_low_be):
raise pycdlibexception.PyCdlibInvalidISO('Dev_t low little-endian does not match big-endian')
self.dev_t_high = dev_t_high_le
self.dev_t_low = dev_t_low_le
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PN record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused... | Parse a Rock Ridge POSIX Device Number record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"POSIX",
"Device",
"Number",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L748-L779 |
21,616 | clalancette/pycdlib | pycdlib/rockridge.py | RRPNRecord.new | def new(self, dev_t_high, dev_t_low):
# type: (int, int) -> None
'''
Create a new Rock Ridge POSIX device number record.
Parameters:
dev_t_high - The high-order 32-bits of the device number.
dev_t_low - The low-order 32-bits of the device number.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PN record already initialized!')
self.dev_t_high = dev_t_high
self.dev_t_low = dev_t_low
self._initialized = True | python | def new(self, dev_t_high, dev_t_low):
# type: (int, int) -> None
'''
Create a new Rock Ridge POSIX device number record.
Parameters:
dev_t_high - The high-order 32-bits of the device number.
dev_t_low - The low-order 32-bits of the device number.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PN record already initialized!')
self.dev_t_high = dev_t_high
self.dev_t_low = dev_t_low
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"dev_t_high",
",",
"dev_t_low",
")",
":",
"# type: (int, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PN record already initialized!'",
")",
"self",
".",
"dev_... | Create a new Rock Ridge POSIX device number record.
Parameters:
dev_t_high - The high-order 32-bits of the device number.
dev_t_low - The low-order 32-bits of the device number.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"POSIX",
"device",
"number",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L781-L798 |
21,617 | clalancette/pycdlib | pycdlib/rockridge.py | RRPNRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge POSIX Device Number
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PN record not yet initialized!')
return b'PN' + struct.pack('=BBLLLL', RRPNRecord.length(), SU_ENTRY_VERSION, self.dev_t_high, utils.swab_32bit(self.dev_t_high), self.dev_t_low, utils.swab_32bit(self.dev_t_low)) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge POSIX Device Number
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PN record not yet initialized!')
return b'PN' + struct.pack('=BBLLLL', RRPNRecord.length(), SU_ENTRY_VERSION, self.dev_t_high, utils.swab_32bit(self.dev_t_high), self.dev_t_low, utils.swab_32bit(self.dev_t_low)) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PN record not yet initialized!'",
")",
"return",
"b'PN'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge POSIX Device Number
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"POSIX",
"Device",
"Number",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L800-L814 |
21,618 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Symbolic Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record already initialized!')
(su_len, su_entry_version_unused, self.flags) = struct.unpack_from('=BBB', rrstr[:5], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
cr_offset = 5
data_len = su_len - 5
while data_len > 0:
(cr_flags, len_cp) = struct.unpack_from('=BB', rrstr[:cr_offset + 2], cr_offset)
data_len -= 2
cr_offset += 2
self.symlink_components.append(self.Component(cr_flags, len_cp,
rrstr[cr_offset:cr_offset + len_cp]))
# FIXME: if this is the last component in this SL record,
# but the component continues on in the next SL record, we will
# fail to record this bit. We should fix that.
cr_offset += len_cp
data_len -= len_cp
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Symbolic Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record already initialized!')
(su_len, su_entry_version_unused, self.flags) = struct.unpack_from('=BBB', rrstr[:5], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
cr_offset = 5
data_len = su_len - 5
while data_len > 0:
(cr_flags, len_cp) = struct.unpack_from('=BB', rrstr[:cr_offset + 2], cr_offset)
data_len -= 2
cr_offset += 2
self.symlink_components.append(self.Component(cr_flags, len_cp,
rrstr[cr_offset:cr_offset + len_cp]))
# FIXME: if this is the last component in this SL record,
# but the component continues on in the next SL record, we will
# fail to record this bit. We should fix that.
cr_offset += len_cp
data_len -= len_cp
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused... | Parse a Rock Ridge Symbolic Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Symbolic",
"Link",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L993-L1029 |
21,619 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.add_component | def add_component(self, symlink_comp):
# type: (bytes) -> None
'''
Add a new component to this symlink record.
Parameters:
symlink_comp - The string to add to this symlink record.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
if (self.current_length() + RRSLRecord.Component.length(symlink_comp)) > 255:
raise pycdlibexception.PyCdlibInvalidInput('Symlink would be longer than 255')
self.symlink_components.append(self.Component.factory(symlink_comp)) | python | def add_component(self, symlink_comp):
# type: (bytes) -> None
'''
Add a new component to this symlink record.
Parameters:
symlink_comp - The string to add to this symlink record.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
if (self.current_length() + RRSLRecord.Component.length(symlink_comp)) > 255:
raise pycdlibexception.PyCdlibInvalidInput('Symlink would be longer than 255')
self.symlink_components.append(self.Component.factory(symlink_comp)) | [
"def",
"add_component",
"(",
"self",
",",
"symlink_comp",
")",
":",
"# type: (bytes) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record not yet initialized!'",
")",
"if",
"(",
"self",
"... | Add a new component to this symlink record.
Parameters:
symlink_comp - The string to add to this symlink record.
Returns:
Nothing. | [
"Add",
"a",
"new",
"component",
"to",
"this",
"symlink",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1046-L1062 |
21,620 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.current_length | def current_length(self):
# type: () -> int
'''
Calculate the current length of this symlink record.
Parameters:
None.
Returns:
Length of this symlink record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
strlist = []
for comp in self.symlink_components:
strlist.append(comp.name())
return RRSLRecord.length(strlist) | python | def current_length(self):
# type: () -> int
'''
Calculate the current length of this symlink record.
Parameters:
None.
Returns:
Length of this symlink record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
strlist = []
for comp in self.symlink_components:
strlist.append(comp.name())
return RRSLRecord.length(strlist) | [
"def",
"current_length",
"(",
"self",
")",
":",
"# type: () -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record not yet initialized!'",
")",
"strlist",
"=",
"[",
"]",
"for",
"comp",
"in... | Calculate the current length of this symlink record.
Parameters:
None.
Returns:
Length of this symlink record. | [
"Calculate",
"the",
"current",
"length",
"of",
"this",
"symlink",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1064-L1081 |
21,621 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Symbolic Link record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
outlist = [b'SL', struct.pack('=BBB', self.current_length(), SU_ENTRY_VERSION, self.flags)]
for comp in self.symlink_components:
outlist.append(comp.record())
return b''.join(outlist) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Symbolic Link record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
outlist = [b'SL', struct.pack('=BBB', self.current_length(), SU_ENTRY_VERSION, self.flags)]
for comp in self.symlink_components:
outlist.append(comp.record())
return b''.join(outlist) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record not yet initialized!'",
")",
"outlist",
"=",
"[",
"b'SL'",
",",
"struct",
".",
... | Generate a string representing the Rock Ridge Symbolic Link record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Symbolic",
"Link",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1083-L1100 |
21,622 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.name | def name(self):
# type: () -> bytes
'''
Generate a string that contains all components of the symlink.
Parameters:
None
Returns:
String containing all components of the symlink.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
outlist = [] # type: List[bytes]
continued = False
for comp in self.symlink_components:
name = comp.name()
if name == b'/':
outlist = []
continued = False
name = b''
if not continued:
outlist.append(name)
else:
outlist[-1] += name
continued = comp.is_continued()
return b'/'.join(outlist) | python | def name(self):
# type: () -> bytes
'''
Generate a string that contains all components of the symlink.
Parameters:
None
Returns:
String containing all components of the symlink.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
outlist = [] # type: List[bytes]
continued = False
for comp in self.symlink_components:
name = comp.name()
if name == b'/':
outlist = []
continued = False
name = b''
if not continued:
outlist.append(name)
else:
outlist[-1] += name
continued = comp.is_continued()
return b'/'.join(outlist) | [
"def",
"name",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record not yet initialized!'",
")",
"outlist",
"=",
"[",
"]",
"# type: List[bytes]",
"cont... | Generate a string that contains all components of the symlink.
Parameters:
None
Returns:
String containing all components of the symlink. | [
"Generate",
"a",
"string",
"that",
"contains",
"all",
"components",
"of",
"the",
"symlink",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1102-L1131 |
21,623 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.set_last_component_continued | def set_last_component_continued(self):
# type: () -> None
'''
Set the previous component of this SL record to continued.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
if not self.symlink_components:
raise pycdlibexception.PyCdlibInternalError('Trying to set continued on a non-existent component!')
self.symlink_components[-1].set_continued() | python | def set_last_component_continued(self):
# type: () -> None
'''
Set the previous component of this SL record to continued.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
if not self.symlink_components:
raise pycdlibexception.PyCdlibInternalError('Trying to set continued on a non-existent component!')
self.symlink_components[-1].set_continued() | [
"def",
"set_last_component_continued",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record not yet initialized!'",
")",
"if",
"not",
"self",
".",
"symlin... | Set the previous component of this SL record to continued.
Parameters:
None.
Returns:
Nothing. | [
"Set",
"the",
"previous",
"component",
"of",
"this",
"SL",
"record",
"to",
"continued",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1148-L1164 |
21,624 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.last_component_continued | def last_component_continued(self):
# type: () -> bool
'''
Determines whether the previous component of this SL record is a
continued one or not.
Parameters:
None.
Returns:
True if the previous component of this SL record is continued, False otherwise.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
if not self.symlink_components:
raise pycdlibexception.PyCdlibInternalError('Trying to get continued on a non-existent component!')
return self.symlink_components[-1].is_continued() | python | def last_component_continued(self):
# type: () -> bool
'''
Determines whether the previous component of this SL record is a
continued one or not.
Parameters:
None.
Returns:
True if the previous component of this SL record is continued, False otherwise.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SL record not yet initialized!')
if not self.symlink_components:
raise pycdlibexception.PyCdlibInternalError('Trying to get continued on a non-existent component!')
return self.symlink_components[-1].is_continued() | [
"def",
"last_component_continued",
"(",
"self",
")",
":",
"# type: () -> bool",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SL record not yet initialized!'",
")",
"if",
"not",
"self",
".",
"symlink_co... | Determines whether the previous component of this SL record is a
continued one or not.
Parameters:
None.
Returns:
True if the previous component of this SL record is continued, False otherwise. | [
"Determines",
"whether",
"the",
"previous",
"component",
"of",
"this",
"SL",
"record",
"is",
"a",
"continued",
"one",
"or",
"not",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1166-L1183 |
21,625 | clalancette/pycdlib | pycdlib/rockridge.py | RRSLRecord.length | def length(symlink_components):
# type: (List[bytes]) -> int
'''
Static method to return the length of the Rock Ridge Symbolic Link
record.
Parameters:
symlink_components - A list containing a string for each of the
symbolic link components.
Returns:
The length of this record in bytes.
'''
length = RRSLRecord.header_length()
for comp in symlink_components:
length += RRSLRecord.Component.length(comp)
return length | python | def length(symlink_components):
# type: (List[bytes]) -> int
'''
Static method to return the length of the Rock Ridge Symbolic Link
record.
Parameters:
symlink_components - A list containing a string for each of the
symbolic link components.
Returns:
The length of this record in bytes.
'''
length = RRSLRecord.header_length()
for comp in symlink_components:
length += RRSLRecord.Component.length(comp)
return length | [
"def",
"length",
"(",
"symlink_components",
")",
":",
"# type: (List[bytes]) -> int",
"length",
"=",
"RRSLRecord",
".",
"header_length",
"(",
")",
"for",
"comp",
"in",
"symlink_components",
":",
"length",
"+=",
"RRSLRecord",
".",
"Component",
".",
"length",
"(",
... | Static method to return the length of the Rock Ridge Symbolic Link
record.
Parameters:
symlink_components - A list containing a string for each of the
symbolic link components.
Returns:
The length of this record in bytes. | [
"Static",
"method",
"to",
"return",
"the",
"length",
"of",
"the",
"Rock",
"Ridge",
"Symbolic",
"Link",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1209-L1224 |
21,626 | clalancette/pycdlib | pycdlib/rockridge.py | RRNMRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Alternate Name record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('NM record already initialized!')
(su_len, su_entry_version_unused, self.posix_name_flags) = struct.unpack_from('=BBB', rrstr[:5], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
name_len = su_len - 5
if (self.posix_name_flags & 0x7) not in (0, 1, 2, 4):
raise pycdlibexception.PyCdlibInvalidISO('Invalid Rock Ridge NM flags')
if name_len != 0:
if (self.posix_name_flags & (1 << 1)) or (self.posix_name_flags & (1 << 2)) or (self.posix_name_flags & (1 << 5)):
raise pycdlibexception.PyCdlibInvalidISO('Invalid name in Rock Ridge NM entry (0x%x %d)' % (self.posix_name_flags, name_len))
self.posix_name += rrstr[5:5 + name_len]
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Alternate Name record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('NM record already initialized!')
(su_len, su_entry_version_unused, self.posix_name_flags) = struct.unpack_from('=BBB', rrstr[:5], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
name_len = su_len - 5
if (self.posix_name_flags & 0x7) not in (0, 1, 2, 4):
raise pycdlibexception.PyCdlibInvalidISO('Invalid Rock Ridge NM flags')
if name_len != 0:
if (self.posix_name_flags & (1 << 1)) or (self.posix_name_flags & (1 << 2)) or (self.posix_name_flags & (1 << 5)):
raise pycdlibexception.PyCdlibInvalidISO('Invalid name in Rock Ridge NM entry (0x%x %d)' % (self.posix_name_flags, name_len))
self.posix_name += rrstr[5:5 + name_len]
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'NM record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused... | Parse a Rock Ridge Alternate Name record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Alternate",
"Name",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1239-L1266 |
21,627 | clalancette/pycdlib | pycdlib/rockridge.py | RRNMRecord.new | def new(self, rr_name):
# type: (bytes) -> None
'''
Create a new Rock Ridge Alternate Name record.
Parameters:
rr_name - The name for the new record.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('NM record already initialized!')
self.posix_name = rr_name
self.posix_name_flags = 0
self._initialized = True | python | def new(self, rr_name):
# type: (bytes) -> None
'''
Create a new Rock Ridge Alternate Name record.
Parameters:
rr_name - The name for the new record.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('NM record already initialized!')
self.posix_name = rr_name
self.posix_name_flags = 0
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"rr_name",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'NM record already initialized!'",
")",
"self",
".",
"posix_name",
"=",
"rr_name",... | Create a new Rock Ridge Alternate Name record.
Parameters:
rr_name - The name for the new record.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Alternate",
"Name",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1268-L1284 |
21,628 | clalancette/pycdlib | pycdlib/rockridge.py | RRNMRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Alternate Name record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('NM record not yet initialized!')
return b'NM' + struct.pack(b'=BBB', RRNMRecord.length(self.posix_name), SU_ENTRY_VERSION, self.posix_name_flags) + self.posix_name | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Alternate Name record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('NM record not yet initialized!')
return b'NM' + struct.pack(b'=BBB', RRNMRecord.length(self.posix_name), SU_ENTRY_VERSION, self.posix_name_flags) + self.posix_name | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'NM record not yet initialized!'",
")",
"return",
"b'NM'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Alternate Name record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Alternate",
"Name",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1286-L1299 |
21,629 | clalancette/pycdlib | pycdlib/rockridge.py | RRCLRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Child Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CL record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused, child_log_block_num_le, child_log_block_num_be) = struct.unpack_from('=BBLL', rrstr[:12], 2)
if su_len != RRCLRecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if child_log_block_num_le != utils.swab_32bit(child_log_block_num_be):
raise pycdlibexception.PyCdlibInvalidISO('Little endian block num does not equal big endian; corrupt ISO')
self.child_log_block_num = child_log_block_num_le
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Child Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CL record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused, child_log_block_num_le, child_log_block_num_be) = struct.unpack_from('=BBLL', rrstr[:12], 2)
if su_len != RRCLRecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if child_log_block_num_le != utils.swab_32bit(child_log_block_num_be):
raise pycdlibexception.PyCdlibInvalidISO('Little endian block num does not equal big endian; corrupt ISO')
self.child_log_block_num = child_log_block_num_le
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CL record already initialized!'",
")",
"# We assume that the caller has already checked t... | Parse a Rock Ridge Child Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Child",
"Link",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1344-L1368 |
21,630 | clalancette/pycdlib | pycdlib/rockridge.py | RRCLRecord.new | def new(self):
# type: () -> None
'''
Create a new Rock Ridge Child Link record.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CL record already initialized!')
self.child_log_block_num = 0 # This gets set later
self._initialized = True | python | def new(self):
# type: () -> None
'''
Create a new Rock Ridge Child Link record.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('CL record already initialized!')
self.child_log_block_num = 0 # This gets set later
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CL record already initialized!'",
")",
"self",
".",
"child_log_block_num",
"=",
"0",
"# This gets set la... | Create a new Rock Ridge Child Link record.
Parameters:
None.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Child",
"Link",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1370-L1385 |
21,631 | clalancette/pycdlib | pycdlib/rockridge.py | RRCLRecord.set_log_block_num | def set_log_block_num(self, bl):
# type: (int) -> None
'''
Set the logical block number for the child.
Parameters:
bl - Logical block number of the child.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CL record not yet initialized!')
self.child_log_block_num = bl | python | def set_log_block_num(self, bl):
# type: (int) -> None
'''
Set the logical block number for the child.
Parameters:
bl - Logical block number of the child.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CL record not yet initialized!')
self.child_log_block_num = bl | [
"def",
"set_log_block_num",
"(",
"self",
",",
"bl",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'CL record not yet initialized!'",
")",
"self",
".",
"child_log_block_... | Set the logical block number for the child.
Parameters:
bl - Logical block number of the child.
Returns:
Nothing. | [
"Set",
"the",
"logical",
"block",
"number",
"for",
"the",
"child",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1402-L1415 |
21,632 | clalancette/pycdlib | pycdlib/rockridge.py | RRPLRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Parent Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PL record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused, parent_log_block_num_le, parent_log_block_num_be) = struct.unpack_from('=BBLL', rrstr[:12], 2)
if su_len != RRPLRecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if parent_log_block_num_le != utils.swab_32bit(parent_log_block_num_be):
raise pycdlibexception.PyCdlibInvalidISO('Little endian block num does not equal big endian; corrupt ISO')
self.parent_log_block_num = parent_log_block_num_le
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Parent Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PL record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused, parent_log_block_num_le, parent_log_block_num_be) = struct.unpack_from('=BBLL', rrstr[:12], 2)
if su_len != RRPLRecord.length():
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
if parent_log_block_num_le != utils.swab_32bit(parent_log_block_num_be):
raise pycdlibexception.PyCdlibInvalidISO('Little endian block num does not equal big endian; corrupt ISO')
self.parent_log_block_num = parent_log_block_num_le
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PL record already initialized!'",
")",
"# We assume that the caller has already checked t... | Parse a Rock Ridge Parent Link record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Parent",
"Link",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1445-L1468 |
21,633 | clalancette/pycdlib | pycdlib/rockridge.py | RRPLRecord.new | def new(self):
# type: () -> None
'''
Generate a string representing the Rock Ridge Parent Link record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PL record already initialized!')
self.parent_log_block_num = 0 # This will get set later
self._initialized = True | python | def new(self):
# type: () -> None
'''
Generate a string representing the Rock Ridge Parent Link record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PL record already initialized!')
self.parent_log_block_num = 0 # This will get set later
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PL record already initialized!'",
")",
"self",
".",
"parent_log_block_num",
"=",
"0",
"# This will get s... | Generate a string representing the Rock Ridge Parent Link record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Parent",
"Link",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1470-L1485 |
21,634 | clalancette/pycdlib | pycdlib/rockridge.py | RRPLRecord.set_log_block_num | def set_log_block_num(self, bl):
# type: (int) -> None
'''
Set the logical block number for the parent.
Parameters:
bl - Logical block number of the parent.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PL record not yet initialized!')
self.parent_log_block_num = bl | python | def set_log_block_num(self, bl):
# type: (int) -> None
'''
Set the logical block number for the parent.
Parameters:
bl - Logical block number of the parent.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PL record not yet initialized!')
self.parent_log_block_num = bl | [
"def",
"set_log_block_num",
"(",
"self",
",",
"bl",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PL record not yet initialized!'",
")",
"self",
".",
"parent_log_block... | Set the logical block number for the parent.
Parameters:
bl - Logical block number of the parent.
Returns:
Nothing. | [
"Set",
"the",
"logical",
"block",
"number",
"for",
"the",
"parent",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1502-L1515 |
21,635 | clalancette/pycdlib | pycdlib/rockridge.py | RRTFRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Time Stamp record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused, self.time_flags,) = struct.unpack_from('=BBB', rrstr[:5], 2)
if su_len < 5:
raise pycdlibexception.PyCdlibInvalidISO('Not enough bytes in the TF record')
tflen = 7
if self.time_flags & (1 << 7):
tflen = 17
offset = 5
for index, fieldname in enumerate(self.FIELDNAMES):
if self.time_flags & (1 << index):
if tflen == 7:
setattr(self, fieldname, dates.DirectoryRecordDate())
elif tflen == 17:
setattr(self, fieldname, dates.VolumeDescriptorDate())
getattr(self, fieldname).parse(rrstr[offset:offset + tflen])
offset += tflen
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Time Stamp record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused, self.time_flags,) = struct.unpack_from('=BBB', rrstr[:5], 2)
if su_len < 5:
raise pycdlibexception.PyCdlibInvalidISO('Not enough bytes in the TF record')
tflen = 7
if self.time_flags & (1 << 7):
tflen = 17
offset = 5
for index, fieldname in enumerate(self.FIELDNAMES):
if self.time_flags & (1 << index):
if tflen == 7:
setattr(self, fieldname, dates.DirectoryRecordDate())
elif tflen == 17:
setattr(self, fieldname, dates.VolumeDescriptorDate())
getattr(self, fieldname).parse(rrstr[offset:offset + tflen])
offset += tflen
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'TF record already initialized!'",
")",
"# We assume that the caller has already checked t... | Parse a Rock Ridge Time Stamp record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Time",
"Stamp",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1558-L1592 |
21,636 | clalancette/pycdlib | pycdlib/rockridge.py | RRTFRecord.new | def new(self, time_flags):
# type: (int) -> None
'''
Create a new Rock Ridge Time Stamp record.
Parameters:
time_flags - The flags to use for this time stamp record.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record already initialized!')
self.time_flags = time_flags
tflen = 7
if self.time_flags & (1 << 7):
tflen = 17
for index, fieldname in enumerate(self.FIELDNAMES):
if self.time_flags & (1 << index):
if tflen == 7:
setattr(self, fieldname, dates.DirectoryRecordDate())
elif tflen == 17:
setattr(self, fieldname, dates.VolumeDescriptorDate())
getattr(self, fieldname).new()
self._initialized = True | python | def new(self, time_flags):
# type: (int) -> None
'''
Create a new Rock Ridge Time Stamp record.
Parameters:
time_flags - The flags to use for this time stamp record.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record already initialized!')
self.time_flags = time_flags
tflen = 7
if self.time_flags & (1 << 7):
tflen = 17
for index, fieldname in enumerate(self.FIELDNAMES):
if self.time_flags & (1 << index):
if tflen == 7:
setattr(self, fieldname, dates.DirectoryRecordDate())
elif tflen == 17:
setattr(self, fieldname, dates.VolumeDescriptorDate())
getattr(self, fieldname).new()
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"time_flags",
")",
":",
"# type: (int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'TF record already initialized!'",
")",
"self",
".",
"time_flags",
"=",
"time_fla... | Create a new Rock Ridge Time Stamp record.
Parameters:
time_flags - The flags to use for this time stamp record.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Time",
"Stamp",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1594-L1621 |
21,637 | clalancette/pycdlib | pycdlib/rockridge.py | RRTFRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Time Stamp record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record not yet initialized!')
outlist = [b'TF', struct.pack('=BBB', RRTFRecord.length(self.time_flags), SU_ENTRY_VERSION, self.time_flags)]
for fieldname in self.FIELDNAMES:
field = getattr(self, fieldname)
if field is not None:
outlist.append(field.record())
return b''.join(outlist) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Time Stamp record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record not yet initialized!')
outlist = [b'TF', struct.pack('=BBB', RRTFRecord.length(self.time_flags), SU_ENTRY_VERSION, self.time_flags)]
for fieldname in self.FIELDNAMES:
field = getattr(self, fieldname)
if field is not None:
outlist.append(field.record())
return b''.join(outlist) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'TF record not yet initialized!'",
")",
"outlist",
"=",
"[",
"b'TF'",
",",
"struct",
".",
... | Generate a string representing the Rock Ridge Time Stamp record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Time",
"Stamp",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1623-L1642 |
21,638 | clalancette/pycdlib | pycdlib/rockridge.py | RRTFRecord.length | def length(time_flags):
# type: (int) -> int
'''
Static method to return the length of the Rock Ridge Time Stamp
record.
Parameters:
time_flags - Integer representing the flags to use.
Returns:
The length of this record in bytes.
'''
tf_each_size = 7
if time_flags & (1 << 7):
tf_each_size = 17
time_flags &= 0x7f
tf_num = 0
while time_flags:
time_flags &= time_flags - 1
tf_num += 1
return 5 + tf_each_size * tf_num | python | def length(time_flags):
# type: (int) -> int
'''
Static method to return the length of the Rock Ridge Time Stamp
record.
Parameters:
time_flags - Integer representing the flags to use.
Returns:
The length of this record in bytes.
'''
tf_each_size = 7
if time_flags & (1 << 7):
tf_each_size = 17
time_flags &= 0x7f
tf_num = 0
while time_flags:
time_flags &= time_flags - 1
tf_num += 1
return 5 + tf_each_size * tf_num | [
"def",
"length",
"(",
"time_flags",
")",
":",
"# type: (int) -> int",
"tf_each_size",
"=",
"7",
"if",
"time_flags",
"&",
"(",
"1",
"<<",
"7",
")",
":",
"tf_each_size",
"=",
"17",
"time_flags",
"&=",
"0x7f",
"tf_num",
"=",
"0",
"while",
"time_flags",
":",
... | Static method to return the length of the Rock Ridge Time Stamp
record.
Parameters:
time_flags - Integer representing the flags to use.
Returns:
The length of this record in bytes. | [
"Static",
"method",
"to",
"return",
"the",
"length",
"of",
"the",
"Rock",
"Ridge",
"Time",
"Stamp",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1645-L1665 |
21,639 | clalancette/pycdlib | pycdlib/rockridge.py | RRSFRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Sparse File record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('SF record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused,) = struct.unpack_from('=BB', rrstr[:4], 2)
if su_len == 12:
# This is a Rock Ridge version 1.10 SF Record, which is 12 bytes.
(virtual_file_size_le, virtual_file_size_be) = struct.unpack_from('=LL', rrstr[:12], 4)
if virtual_file_size_le != utils.swab_32bit(virtual_file_size_be):
raise pycdlibexception.PyCdlibInvalidISO('Virtual file size little-endian does not match big-endian')
self.virtual_file_size_low = virtual_file_size_le
elif su_len == 21:
# This is a Rock Ridge version 1.12 SF Record, which is 21 bytes.
(virtual_file_size_high_le, virtual_file_size_high_be, virtual_file_size_low_le,
virtual_file_size_low_be, self.table_depth) = struct.unpack_from('=LLLLB', rrstr[:21], 4)
if virtual_file_size_high_le != utils.swab_32bit(virtual_file_size_high_be):
raise pycdlibexception.PyCdlibInvalidISO('Virtual file size high little-endian does not match big-endian')
if virtual_file_size_low_le != utils.swab_32bit(virtual_file_size_low_be):
raise pycdlibexception.PyCdlibInvalidISO('Virtual file size low little-endian does not match big-endian')
self.virtual_file_size_low = virtual_file_size_low_le
self.virtual_file_size_high = virtual_file_size_high_le
else:
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on Rock Ridge SF record (expected 12 or 21)')
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Sparse File record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('SF record already initialized!')
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
(su_len, su_entry_version_unused,) = struct.unpack_from('=BB', rrstr[:4], 2)
if su_len == 12:
# This is a Rock Ridge version 1.10 SF Record, which is 12 bytes.
(virtual_file_size_le, virtual_file_size_be) = struct.unpack_from('=LL', rrstr[:12], 4)
if virtual_file_size_le != utils.swab_32bit(virtual_file_size_be):
raise pycdlibexception.PyCdlibInvalidISO('Virtual file size little-endian does not match big-endian')
self.virtual_file_size_low = virtual_file_size_le
elif su_len == 21:
# This is a Rock Ridge version 1.12 SF Record, which is 21 bytes.
(virtual_file_size_high_le, virtual_file_size_high_be, virtual_file_size_low_le,
virtual_file_size_low_be, self.table_depth) = struct.unpack_from('=LLLLB', rrstr[:21], 4)
if virtual_file_size_high_le != utils.swab_32bit(virtual_file_size_high_be):
raise pycdlibexception.PyCdlibInvalidISO('Virtual file size high little-endian does not match big-endian')
if virtual_file_size_low_le != utils.swab_32bit(virtual_file_size_low_be):
raise pycdlibexception.PyCdlibInvalidISO('Virtual file size low little-endian does not match big-endian')
self.virtual_file_size_low = virtual_file_size_low_le
self.virtual_file_size_high = virtual_file_size_high_le
else:
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on Rock Ridge SF record (expected 12 or 21)')
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SF record already initialized!'",
")",
"# We assume that the caller has already checked t... | Parse a Rock Ridge Sparse File record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Sparse",
"File",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1683-L1721 |
21,640 | clalancette/pycdlib | pycdlib/rockridge.py | RRSFRecord.new | def new(self, file_size_high, file_size_low, table_depth):
# type: (Optional[int], int, Optional[int]) -> None
'''
Create a new Rock Ridge Sparse File record.
Parameters:
file_size_high - The high-order 32-bits of the file size.
file_size_low - The low-order 32-bits of the file size.
table_depth - The maximum virtual file size.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('SF record already initialized!')
self.virtual_file_size_high = file_size_high
self.virtual_file_size_low = file_size_low
self.table_depth = table_depth
self._initialized = True | python | def new(self, file_size_high, file_size_low, table_depth):
# type: (Optional[int], int, Optional[int]) -> None
'''
Create a new Rock Ridge Sparse File record.
Parameters:
file_size_high - The high-order 32-bits of the file size.
file_size_low - The low-order 32-bits of the file size.
table_depth - The maximum virtual file size.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('SF record already initialized!')
self.virtual_file_size_high = file_size_high
self.virtual_file_size_low = file_size_low
self.table_depth = table_depth
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"file_size_high",
",",
"file_size_low",
",",
"table_depth",
")",
":",
"# type: (Optional[int], int, Optional[int]) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SF recor... | Create a new Rock Ridge Sparse File record.
Parameters:
file_size_high - The high-order 32-bits of the file size.
file_size_low - The low-order 32-bits of the file size.
table_depth - The maximum virtual file size.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Sparse",
"File",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1723-L1742 |
21,641 | clalancette/pycdlib | pycdlib/rockridge.py | RRSFRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Sparse File record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SF record not yet initialized!')
length = 12
if self.virtual_file_size_high is not None:
length = 21
ret = b'SF' + struct.pack('=BB', length, SU_ENTRY_VERSION)
if self.virtual_file_size_high is not None and self.table_depth is not None:
ret += struct.pack('=LLLLB', self.virtual_file_size_high, utils.swab_32bit(self.virtual_file_size_high), self.virtual_file_size_low, utils.swab_32bit(self.virtual_file_size_low), self.table_depth)
else:
ret += struct.pack('=LL', self.virtual_file_size_low, utils.swab_32bit(self.virtual_file_size_low))
return ret | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Sparse File record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('SF record not yet initialized!')
length = 12
if self.virtual_file_size_high is not None:
length = 21
ret = b'SF' + struct.pack('=BB', length, SU_ENTRY_VERSION)
if self.virtual_file_size_high is not None and self.table_depth is not None:
ret += struct.pack('=LLLLB', self.virtual_file_size_high, utils.swab_32bit(self.virtual_file_size_high), self.virtual_file_size_low, utils.swab_32bit(self.virtual_file_size_low), self.table_depth)
else:
ret += struct.pack('=LL', self.virtual_file_size_low, utils.swab_32bit(self.virtual_file_size_low))
return ret | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'SF record not yet initialized!'",
")",
"length",
"=",
"12",
"if",
"self",
".",
"virtual_f... | Generate a string representing the Rock Ridge Sparse File record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Sparse",
"File",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1744-L1766 |
21,642 | clalancette/pycdlib | pycdlib/rockridge.py | RRRERecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Relocated Directory
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('RE record not yet initialized!')
return b'RE' + struct.pack('=BB', RRRERecord.length(), SU_ENTRY_VERSION) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Relocated Directory
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('RE record not yet initialized!')
return b'RE' + struct.pack('=BB', RRRERecord.length(), SU_ENTRY_VERSION) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'RE record not yet initialized!'",
")",
"return",
"b'RE'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Relocated Directory
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Relocated",
"Directory",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1839-L1853 |
21,643 | clalancette/pycdlib | pycdlib/rockridge.py | RRSTRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge System Terminator record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ST record already initialized!')
(su_len, su_entry_version_unused) = struct.unpack_from('=BB', rrstr[:4], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if su_len != 4:
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge System Terminator record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('ST record already initialized!')
(su_len, su_entry_version_unused) = struct.unpack_from('=BB', rrstr[:4], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
if su_len != 4:
raise pycdlibexception.PyCdlibInvalidISO('Invalid length on rock ridge extension')
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ST record already initialized!'",
")",
"(",
"su_len",
",",
"su_entry_version_unused... | Parse a Rock Ridge System Terminator record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"System",
"Terminator",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1882-L1903 |
21,644 | clalancette/pycdlib | pycdlib/rockridge.py | RRSTRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge System Terminator
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('ST record not yet initialized!')
return b'ST' + struct.pack('=BB', RRSTRecord.length(), SU_ENTRY_VERSION) | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge System Terminator
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('ST record not yet initialized!')
return b'ST' + struct.pack('=BB', RRSTRecord.length(), SU_ENTRY_VERSION) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'ST record not yet initialized!'",
")",
"return",
"b'ST'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge System Terminator
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"System",
"Terminator",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1920-L1934 |
21,645 | clalancette/pycdlib | pycdlib/rockridge.py | RRPDRecord.parse | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Platform Dependent record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PD record already initialized!')
(su_len_unused, su_entry_version_unused) = struct.unpack_from('=BB', rrstr[:4], 2)
self.padding = rrstr[4:]
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
self._initialized = True | python | def parse(self, rrstr):
# type: (bytes) -> None
'''
Parse a Rock Ridge Platform Dependent record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PD record already initialized!')
(su_len_unused, su_entry_version_unused) = struct.unpack_from('=BB', rrstr[:4], 2)
self.padding = rrstr[4:]
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"rrstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PD record already initialized!'",
")",
"(",
"su_len_unused",
",",
"su_entry_version... | Parse a Rock Ridge Platform Dependent record out of a string.
Parameters:
rrstr - The string to parse the record out of.
Returns:
Nothing. | [
"Parse",
"a",
"Rock",
"Ridge",
"Platform",
"Dependent",
"record",
"out",
"of",
"a",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1963-L1983 |
21,646 | clalancette/pycdlib | pycdlib/rockridge.py | RRPDRecord.new | def new(self):
# type: () -> None
'''
Create a new Rock Ridge Platform Dependent record.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PD record already initialized!')
self._initialized = True
self.padding = b'' | python | def new(self):
# type: () -> None
'''
Create a new Rock Ridge Platform Dependent record.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('PD record already initialized!')
self._initialized = True
self.padding = b'' | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PD record already initialized!'",
")",
"self",
".",
"_initialized",
"=",
"True",
"self",
".",
"paddi... | Create a new Rock Ridge Platform Dependent record.
Parameters:
None.
Returns:
Nothing. | [
"Create",
"a",
"new",
"Rock",
"Ridge",
"Platform",
"Dependent",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L1985-L1999 |
21,647 | clalancette/pycdlib | pycdlib/rockridge.py | RRPDRecord.record | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Platform Dependent
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PD record not yet initialized!')
return b'PD' + struct.pack('=BB', RRPDRecord.length(self.padding),
SU_ENTRY_VERSION) + self.padding | python | def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Platform Dependent
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('PD record not yet initialized!')
return b'PD' + struct.pack('=BB', RRPDRecord.length(self.padding),
SU_ENTRY_VERSION) + self.padding | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'PD record not yet initialized!'",
")",
"return",
"b'PD'",
"+",
"struct",
".",
"pack",
"("... | Generate a string representing the Rock Ridge Platform Dependent
record.
Parameters:
None.
Returns:
String containing the Rock Ridge record. | [
"Generate",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"Platform",
"Dependent",
"record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2001-L2016 |
21,648 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.has_entry | def has_entry(self, name):
# type: (str) -> bool
'''
An internal method to tell if we have already parsed an entry of the
named type.
Parameters:
name - The name of the entry to check.
Returns:
True if we have already parsed an entry of the named type, False otherwise.
'''
return getattr(self.dr_entries, name) or getattr(self.ce_entries, name) | python | def has_entry(self, name):
# type: (str) -> bool
'''
An internal method to tell if we have already parsed an entry of the
named type.
Parameters:
name - The name of the entry to check.
Returns:
True if we have already parsed an entry of the named type, False otherwise.
'''
return getattr(self.dr_entries, name) or getattr(self.ce_entries, name) | [
"def",
"has_entry",
"(",
"self",
",",
"name",
")",
":",
"# type: (str) -> bool",
"return",
"getattr",
"(",
"self",
".",
"dr_entries",
",",
"name",
")",
"or",
"getattr",
"(",
"self",
".",
"ce_entries",
",",
"name",
")"
] | An internal method to tell if we have already parsed an entry of the
named type.
Parameters:
name - The name of the entry to check.
Returns:
True if we have already parsed an entry of the named type, False otherwise. | [
"An",
"internal",
"method",
"to",
"tell",
"if",
"we",
"have",
"already",
"parsed",
"an",
"entry",
"of",
"the",
"named",
"type",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2095-L2106 |
21,649 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge._record | def _record(self, entries):
# type: (RockRidgeEntries) -> bytes
'''
Return a string representing the Rock Ridge entry.
Parameters:
entries - The dr_entries or ce_entries to generate a record for.
Returns:
A string representing the Rock Ridge entry.
'''
outlist = []
if entries.sp_record is not None:
outlist.append(entries.sp_record.record())
if entries.rr_record is not None:
outlist.append(entries.rr_record.record())
for nm_record in entries.nm_records:
outlist.append(nm_record.record())
if entries.px_record is not None:
outlist.append(entries.px_record.record(self.rr_version))
for sl_record in entries.sl_records:
outlist.append(sl_record.record())
if entries.tf_record is not None:
outlist.append(entries.tf_record.record())
if entries.cl_record is not None:
outlist.append(entries.cl_record.record())
if entries.pl_record is not None:
outlist.append(entries.pl_record.record())
if entries.re_record is not None:
outlist.append(entries.re_record.record())
for es_record in entries.es_records:
outlist.append(es_record.record())
if entries.er_record is not None:
outlist.append(entries.er_record.record())
if entries.ce_record is not None:
outlist.append(entries.ce_record.record())
for pd_record in entries.pd_records:
outlist.append(pd_record.record())
if entries.st_record is not None:
outlist.append(entries.st_record.record())
if entries.sf_record is not None:
outlist.append(entries.sf_record.record())
return b''.join(outlist) | python | def _record(self, entries):
# type: (RockRidgeEntries) -> bytes
'''
Return a string representing the Rock Ridge entry.
Parameters:
entries - The dr_entries or ce_entries to generate a record for.
Returns:
A string representing the Rock Ridge entry.
'''
outlist = []
if entries.sp_record is not None:
outlist.append(entries.sp_record.record())
if entries.rr_record is not None:
outlist.append(entries.rr_record.record())
for nm_record in entries.nm_records:
outlist.append(nm_record.record())
if entries.px_record is not None:
outlist.append(entries.px_record.record(self.rr_version))
for sl_record in entries.sl_records:
outlist.append(sl_record.record())
if entries.tf_record is not None:
outlist.append(entries.tf_record.record())
if entries.cl_record is not None:
outlist.append(entries.cl_record.record())
if entries.pl_record is not None:
outlist.append(entries.pl_record.record())
if entries.re_record is not None:
outlist.append(entries.re_record.record())
for es_record in entries.es_records:
outlist.append(es_record.record())
if entries.er_record is not None:
outlist.append(entries.er_record.record())
if entries.ce_record is not None:
outlist.append(entries.ce_record.record())
for pd_record in entries.pd_records:
outlist.append(pd_record.record())
if entries.st_record is not None:
outlist.append(entries.st_record.record())
if entries.sf_record is not None:
outlist.append(entries.sf_record.record())
return b''.join(outlist) | [
"def",
"_record",
"(",
"self",
",",
"entries",
")",
":",
"# type: (RockRidgeEntries) -> bytes",
"outlist",
"=",
"[",
"]",
"if",
"entries",
".",
"sp_record",
"is",
"not",
"None",
":",
"outlist",
".",
"append",
"(",
"entries",
".",
"sp_record",
".",
"record",
... | Return a string representing the Rock Ridge entry.
Parameters:
entries - The dr_entries or ce_entries to generate a record for.
Returns:
A string representing the Rock Ridge entry. | [
"Return",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2274-L2331 |
21,650 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.record_dr_entries | def record_dr_entries(self):
# type: () -> bytes
'''
Return a string representing the Rock Ridge entries in the Directory Record.
Parameters:
None.
Returns:
A string representing the Rock Ridge entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
return self._record(self.dr_entries) | python | def record_dr_entries(self):
# type: () -> bytes
'''
Return a string representing the Rock Ridge entries in the Directory Record.
Parameters:
None.
Returns:
A string representing the Rock Ridge entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
return self._record(self.dr_entries) | [
"def",
"record_dr_entries",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"return",
"self",
".",
"_record",
... | Return a string representing the Rock Ridge entries in the Directory Record.
Parameters:
None.
Returns:
A string representing the Rock Ridge entry. | [
"Return",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"entries",
"in",
"the",
"Directory",
"Record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2333-L2346 |
21,651 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.record_ce_entries | def record_ce_entries(self):
# type: () -> bytes
'''
Return a string representing the Rock Ridge entries in the Continuation Entry.
Parameters:
None.
Returns:
A string representing the Rock Ridge entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
return self._record(self.ce_entries) | python | def record_ce_entries(self):
# type: () -> bytes
'''
Return a string representing the Rock Ridge entries in the Continuation Entry.
Parameters:
None.
Returns:
A string representing the Rock Ridge entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
return self._record(self.ce_entries) | [
"def",
"record_ce_entries",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"return",
"self",
".",
"_record",
... | Return a string representing the Rock Ridge entries in the Continuation Entry.
Parameters:
None.
Returns:
A string representing the Rock Ridge entry. | [
"Return",
"a",
"string",
"representing",
"the",
"Rock",
"Ridge",
"entries",
"in",
"the",
"Continuation",
"Entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2348-L2361 |
21,652 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge._add_ce_record | def _add_ce_record(self, curr_dr_len, thislen):
# type: (int, int) -> int
'''
An internal method to add a new length to a Continuation Entry. If the
Continuation Entry does not yet exist, this method creates it.
Parameters:
curr_dr_len - The current Directory Record length.
thislen - The new length to add to the Continuation Entry.
Returns:
An integer representing the current directory record length after
adding the Continuation Entry.
'''
if self.dr_entries.ce_record is None:
self.dr_entries.ce_record = RRCERecord()
self.dr_entries.ce_record.new()
curr_dr_len += RRCERecord.length()
self.dr_entries.ce_record.add_record(thislen)
return curr_dr_len | python | def _add_ce_record(self, curr_dr_len, thislen):
# type: (int, int) -> int
'''
An internal method to add a new length to a Continuation Entry. If the
Continuation Entry does not yet exist, this method creates it.
Parameters:
curr_dr_len - The current Directory Record length.
thislen - The new length to add to the Continuation Entry.
Returns:
An integer representing the current directory record length after
adding the Continuation Entry.
'''
if self.dr_entries.ce_record is None:
self.dr_entries.ce_record = RRCERecord()
self.dr_entries.ce_record.new()
curr_dr_len += RRCERecord.length()
self.dr_entries.ce_record.add_record(thislen)
return curr_dr_len | [
"def",
"_add_ce_record",
"(",
"self",
",",
"curr_dr_len",
",",
"thislen",
")",
":",
"# type: (int, int) -> int",
"if",
"self",
".",
"dr_entries",
".",
"ce_record",
"is",
"None",
":",
"self",
".",
"dr_entries",
".",
"ce_record",
"=",
"RRCERecord",
"(",
")",
"... | An internal method to add a new length to a Continuation Entry. If the
Continuation Entry does not yet exist, this method creates it.
Parameters:
curr_dr_len - The current Directory Record length.
thislen - The new length to add to the Continuation Entry.
Returns:
An integer representing the current directory record length after
adding the Continuation Entry. | [
"An",
"internal",
"method",
"to",
"add",
"a",
"new",
"length",
"to",
"a",
"Continuation",
"Entry",
".",
"If",
"the",
"Continuation",
"Entry",
"does",
"not",
"yet",
"exist",
"this",
"method",
"creates",
"it",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2363-L2381 |
21,653 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge._add_name | def _add_name(self, rr_name, curr_dr_len):
# type: (bytes, int) -> int
'''
An internal method to add the appropriate name records to the ISO.
Parameters:
rr_name - The Rock Ridge name to add to the ISO.
curr_dr_len - The current directory record length.
Returns:
The new directory record length.
'''
# The length we are putting in this object (as opposed to the
# continuation entry) is the maximum, minus how much is already in the
# DR, minus 5 for the NM metadata. We know that at least part of the
# NM record will always fit in this DR. That's because the DR is a
# maximum size of 255, and the ISO9660 fields uses a maximum of 34 bytes
# for metadata and 8+1+3+1+5 (8 for name, 1 for dot, 3 for extension,
# 1 for semicolon, and 5 for version number, allowed up to 32767), which
# leaves the System Use entry with 255 - 34 - 18 = 203 bytes. Before
# this record, the only records we ever put in place could be the SP or
# the RR record, and the combination of them is never > 203, so we will
# always put some NM data in here.
len_here = ALLOWED_DR_SIZE - curr_dr_len - 5
if len_here < len(rr_name):
curr_dr_len = self._add_ce_record(curr_dr_len, 0)
len_here = ALLOWED_DR_SIZE - curr_dr_len - 5
curr_nm = RRNMRecord()
curr_nm.new(rr_name[:len_here])
self.dr_entries.nm_records.append(curr_nm)
curr_dr_len += RRNMRecord.length(rr_name[:len_here])
offset = len_here
while offset < len(rr_name):
curr_nm.set_continued()
# We clip the length for this NM entry to 250, as that is
# the maximum possible size for an NM entry.
length = min(len(rr_name[offset:]), 250)
curr_nm = RRNMRecord()
curr_nm.new(rr_name[offset:offset + length])
self.ce_entries.nm_records.append(curr_nm)
if self.dr_entries.ce_record is not None:
self.dr_entries.ce_record.add_record(RRNMRecord.length(rr_name[offset:offset + length]))
offset += length
return curr_dr_len | python | def _add_name(self, rr_name, curr_dr_len):
# type: (bytes, int) -> int
'''
An internal method to add the appropriate name records to the ISO.
Parameters:
rr_name - The Rock Ridge name to add to the ISO.
curr_dr_len - The current directory record length.
Returns:
The new directory record length.
'''
# The length we are putting in this object (as opposed to the
# continuation entry) is the maximum, minus how much is already in the
# DR, minus 5 for the NM metadata. We know that at least part of the
# NM record will always fit in this DR. That's because the DR is a
# maximum size of 255, and the ISO9660 fields uses a maximum of 34 bytes
# for metadata and 8+1+3+1+5 (8 for name, 1 for dot, 3 for extension,
# 1 for semicolon, and 5 for version number, allowed up to 32767), which
# leaves the System Use entry with 255 - 34 - 18 = 203 bytes. Before
# this record, the only records we ever put in place could be the SP or
# the RR record, and the combination of them is never > 203, so we will
# always put some NM data in here.
len_here = ALLOWED_DR_SIZE - curr_dr_len - 5
if len_here < len(rr_name):
curr_dr_len = self._add_ce_record(curr_dr_len, 0)
len_here = ALLOWED_DR_SIZE - curr_dr_len - 5
curr_nm = RRNMRecord()
curr_nm.new(rr_name[:len_here])
self.dr_entries.nm_records.append(curr_nm)
curr_dr_len += RRNMRecord.length(rr_name[:len_here])
offset = len_here
while offset < len(rr_name):
curr_nm.set_continued()
# We clip the length for this NM entry to 250, as that is
# the maximum possible size for an NM entry.
length = min(len(rr_name[offset:]), 250)
curr_nm = RRNMRecord()
curr_nm.new(rr_name[offset:offset + length])
self.ce_entries.nm_records.append(curr_nm)
if self.dr_entries.ce_record is not None:
self.dr_entries.ce_record.add_record(RRNMRecord.length(rr_name[offset:offset + length]))
offset += length
return curr_dr_len | [
"def",
"_add_name",
"(",
"self",
",",
"rr_name",
",",
"curr_dr_len",
")",
":",
"# type: (bytes, int) -> int",
"# The length we are putting in this object (as opposed to the",
"# continuation entry) is the maximum, minus how much is already in the",
"# DR, minus 5 for the NM metadata. We k... | An internal method to add the appropriate name records to the ISO.
Parameters:
rr_name - The Rock Ridge name to add to the ISO.
curr_dr_len - The current directory record length.
Returns:
The new directory record length. | [
"An",
"internal",
"method",
"to",
"add",
"the",
"appropriate",
"name",
"records",
"to",
"the",
"ISO",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2502-L2549 |
21,654 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.add_to_file_links | def add_to_file_links(self):
# type: () -> None
'''
Increment the number of POSIX file links on this entry by one.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.px_record is None:
if self.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file links')
self.ce_entries.px_record.posix_file_links += 1
else:
self.dr_entries.px_record.posix_file_links += 1 | python | def add_to_file_links(self):
# type: () -> None
'''
Increment the number of POSIX file links on this entry by one.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.px_record is None:
if self.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file links')
self.ce_entries.px_record.posix_file_links += 1
else:
self.dr_entries.px_record.posix_file_links += 1 | [
"def",
"add_to_file_links",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"if",
"self",
".",
"dr_entries",
"... | Increment the number of POSIX file links on this entry by one.
Parameters:
None.
Returns:
Nothing. | [
"Increment",
"the",
"number",
"of",
"POSIX",
"file",
"links",
"on",
"this",
"entry",
"by",
"one",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2728-L2746 |
21,655 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.copy_file_links | def copy_file_links(self, src):
# type: (RockRidge) -> None
'''
Copy the number of file links from the source Rock Ridge entry into
this Rock Ridge entry.
Parameters:
src - The source Rock Ridge entry to copy from.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
# First, get the src data
if src.dr_entries.px_record is None:
if src.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file links')
num_links = src.ce_entries.px_record.posix_file_links
else:
num_links = src.dr_entries.px_record.posix_file_links
# Now apply it to this record.
if self.dr_entries.px_record is None:
if self.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file links')
self.ce_entries.px_record.posix_file_links = num_links
else:
self.dr_entries.px_record.posix_file_links = num_links | python | def copy_file_links(self, src):
# type: (RockRidge) -> None
'''
Copy the number of file links from the source Rock Ridge entry into
this Rock Ridge entry.
Parameters:
src - The source Rock Ridge entry to copy from.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
# First, get the src data
if src.dr_entries.px_record is None:
if src.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file links')
num_links = src.ce_entries.px_record.posix_file_links
else:
num_links = src.dr_entries.px_record.posix_file_links
# Now apply it to this record.
if self.dr_entries.px_record is None:
if self.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file links')
self.ce_entries.px_record.posix_file_links = num_links
else:
self.dr_entries.px_record.posix_file_links = num_links | [
"def",
"copy_file_links",
"(",
"self",
",",
"src",
")",
":",
"# type: (RockRidge) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"# First, get the s... | Copy the number of file links from the source Rock Ridge entry into
this Rock Ridge entry.
Parameters:
src - The source Rock Ridge entry to copy from.
Returns:
Nothing. | [
"Copy",
"the",
"number",
"of",
"file",
"links",
"from",
"the",
"source",
"Rock",
"Ridge",
"entry",
"into",
"this",
"Rock",
"Ridge",
"entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2768-L2796 |
21,656 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.get_file_mode | def get_file_mode(self):
# type: () -> int
'''
Get the POSIX file mode bits for this Rock Ridge entry.
Parameters:
None.
Returns:
The POSIX file mode bits for this Rock Ridge entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.px_record is None:
if self.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file mode')
return self.ce_entries.px_record.posix_file_mode
return self.dr_entries.px_record.posix_file_mode | python | def get_file_mode(self):
# type: () -> int
'''
Get the POSIX file mode bits for this Rock Ridge entry.
Parameters:
None.
Returns:
The POSIX file mode bits for this Rock Ridge entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.px_record is None:
if self.ce_entries.px_record is None:
raise pycdlibexception.PyCdlibInvalidInput('No Rock Ridge file mode')
return self.ce_entries.px_record.posix_file_mode
return self.dr_entries.px_record.posix_file_mode | [
"def",
"get_file_mode",
"(",
"self",
")",
":",
"# type: () -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"if",
"self",
".",
"dr_entries",
".",
... | Get the POSIX file mode bits for this Rock Ridge entry.
Parameters:
None.
Returns:
The POSIX file mode bits for this Rock Ridge entry. | [
"Get",
"the",
"POSIX",
"file",
"mode",
"bits",
"for",
"this",
"Rock",
"Ridge",
"entry",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2798-L2816 |
21,657 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge._is_symlink | def _is_symlink(self):
# type: () -> bool
'''
Internal method to determine whether this Rock Ridge entry is a symlink.
'''
return len(self.dr_entries.sl_records) > 0 or len(self.ce_entries.sl_records) > 0 | python | def _is_symlink(self):
# type: () -> bool
'''
Internal method to determine whether this Rock Ridge entry is a symlink.
'''
return len(self.dr_entries.sl_records) > 0 or len(self.ce_entries.sl_records) > 0 | [
"def",
"_is_symlink",
"(",
"self",
")",
":",
"# type: () -> bool",
"return",
"len",
"(",
"self",
".",
"dr_entries",
".",
"sl_records",
")",
">",
"0",
"or",
"len",
"(",
"self",
".",
"ce_entries",
".",
"sl_records",
")",
">",
"0"
] | Internal method to determine whether this Rock Ridge entry is a symlink. | [
"Internal",
"method",
"to",
"determine",
"whether",
"this",
"Rock",
"Ridge",
"entry",
"is",
"a",
"symlink",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2833-L2838 |
21,658 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.child_link_extent | def child_link_extent(self):
# type: () -> int
'''
Get the extent of the child of this entry if it has one.
Parameters:
None.
Returns:
The logical block number of the child if it exists.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.cl_record is not None:
return self.dr_entries.cl_record.child_log_block_num
if self.ce_entries.cl_record is not None:
return self.ce_entries.cl_record.child_log_block_num
raise pycdlibexception.PyCdlibInternalError('Asked for child extent for non-existent parent record') | python | def child_link_extent(self):
# type: () -> int
'''
Get the extent of the child of this entry if it has one.
Parameters:
None.
Returns:
The logical block number of the child if it exists.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.cl_record is not None:
return self.dr_entries.cl_record.child_log_block_num
if self.ce_entries.cl_record is not None:
return self.ce_entries.cl_record.child_log_block_num
raise pycdlibexception.PyCdlibInternalError('Asked for child extent for non-existent parent record') | [
"def",
"child_link_extent",
"(",
"self",
")",
":",
"# type: () -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"if",
"self",
".",
"dr_entries",
".... | Get the extent of the child of this entry if it has one.
Parameters:
None.
Returns:
The logical block number of the child if it exists. | [
"Get",
"the",
"extent",
"of",
"the",
"child",
"of",
"this",
"entry",
"if",
"it",
"has",
"one",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2929-L2947 |
21,659 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.parent_link_extent | def parent_link_extent(self):
# type: () -> int
'''
Get the extent of the parent of this entry if it has one.
Parameters:
None.
Returns:
The logical block number of the parent if it exists.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.pl_record is not None:
return self.dr_entries.pl_record.parent_log_block_num
if self.ce_entries.pl_record is not None:
return self.ce_entries.pl_record.parent_log_block_num
raise pycdlibexception.PyCdlibInternalError('Asked for parent extent for non-existent parent record') | python | def parent_link_extent(self):
# type: () -> int
'''
Get the extent of the parent of this entry if it has one.
Parameters:
None.
Returns:
The logical block number of the parent if it exists.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
if self.dr_entries.pl_record is not None:
return self.dr_entries.pl_record.parent_log_block_num
if self.ce_entries.pl_record is not None:
return self.ce_entries.pl_record.parent_log_block_num
raise pycdlibexception.PyCdlibInternalError('Asked for parent extent for non-existent parent record') | [
"def",
"parent_link_extent",
"(",
"self",
")",
":",
"# type: () -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
"if",
"self",
".",
"dr_entries",
"... | Get the extent of the parent of this entry if it has one.
Parameters:
None.
Returns:
The logical block number of the parent if it exists. | [
"Get",
"the",
"extent",
"of",
"the",
"parent",
"of",
"this",
"entry",
"if",
"it",
"has",
"one",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L2991-L3009 |
21,660 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidge.update_ce_block | def update_ce_block(self, block):
# type: (RockRidgeContinuationBlock) -> None
'''
Update the Continuation Entry block object used by this Rock Ridge Record.
Parameters:
block - The new block object.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
self.ce_block = block | python | def update_ce_block(self, block):
# type: (RockRidgeContinuationBlock) -> None
'''
Update the Continuation Entry block object used by this Rock Ridge Record.
Parameters:
block - The new block object.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Rock Ridge extension not yet initialized')
self.ce_block = block | [
"def",
"update_ce_block",
"(",
"self",
",",
"block",
")",
":",
"# type: (RockRidgeContinuationBlock) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Rock Ridge extension not yet initialized'",
")",
... | Update the Continuation Entry block object used by this Rock Ridge Record.
Parameters:
block - The new block object.
Returns:
Nothing. | [
"Update",
"the",
"Continuation",
"Entry",
"block",
"object",
"used",
"by",
"this",
"Rock",
"Ridge",
"Record",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L3027-L3040 |
21,661 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidgeContinuationBlock.track_entry | def track_entry(self, offset, length):
# type: (int, int) -> None
'''
Track an already allocated entry in this Rock Ridge Continuation Block.
Parameters:
offset - The offset at which to place the entry.
length - The length of the entry to track.
Returns:
Nothing.
'''
newlen = offset + length - 1
for entry in self._entries:
thislen = entry.offset + entry.length - 1
overlap = range(max(entry.offset, offset), min(thislen, newlen) + 1)
if overlap:
raise pycdlibexception.PyCdlibInvalidISO('Overlapping CE regions on the ISO')
# OK, there were no overlaps with existing entries. Let's see if
# the new entry fits at the end.
if offset + length > self._max_block_size:
raise pycdlibexception.PyCdlibInvalidISO('No room in continuation block to track entry')
# We passed all of the checks; add the new entry to track in.
bisect.insort_left(self._entries, RockRidgeContinuationEntry(offset, length)) | python | def track_entry(self, offset, length):
# type: (int, int) -> None
'''
Track an already allocated entry in this Rock Ridge Continuation Block.
Parameters:
offset - The offset at which to place the entry.
length - The length of the entry to track.
Returns:
Nothing.
'''
newlen = offset + length - 1
for entry in self._entries:
thislen = entry.offset + entry.length - 1
overlap = range(max(entry.offset, offset), min(thislen, newlen) + 1)
if overlap:
raise pycdlibexception.PyCdlibInvalidISO('Overlapping CE regions on the ISO')
# OK, there were no overlaps with existing entries. Let's see if
# the new entry fits at the end.
if offset + length > self._max_block_size:
raise pycdlibexception.PyCdlibInvalidISO('No room in continuation block to track entry')
# We passed all of the checks; add the new entry to track in.
bisect.insort_left(self._entries, RockRidgeContinuationEntry(offset, length)) | [
"def",
"track_entry",
"(",
"self",
",",
"offset",
",",
"length",
")",
":",
"# type: (int, int) -> None",
"newlen",
"=",
"offset",
"+",
"length",
"-",
"1",
"for",
"entry",
"in",
"self",
".",
"_entries",
":",
"thislen",
"=",
"entry",
".",
"offset",
"+",
"e... | Track an already allocated entry in this Rock Ridge Continuation Block.
Parameters:
offset - The offset at which to place the entry.
length - The length of the entry to track.
Returns:
Nothing. | [
"Track",
"an",
"already",
"allocated",
"entry",
"in",
"this",
"Rock",
"Ridge",
"Continuation",
"Block",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L3125-L3149 |
21,662 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidgeContinuationBlock.add_entry | def add_entry(self, length):
# type: (int) -> int
'''
Add a new entry to this Rock Ridge Continuation Block. This method
attempts to find a gap that fits the new length anywhere within this
Continuation Block. If successful, it returns the offset at which
it placed this entry. If unsuccessful, it returns None.
Parameters:
length - The length of the entry to find a gap for.
Returns:
The offset the entry was placed at, or None if no gap was found.
'''
offset = -1
# Need to find a gap
for index, entry in enumerate(self._entries):
if index == 0:
if entry.offset != 0 and length <= entry.offset:
# We can put it at the beginning!
offset = 0
break
else:
lastentry = self._entries[index - 1]
lastend = lastentry.offset + lastentry.length - 1
gapsize = entry.offset - lastend - 1
if gapsize >= length:
# We found a spot for it!
offset = lastend + 1
break
else:
# We reached the end without finding a gap for it. Look at the last
# entry and see if there is room at the end.
if self._entries:
lastentry = self._entries[-1]
lastend = lastentry.offset + lastentry.length - 1
left = self._max_block_size - lastend - 1
if left >= length:
offset = lastend + 1
else:
if self._max_block_size >= length:
offset = 0
if offset >= 0:
bisect.insort_left(self._entries,
RockRidgeContinuationEntry(offset, length))
return offset | python | def add_entry(self, length):
# type: (int) -> int
'''
Add a new entry to this Rock Ridge Continuation Block. This method
attempts to find a gap that fits the new length anywhere within this
Continuation Block. If successful, it returns the offset at which
it placed this entry. If unsuccessful, it returns None.
Parameters:
length - The length of the entry to find a gap for.
Returns:
The offset the entry was placed at, or None if no gap was found.
'''
offset = -1
# Need to find a gap
for index, entry in enumerate(self._entries):
if index == 0:
if entry.offset != 0 and length <= entry.offset:
# We can put it at the beginning!
offset = 0
break
else:
lastentry = self._entries[index - 1]
lastend = lastentry.offset + lastentry.length - 1
gapsize = entry.offset - lastend - 1
if gapsize >= length:
# We found a spot for it!
offset = lastend + 1
break
else:
# We reached the end without finding a gap for it. Look at the last
# entry and see if there is room at the end.
if self._entries:
lastentry = self._entries[-1]
lastend = lastentry.offset + lastentry.length - 1
left = self._max_block_size - lastend - 1
if left >= length:
offset = lastend + 1
else:
if self._max_block_size >= length:
offset = 0
if offset >= 0:
bisect.insort_left(self._entries,
RockRidgeContinuationEntry(offset, length))
return offset | [
"def",
"add_entry",
"(",
"self",
",",
"length",
")",
":",
"# type: (int) -> int",
"offset",
"=",
"-",
"1",
"# Need to find a gap",
"for",
"index",
",",
"entry",
"in",
"enumerate",
"(",
"self",
".",
"_entries",
")",
":",
"if",
"index",
"==",
"0",
":",
"if... | Add a new entry to this Rock Ridge Continuation Block. This method
attempts to find a gap that fits the new length anywhere within this
Continuation Block. If successful, it returns the offset at which
it placed this entry. If unsuccessful, it returns None.
Parameters:
length - The length of the entry to find a gap for.
Returns:
The offset the entry was placed at, or None if no gap was found. | [
"Add",
"a",
"new",
"entry",
"to",
"this",
"Rock",
"Ridge",
"Continuation",
"Block",
".",
"This",
"method",
"attempts",
"to",
"find",
"a",
"gap",
"that",
"fits",
"the",
"new",
"length",
"anywhere",
"within",
"this",
"Continuation",
"Block",
".",
"If",
"succ... | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L3151-L3197 |
21,663 | clalancette/pycdlib | pycdlib/rockridge.py | RockRidgeContinuationBlock.remove_entry | def remove_entry(self, offset, length):
# type: (int, int) -> None
'''
Given an offset and length, find and remove the entry in this block
that corresponds.
Parameters:
offset - The offset of the entry to look for.
length - The length of the entry to look for.
Returns:
Nothing.
'''
for index, entry in enumerate(self._entries):
if entry.offset == offset and entry.length == length:
del self._entries[index]
break
else:
raise pycdlibexception.PyCdlibInternalError('Could not find an entry for the RR CE entry in the CE block!') | python | def remove_entry(self, offset, length):
# type: (int, int) -> None
'''
Given an offset and length, find and remove the entry in this block
that corresponds.
Parameters:
offset - The offset of the entry to look for.
length - The length of the entry to look for.
Returns:
Nothing.
'''
for index, entry in enumerate(self._entries):
if entry.offset == offset and entry.length == length:
del self._entries[index]
break
else:
raise pycdlibexception.PyCdlibInternalError('Could not find an entry for the RR CE entry in the CE block!') | [
"def",
"remove_entry",
"(",
"self",
",",
"offset",
",",
"length",
")",
":",
"# type: (int, int) -> None",
"for",
"index",
",",
"entry",
"in",
"enumerate",
"(",
"self",
".",
"_entries",
")",
":",
"if",
"entry",
".",
"offset",
"==",
"offset",
"and",
"entry",... | Given an offset and length, find and remove the entry in this block
that corresponds.
Parameters:
offset - The offset of the entry to look for.
length - The length of the entry to look for.
Returns:
Nothing. | [
"Given",
"an",
"offset",
"and",
"length",
"find",
"and",
"remove",
"the",
"entry",
"in",
"this",
"block",
"that",
"corresponds",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L3199-L3216 |
21,664 | clalancette/pycdlib | pycdlib/udf.py | crc_ccitt | def crc_ccitt(data):
# type: (bytes) -> int
'''
Calculate the CRC over a range of bytes using the CCITT polynomial.
Parameters:
data - The array of bytes to calculate the CRC over.
Returns:
The CCITT CRC of the data.
'''
crc = 0
if not have_py_3:
for x in data:
crc = crc_ccitt_table[ord(x) ^ ((crc >> 8) & 0xFF)] ^ ((crc << 8) & 0xFF00) # type: ignore
else:
mv = memoryview(data)
for x in mv.tobytes():
crc = crc_ccitt_table[x ^ ((crc >> 8) & 0xFF)] ^ ((crc << 8) & 0xFF00)
return crc | python | def crc_ccitt(data):
# type: (bytes) -> int
'''
Calculate the CRC over a range of bytes using the CCITT polynomial.
Parameters:
data - The array of bytes to calculate the CRC over.
Returns:
The CCITT CRC of the data.
'''
crc = 0
if not have_py_3:
for x in data:
crc = crc_ccitt_table[ord(x) ^ ((crc >> 8) & 0xFF)] ^ ((crc << 8) & 0xFF00) # type: ignore
else:
mv = memoryview(data)
for x in mv.tobytes():
crc = crc_ccitt_table[x ^ ((crc >> 8) & 0xFF)] ^ ((crc << 8) & 0xFF00)
return crc | [
"def",
"crc_ccitt",
"(",
"data",
")",
":",
"# type: (bytes) -> int",
"crc",
"=",
"0",
"if",
"not",
"have_py_3",
":",
"for",
"x",
"in",
"data",
":",
"crc",
"=",
"crc_ccitt_table",
"[",
"ord",
"(",
"x",
")",
"^",
"(",
"(",
"crc",
">>",
"8",
")",
"&",... | Calculate the CRC over a range of bytes using the CCITT polynomial.
Parameters:
data - The array of bytes to calculate the CRC over.
Returns:
The CCITT CRC of the data. | [
"Calculate",
"the",
"CRC",
"over",
"a",
"range",
"of",
"bytes",
"using",
"the",
"CCITT",
"polynomial",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L93-L112 |
21,665 | clalancette/pycdlib | pycdlib/udf.py | _ostaunicode | def _ostaunicode(src):
# type: (str) -> bytes
'''
Internal function to create an OSTA byte string from a source string.
'''
if have_py_3:
bytename = src
else:
bytename = src.decode('utf-8') # type: ignore
try:
enc = bytename.encode('latin-1')
encbyte = b'\x08'
except (UnicodeEncodeError, UnicodeDecodeError):
enc = bytename.encode('utf-16_be')
encbyte = b'\x10'
return encbyte + enc | python | def _ostaunicode(src):
# type: (str) -> bytes
'''
Internal function to create an OSTA byte string from a source string.
'''
if have_py_3:
bytename = src
else:
bytename = src.decode('utf-8') # type: ignore
try:
enc = bytename.encode('latin-1')
encbyte = b'\x08'
except (UnicodeEncodeError, UnicodeDecodeError):
enc = bytename.encode('utf-16_be')
encbyte = b'\x10'
return encbyte + enc | [
"def",
"_ostaunicode",
"(",
"src",
")",
":",
"# type: (str) -> bytes",
"if",
"have_py_3",
":",
"bytename",
"=",
"src",
"else",
":",
"bytename",
"=",
"src",
".",
"decode",
"(",
"'utf-8'",
")",
"# type: ignore",
"try",
":",
"enc",
"=",
"bytename",
".",
"enco... | Internal function to create an OSTA byte string from a source string. | [
"Internal",
"function",
"to",
"create",
"an",
"OSTA",
"byte",
"string",
"from",
"a",
"source",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L115-L131 |
21,666 | clalancette/pycdlib | pycdlib/udf.py | _ostaunicode_zero_pad | def _ostaunicode_zero_pad(src, fulllen):
# type: (str, int) -> bytes
'''
Internal function to create a zero-padded Identifier byte string from a
source string.
Parameters:
src - The src string to start from.
fulllen - The padded out length of the result.
Returns:
A full identifier byte string containing the source string.
'''
byte_src = _ostaunicode(src)
return byte_src + b'\x00' * (fulllen - 1 - len(byte_src)) + (struct.pack('=B', len(byte_src))) | python | def _ostaunicode_zero_pad(src, fulllen):
# type: (str, int) -> bytes
'''
Internal function to create a zero-padded Identifier byte string from a
source string.
Parameters:
src - The src string to start from.
fulllen - The padded out length of the result.
Returns:
A full identifier byte string containing the source string.
'''
byte_src = _ostaunicode(src)
return byte_src + b'\x00' * (fulllen - 1 - len(byte_src)) + (struct.pack('=B', len(byte_src))) | [
"def",
"_ostaunicode_zero_pad",
"(",
"src",
",",
"fulllen",
")",
":",
"# type: (str, int) -> bytes",
"byte_src",
"=",
"_ostaunicode",
"(",
"src",
")",
"return",
"byte_src",
"+",
"b'\\x00'",
"*",
"(",
"fulllen",
"-",
"1",
"-",
"len",
"(",
"byte_src",
")",
")"... | Internal function to create a zero-padded Identifier byte string from a
source string.
Parameters:
src - The src string to start from.
fulllen - The padded out length of the result.
Returns:
A full identifier byte string containing the source string. | [
"Internal",
"function",
"to",
"create",
"a",
"zero",
"-",
"padded",
"Identifier",
"byte",
"string",
"from",
"a",
"source",
"string",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L134-L147 |
21,667 | clalancette/pycdlib | pycdlib/udf.py | _compute_csum | def _compute_csum(data):
# type: (bytes) -> int
'''
A method to compute a simple checksum over the given data.
Parameters:
data - The data to compute the checksum over.
Returns:
The checksum.
'''
def identity(x):
# type: (int) -> int
'''
The identity function so we can use a function for python2/3
compatibility.
'''
return x
if isinstance(data, str):
myord = ord
elif isinstance(data, bytes):
myord = identity
elif isinstance(data, bytearray):
myord = identity
csum = 0
for byte in data:
csum += myord(byte)
csum -= myord(data[4])
csum %= 256
return csum | python | def _compute_csum(data):
# type: (bytes) -> int
'''
A method to compute a simple checksum over the given data.
Parameters:
data - The data to compute the checksum over.
Returns:
The checksum.
'''
def identity(x):
# type: (int) -> int
'''
The identity function so we can use a function for python2/3
compatibility.
'''
return x
if isinstance(data, str):
myord = ord
elif isinstance(data, bytes):
myord = identity
elif isinstance(data, bytearray):
myord = identity
csum = 0
for byte in data:
csum += myord(byte)
csum -= myord(data[4])
csum %= 256
return csum | [
"def",
"_compute_csum",
"(",
"data",
")",
":",
"# type: (bytes) -> int",
"def",
"identity",
"(",
"x",
")",
":",
"# type: (int) -> int",
"'''\n The identity function so we can use a function for python2/3\n compatibility.\n '''",
"return",
"x",
"if",
"isinstan... | A method to compute a simple checksum over the given data.
Parameters:
data - The data to compute the checksum over.
Returns:
The checksum. | [
"A",
"method",
"to",
"compute",
"a",
"simple",
"checksum",
"over",
"the",
"given",
"data",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L486-L516 |
21,668 | clalancette/pycdlib | pycdlib/udf.py | symlink_to_bytes | def symlink_to_bytes(symlink_target):
# type: (str) -> bytes
'''
A function to generate UDF symlink data from a Unix-like path.
Parameters:
symlink_target - The Unix-like path that is the symlink.
Returns:
The UDF data corresponding to the symlink.
'''
symlink_data = bytearray()
for comp in symlink_target.split('/'):
if comp == '':
# If comp is empty, then we know this is the leading slash
# and we should make an absolute entry (double slashes and
# such are weeded out by the earlier utils.normpath).
symlink_data.extend(b'\x02\x00\x00\x00')
elif comp == '.':
symlink_data.extend(b'\x04\x00\x00\x00')
elif comp == '..':
symlink_data.extend(b'\x03\x00\x00\x00')
else:
symlink_data.extend(b'\x05')
ostaname = _ostaunicode(comp)
symlink_data.append(len(ostaname))
symlink_data.extend(b'\x00\x00')
symlink_data.extend(ostaname)
return symlink_data | python | def symlink_to_bytes(symlink_target):
# type: (str) -> bytes
'''
A function to generate UDF symlink data from a Unix-like path.
Parameters:
symlink_target - The Unix-like path that is the symlink.
Returns:
The UDF data corresponding to the symlink.
'''
symlink_data = bytearray()
for comp in symlink_target.split('/'):
if comp == '':
# If comp is empty, then we know this is the leading slash
# and we should make an absolute entry (double slashes and
# such are weeded out by the earlier utils.normpath).
symlink_data.extend(b'\x02\x00\x00\x00')
elif comp == '.':
symlink_data.extend(b'\x04\x00\x00\x00')
elif comp == '..':
symlink_data.extend(b'\x03\x00\x00\x00')
else:
symlink_data.extend(b'\x05')
ostaname = _ostaunicode(comp)
symlink_data.append(len(ostaname))
symlink_data.extend(b'\x00\x00')
symlink_data.extend(ostaname)
return symlink_data | [
"def",
"symlink_to_bytes",
"(",
"symlink_target",
")",
":",
"# type: (str) -> bytes",
"symlink_data",
"=",
"bytearray",
"(",
")",
"for",
"comp",
"in",
"symlink_target",
".",
"split",
"(",
"'/'",
")",
":",
"if",
"comp",
"==",
"''",
":",
"# If comp is empty, then ... | A function to generate UDF symlink data from a Unix-like path.
Parameters:
symlink_target - The Unix-like path that is the symlink.
Returns:
The UDF data corresponding to the symlink. | [
"A",
"function",
"to",
"generate",
"UDF",
"symlink",
"data",
"from",
"a",
"Unix",
"-",
"like",
"path",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3554-L3582 |
21,669 | clalancette/pycdlib | pycdlib/udf.py | BEAVolumeStructure.set_extent_location | def set_extent_location(self, extent):
# type: (int) -> None
'''
A method to set the new location for this UDF BEA Volume Structure.
Parameters:
extent - The new extent location to set for this UDF BEA Volume Structure.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
self.new_extent_loc = extent | python | def set_extent_location(self, extent):
# type: (int) -> None
'''
A method to set the new location for this UDF BEA Volume Structure.
Parameters:
extent - The new extent location to set for this UDF BEA Volume Structure.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
self.new_extent_loc = extent | [
"def",
"set_extent_location",
"(",
"self",
",",
"extent",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"self",
"."... | A method to set the new location for this UDF BEA Volume Structure.
Parameters:
extent - The new extent location to set for this UDF BEA Volume Structure.
Returns:
Nothing. | [
"A",
"method",
"to",
"set",
"the",
"new",
"location",
"for",
"this",
"UDF",
"BEA",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L253-L265 |
21,670 | clalancette/pycdlib | pycdlib/udf.py | NSRVolumeStructure.parse | def parse(self, data, extent):
# type: (bytes, int) -> None
'''
Parse the passed in data into a UDF NSR Volume Structure.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure already initialized')
(structure_type, self.standard_ident, structure_version,
reserved_unused) = struct.unpack_from(self.FMT, data, 0)
if structure_type != 0:
raise pycdlibexception.PyCdlibInvalidISO('Invalid structure type')
if self.standard_ident not in [b'NSR02', b'NSR03']:
raise pycdlibexception.PyCdlibInvalidISO('Invalid standard identifier')
if structure_version != 1:
raise pycdlibexception.PyCdlibInvalidISO('Invalid structure version')
self.orig_extent_loc = extent
self._initialized = True | python | def parse(self, data, extent):
# type: (bytes, int) -> None
'''
Parse the passed in data into a UDF NSR Volume Structure.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure already initialized')
(structure_type, self.standard_ident, structure_version,
reserved_unused) = struct.unpack_from(self.FMT, data, 0)
if structure_type != 0:
raise pycdlibexception.PyCdlibInvalidISO('Invalid structure type')
if self.standard_ident not in [b'NSR02', b'NSR03']:
raise pycdlibexception.PyCdlibInvalidISO('Invalid standard identifier')
if structure_version != 1:
raise pycdlibexception.PyCdlibInvalidISO('Invalid structure version')
self.orig_extent_loc = extent
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
")",
":",
"# type: (bytes, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF NSR Volume Structure already initialized'",
")",
"(",
"struc... | Parse the passed in data into a UDF NSR Volume Structure.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"NSR",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L282-L310 |
21,671 | clalancette/pycdlib | pycdlib/udf.py | NSRVolumeStructure.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF NSR Volume
Structure.
Parameters:
None.
Returns:
A string representing this UDF BEA Volume Strucutre.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure not initialized')
return struct.pack(self.FMT, 0, self.standard_ident, 1, b'\x00' * 2041) | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF NSR Volume
Structure.
Parameters:
None.
Returns:
A string representing this UDF BEA Volume Strucutre.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure not initialized')
return struct.pack(self.FMT, 0, self.standard_ident, 1, b'\x00' * 2041) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF NSR Volume Structure not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"sel... | A method to generate the string representing this UDF NSR Volume
Structure.
Parameters:
None.
Returns:
A string representing this UDF BEA Volume Strucutre. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"NSR",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L312-L325 |
21,672 | clalancette/pycdlib | pycdlib/udf.py | NSRVolumeStructure.new | def new(self, version):
# type: () -> None
'''
A method to create a new UDF NSR Volume Structure.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure already initialized')
if version == 2:
self.standard_ident = b'NSR02'
elif version == 3:
self.standard_ident = b'NSR03'
else:
raise pycdlibexception.PyCdlibInternalError('Invalid NSR version requested')
self._initialized = True | python | def new(self, version):
# type: () -> None
'''
A method to create a new UDF NSR Volume Structure.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure already initialized')
if version == 2:
self.standard_ident = b'NSR02'
elif version == 3:
self.standard_ident = b'NSR03'
else:
raise pycdlibexception.PyCdlibInternalError('Invalid NSR version requested')
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"version",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF NSR Volume Structure already initialized'",
")",
"if",
"version",
"==",
"2",
":",
... | A method to create a new UDF NSR Volume Structure.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"NSR",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L327-L347 |
21,673 | clalancette/pycdlib | pycdlib/udf.py | NSRVolumeStructure.extent_location | def extent_location(self):
# type: () -> int
'''
A method to get the extent location of this UDF NSR Volume Structure.
Parameters:
None.
Returns:
Integer extent location of this UDF NSR Volume Structure.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure not yet initialized')
if self.new_extent_loc < 0:
return self.orig_extent_loc
return self.new_extent_loc | python | def extent_location(self):
# type: () -> int
'''
A method to get the extent location of this UDF NSR Volume Structure.
Parameters:
None.
Returns:
Integer extent location of this UDF NSR Volume Structure.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF NSR Volume Structure not yet initialized')
if self.new_extent_loc < 0:
return self.orig_extent_loc
return self.new_extent_loc | [
"def",
"extent_location",
"(",
"self",
")",
":",
"# type: () -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF NSR Volume Structure not yet initialized'",
")",
"if",
"self",
".",
"new_extent_loc"... | A method to get the extent location of this UDF NSR Volume Structure.
Parameters:
None.
Returns:
Integer extent location of this UDF NSR Volume Structure. | [
"A",
"method",
"to",
"get",
"the",
"extent",
"location",
"of",
"this",
"UDF",
"NSR",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L349-L364 |
21,674 | clalancette/pycdlib | pycdlib/udf.py | UDFTag.parse | def parse(self, data, extent):
# type: (bytes, int) -> None
'''
Parse the passed in data into a UDF Descriptor tag.
Parameters:
data - The data to parse.
extent - The extent to compare against for the tag location.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Tag already initialized')
(self.tag_ident, self.desc_version, tag_checksum, reserved,
self.tag_serial_number, desc_crc, self.desc_crc_length,
self.tag_location) = struct.unpack_from(self.FMT, data, 0)
if reserved != 0:
raise pycdlibexception.PyCdlibInvalidISO('Reserved data not 0!')
if _compute_csum(data[:16]) != tag_checksum:
raise pycdlibexception.PyCdlibInvalidISO('Tag checksum does not match!')
if self.tag_location != extent:
# In theory, we should abort (throw an exception) if we see that a
# tag location that doesn't match an actual location. However, we
# have seen UDF ISOs in the wild (most notably PS2 GT4 ISOs) that
# have an invalid tag location for the second anchor and File Set
# Terminator. So that we can support those ISOs, just silently
# fix it up. We lose a little bit of detection of whether this is
# "truly" a UDFTag, but it is really not a big risk.
self.tag_location = extent
if self.desc_version not in (2, 3):
raise pycdlibexception.PyCdlibInvalidISO('Tag version not 2 or 3')
if (len(data) - 16) < self.desc_crc_length:
raise pycdlibexception.PyCdlibInternalError('Not enough CRC bytes to compute (expected at least %d, got %d)' % (self.desc_crc_length, len(data) - 16))
if desc_crc != crc_ccitt(data[16:16 + self.desc_crc_length]):
raise pycdlibexception.PyCdlibInvalidISO('Tag CRC does not match!')
self._initialized = True | python | def parse(self, data, extent):
# type: (bytes, int) -> None
'''
Parse the passed in data into a UDF Descriptor tag.
Parameters:
data - The data to parse.
extent - The extent to compare against for the tag location.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Tag already initialized')
(self.tag_ident, self.desc_version, tag_checksum, reserved,
self.tag_serial_number, desc_crc, self.desc_crc_length,
self.tag_location) = struct.unpack_from(self.FMT, data, 0)
if reserved != 0:
raise pycdlibexception.PyCdlibInvalidISO('Reserved data not 0!')
if _compute_csum(data[:16]) != tag_checksum:
raise pycdlibexception.PyCdlibInvalidISO('Tag checksum does not match!')
if self.tag_location != extent:
# In theory, we should abort (throw an exception) if we see that a
# tag location that doesn't match an actual location. However, we
# have seen UDF ISOs in the wild (most notably PS2 GT4 ISOs) that
# have an invalid tag location for the second anchor and File Set
# Terminator. So that we can support those ISOs, just silently
# fix it up. We lose a little bit of detection of whether this is
# "truly" a UDFTag, but it is really not a big risk.
self.tag_location = extent
if self.desc_version not in (2, 3):
raise pycdlibexception.PyCdlibInvalidISO('Tag version not 2 or 3')
if (len(data) - 16) < self.desc_crc_length:
raise pycdlibexception.PyCdlibInternalError('Not enough CRC bytes to compute (expected at least %d, got %d)' % (self.desc_crc_length, len(data) - 16))
if desc_crc != crc_ccitt(data[16:16 + self.desc_crc_length]):
raise pycdlibexception.PyCdlibInvalidISO('Tag CRC does not match!')
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
")",
":",
"# type: (bytes, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Tag already initialized'",
")",
"(",
"self",
".",
"tag_i... | Parse the passed in data into a UDF Descriptor tag.
Parameters:
data - The data to parse.
extent - The extent to compare against for the tag location.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Descriptor",
"tag",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L533-L576 |
21,675 | clalancette/pycdlib | pycdlib/udf.py | UDFTag.record | def record(self, crc_bytes):
# type: (bytes) -> bytes
'''
A method to generate the string representing this UDF Descriptor Tag.
Parameters:
crc_bytes - The string to compute the CRC over.
Returns:
A string representing this UDF Descriptor Tag.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Descriptor Tag not initialized')
crc_byte_len = len(crc_bytes)
if self.desc_crc_length >= 0:
crc_byte_len = self.desc_crc_length
# We need to compute the checksum, but we'll do that by first creating
# the output buffer with the csum field set to 0, computing the csum,
# and then setting that record back as usual.
rec = bytearray(struct.pack(self.FMT, self.tag_ident, self.desc_version,
0, 0, self.tag_serial_number,
crc_ccitt(crc_bytes[:crc_byte_len]),
crc_byte_len, self.tag_location))
rec[4] = _compute_csum(rec)
return bytes(rec) | python | def record(self, crc_bytes):
# type: (bytes) -> bytes
'''
A method to generate the string representing this UDF Descriptor Tag.
Parameters:
crc_bytes - The string to compute the CRC over.
Returns:
A string representing this UDF Descriptor Tag.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Descriptor Tag not initialized')
crc_byte_len = len(crc_bytes)
if self.desc_crc_length >= 0:
crc_byte_len = self.desc_crc_length
# We need to compute the checksum, but we'll do that by first creating
# the output buffer with the csum field set to 0, computing the csum,
# and then setting that record back as usual.
rec = bytearray(struct.pack(self.FMT, self.tag_ident, self.desc_version,
0, 0, self.tag_serial_number,
crc_ccitt(crc_bytes[:crc_byte_len]),
crc_byte_len, self.tag_location))
rec[4] = _compute_csum(rec)
return bytes(rec) | [
"def",
"record",
"(",
"self",
",",
"crc_bytes",
")",
":",
"# type: (bytes) -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Descriptor Tag not initialized'",
")",
"crc_byte_len",
"=",
"len",... | A method to generate the string representing this UDF Descriptor Tag.
Parameters:
crc_bytes - The string to compute the CRC over.
Returns:
A string representing this UDF Descriptor Tag. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Descriptor",
"Tag",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L578-L605 |
21,676 | clalancette/pycdlib | pycdlib/udf.py | UDFTag.new | def new(self, tag_ident, tag_serial=0):
# type: (int, int) -> None
'''
A method to create a new UDF Descriptor Tag.
Parameters:
tag_ident - The tag identifier number for this tag.
tag_serial - The tag serial number for this tag.
Returns:
Nothing
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Tag already initialized')
self.tag_ident = tag_ident
self.desc_version = 2
self.tag_serial_number = tag_serial
self.tag_location = 0 # This will be set later.
self._initialized = True | python | def new(self, tag_ident, tag_serial=0):
# type: (int, int) -> None
'''
A method to create a new UDF Descriptor Tag.
Parameters:
tag_ident - The tag identifier number for this tag.
tag_serial - The tag serial number for this tag.
Returns:
Nothing
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Tag already initialized')
self.tag_ident = tag_ident
self.desc_version = 2
self.tag_serial_number = tag_serial
self.tag_location = 0 # This will be set later.
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"tag_ident",
",",
"tag_serial",
"=",
"0",
")",
":",
"# type: (int, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Tag already initialized'",
")",
"self",
"... | A method to create a new UDF Descriptor Tag.
Parameters:
tag_ident - The tag identifier number for this tag.
tag_serial - The tag serial number for this tag.
Returns:
Nothing | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Descriptor",
"Tag",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L607-L626 |
21,677 | clalancette/pycdlib | pycdlib/udf.py | UDFAnchorVolumeStructure.parse | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Anchor Volume Structure.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('Anchor Volume Structure already initialized')
(tag_unused, self.main_vd_length, self.main_vd_extent,
self.reserve_vd_length,
self.reserve_vd_extent) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.orig_extent_loc = extent
self._initialized = True | python | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Anchor Volume Structure.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('Anchor Volume Structure already initialized')
(tag_unused, self.main_vd_length, self.main_vd_extent,
self.reserve_vd_length,
self.reserve_vd_extent) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.orig_extent_loc = extent
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Anchor Volume Structure already initializ... | Parse the passed in data into a UDF Anchor Volume Structure.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Anchor",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L644-L667 |
21,678 | clalancette/pycdlib | pycdlib/udf.py | UDFAnchorVolumeStructure.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Anchor Volume
Structure.
Parameters:
None.
Returns:
A string representing this UDF Anchor Volume Structure.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16, self.main_vd_length,
self.main_vd_extent, self.reserve_vd_length,
self.reserve_vd_extent)[16:] + b'\x00' * 480
return self.desc_tag.record(rec) + rec | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Anchor Volume
Structure.
Parameters:
None.
Returns:
A string representing this UDF Anchor Volume Structure.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16, self.main_vd_length,
self.main_vd_extent, self.reserve_vd_length,
self.reserve_vd_extent)[16:] + b'\x00' * 480
return self.desc_tag.record(rec) + rec | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Anchor Volume Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"("... | A method to generate the string representing this UDF Anchor Volume
Structure.
Parameters:
None.
Returns:
A string representing this UDF Anchor Volume Structure. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Anchor",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L669-L687 |
21,679 | clalancette/pycdlib | pycdlib/udf.py | UDFAnchorVolumeStructure.new | def new(self):
# type: () -> None
'''
A method to create a new UDF Anchor Volume Structure.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(2) # FIXME: we should let the user set serial_number
self.main_vd_length = 32768
self.main_vd_extent = 0 # This will get set later.
self.reserve_vd_length = 32768
self.reserve_vd_extent = 0 # This will get set later.
self._initialized = True | python | def new(self):
# type: () -> None
'''
A method to create a new UDF Anchor Volume Structure.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(2) # FIXME: we should let the user set serial_number
self.main_vd_length = 32768
self.main_vd_extent = 0 # This will get set later.
self.reserve_vd_length = 32768
self.reserve_vd_extent = 0 # This will get set later.
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Anchor Volume Structure already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
"... | A method to create a new UDF Anchor Volume Structure.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Anchor",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L706-L726 |
21,680 | clalancette/pycdlib | pycdlib/udf.py | UDFAnchorVolumeStructure.set_extent_location | def set_extent_location(self, new_location, main_vd_extent, reserve_vd_extent):
# type: (int, int, int) -> None
'''
A method to set a new location for this Anchor Volume Structure.
Parameters:
new_location - The new extent that this Anchor Volume Structure should be located at.
main_vd_extent - The extent containing the main Volume Descriptors.
reserve_vd_extent - The extent containing the reserve Volume Descriptors.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure not yet initialized')
self.new_extent_loc = new_location
self.desc_tag.tag_location = new_location
self.main_vd_extent = main_vd_extent
self.reserve_vd_extent = reserve_vd_extent | python | def set_extent_location(self, new_location, main_vd_extent, reserve_vd_extent):
# type: (int, int, int) -> None
'''
A method to set a new location for this Anchor Volume Structure.
Parameters:
new_location - The new extent that this Anchor Volume Structure should be located at.
main_vd_extent - The extent containing the main Volume Descriptors.
reserve_vd_extent - The extent containing the reserve Volume Descriptors.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Anchor Volume Structure not yet initialized')
self.new_extent_loc = new_location
self.desc_tag.tag_location = new_location
self.main_vd_extent = main_vd_extent
self.reserve_vd_extent = reserve_vd_extent | [
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
",",
"main_vd_extent",
",",
"reserve_vd_extent",
")",
":",
"# type: (int, int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
... | A method to set a new location for this Anchor Volume Structure.
Parameters:
new_location - The new extent that this Anchor Volume Structure should be located at.
main_vd_extent - The extent containing the main Volume Descriptors.
reserve_vd_extent - The extent containing the reserve Volume Descriptors.
Returns:
Nothing. | [
"A",
"method",
"to",
"set",
"a",
"new",
"location",
"for",
"this",
"Anchor",
"Volume",
"Structure",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L728-L746 |
21,681 | clalancette/pycdlib | pycdlib/udf.py | UDFTimestamp.parse | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Timestamp.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized')
(tz, timetype, self.year, self.month, self.day, self.hour, self.minute,
self.second, self.centiseconds, self.hundreds_microseconds,
self.microseconds) = struct.unpack_from(self.FMT, data, 0)
self.timetype = timetype >> 4
def twos_comp(val, bits):
# type: (int, int) -> int
'''
Compute the 2's complement of int value val
'''
if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255
val = val - (1 << bits) # compute negative value
return val # return positive value as is
self.tz = twos_comp(((timetype & 0xf) << 8) | tz, 12)
if self.tz < -1440 or self.tz > 1440:
if self.tz != -2047:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF timezone')
if self.year < 1 or self.year > 9999:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF year')
if self.month < 1 or self.month > 12:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF month')
if self.day < 1 or self.day > 31:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF day')
if self.hour < 0 or self.hour > 23:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF hour')
if self.minute < 0 or self.minute > 59:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF minute')
if self.second < 0 or self.second > 59:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF second')
self._initialized = True | python | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Timestamp.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized')
(tz, timetype, self.year, self.month, self.day, self.hour, self.minute,
self.second, self.centiseconds, self.hundreds_microseconds,
self.microseconds) = struct.unpack_from(self.FMT, data, 0)
self.timetype = timetype >> 4
def twos_comp(val, bits):
# type: (int, int) -> int
'''
Compute the 2's complement of int value val
'''
if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255
val = val - (1 << bits) # compute negative value
return val # return positive value as is
self.tz = twos_comp(((timetype & 0xf) << 8) | tz, 12)
if self.tz < -1440 or self.tz > 1440:
if self.tz != -2047:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF timezone')
if self.year < 1 or self.year > 9999:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF year')
if self.month < 1 or self.month > 12:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF month')
if self.day < 1 or self.day > 31:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF day')
if self.hour < 0 or self.hour > 23:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF hour')
if self.minute < 0 or self.minute > 59:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF minute')
if self.second < 0 or self.second > 59:
raise pycdlibexception.PyCdlibInvalidISO('Invalid UDF second')
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Timestamp already initialized'",
")",
"(",
"tz",
",",
"timetype",
",",
"self... | Parse the passed in data into a UDF Timestamp.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Timestamp",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L763-L808 |
21,682 | clalancette/pycdlib | pycdlib/udf.py | UDFTimestamp.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Timestamp.
Parameters:
None.
Returns:
A string representing this UDF Timestamp.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp not initialized')
tmp = ((1 << 16) - 1) & self.tz
newtz = tmp & 0xff
newtimetype = ((tmp >> 8) & 0x0f) | (self.timetype << 4)
return struct.pack(self.FMT, newtz, newtimetype, self.year, self.month,
self.day, self.hour, self.minute, self.second,
self.centiseconds, self.hundreds_microseconds,
self.microseconds) | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Timestamp.
Parameters:
None.
Returns:
A string representing this UDF Timestamp.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp not initialized')
tmp = ((1 << 16) - 1) & self.tz
newtz = tmp & 0xff
newtimetype = ((tmp >> 8) & 0x0f) | (self.timetype << 4)
return struct.pack(self.FMT, newtz, newtimetype, self.year, self.month,
self.day, self.hour, self.minute, self.second,
self.centiseconds, self.hundreds_microseconds,
self.microseconds) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Timestamp not initialized'",
")",
"tmp",
"=",
"(",
"(",
"1",
"<<",
"16",
")",
"-"... | A method to generate the string representing this UDF Timestamp.
Parameters:
None.
Returns:
A string representing this UDF Timestamp. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Timestamp",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L810-L830 |
21,683 | clalancette/pycdlib | pycdlib/udf.py | UDFTimestamp.new | def new(self):
# type: () -> None
'''
A method to create a new UDF Timestamp.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized')
tm = time.time()
local = time.localtime(tm)
self.tz = utils.gmtoffset_from_tm(tm, local)
# FIXME: for the timetype, 0 is UTC, 1 is local, 2 is 'agreement'.
# We should let the user set this.
self.timetype = 1
self.year = local.tm_year
self.month = local.tm_mon
self.day = local.tm_mon
self.hour = local.tm_hour
self.minute = local.tm_min
self.second = local.tm_sec
self.centiseconds = 0
self.hundreds_microseconds = 0
self.microseconds = 0
self._initialized = True | python | def new(self):
# type: () -> None
'''
A method to create a new UDF Timestamp.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized')
tm = time.time()
local = time.localtime(tm)
self.tz = utils.gmtoffset_from_tm(tm, local)
# FIXME: for the timetype, 0 is UTC, 1 is local, 2 is 'agreement'.
# We should let the user set this.
self.timetype = 1
self.year = local.tm_year
self.month = local.tm_mon
self.day = local.tm_mon
self.hour = local.tm_hour
self.minute = local.tm_min
self.second = local.tm_sec
self.centiseconds = 0
self.hundreds_microseconds = 0
self.microseconds = 0
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Timestamp already initialized'",
")",
"tm",
"=",
"time",
".",
"time",
"(",
")",
"local",
"=",
... | A method to create a new UDF Timestamp.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Timestamp",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L832-L862 |
21,684 | clalancette/pycdlib | pycdlib/udf.py | UDFEntityID.parse | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Entity ID.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Entity ID already initialized')
(self.flags, self.identifier, self.suffix) = struct.unpack_from(self.FMT, data, 0)
self._initialized = True | python | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Entity ID.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Entity ID already initialized')
(self.flags, self.identifier, self.suffix) = struct.unpack_from(self.FMT, data, 0)
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Entity ID already initialized'",
")",
"(",
"self",
".",
"flags",
",",
"self"... | Parse the passed in data into a UDF Entity ID.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Entity",
"ID",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L877-L892 |
21,685 | clalancette/pycdlib | pycdlib/udf.py | UDFEntityID.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Entity ID.
Parameters:
None.
Returns:
A string representing this UDF Entity ID.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Entity ID not initialized')
return struct.pack(self.FMT, self.flags, self.identifier, self.suffix) | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Entity ID.
Parameters:
None.
Returns:
A string representing this UDF Entity ID.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Entity ID not initialized')
return struct.pack(self.FMT, self.flags, self.identifier, self.suffix) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Entity ID not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
... | A method to generate the string representing this UDF Entity ID.
Parameters:
None.
Returns:
A string representing this UDF Entity ID. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Entity",
"ID",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L894-L907 |
21,686 | clalancette/pycdlib | pycdlib/udf.py | UDFEntityID.new | def new(self, flags=0, identifier=b'', suffix=b''):
# type: (int, bytes, bytes) -> None
'''
A method to create a new UDF Entity ID.
Parameters:
flags - The flags to set for this Entity ID.
identifier - The identifier to set for this Entity ID.
suffix - The suffix to set for this Entity ID.
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Entity ID already initialized')
if len(identifier) > 23:
raise pycdlibexception.PyCdlibInvalidInput('UDF Entity ID identifer must be less than 23 characters')
if len(suffix) > 8:
raise pycdlibexception.PyCdlibInvalidInput('UDF Entity ID suffix must be less than 8 characters')
self.flags = flags
self.identifier = identifier + b'\x00' * (23 - len(identifier))
self.suffix = suffix + b'\x00' * (8 - len(suffix))
self._initialized = True | python | def new(self, flags=0, identifier=b'', suffix=b''):
# type: (int, bytes, bytes) -> None
'''
A method to create a new UDF Entity ID.
Parameters:
flags - The flags to set for this Entity ID.
identifier - The identifier to set for this Entity ID.
suffix - The suffix to set for this Entity ID.
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Entity ID already initialized')
if len(identifier) > 23:
raise pycdlibexception.PyCdlibInvalidInput('UDF Entity ID identifer must be less than 23 characters')
if len(suffix) > 8:
raise pycdlibexception.PyCdlibInvalidInput('UDF Entity ID suffix must be less than 8 characters')
self.flags = flags
self.identifier = identifier + b'\x00' * (23 - len(identifier))
self.suffix = suffix + b'\x00' * (8 - len(suffix))
self._initialized = True | [
"def",
"new",
"(",
"self",
",",
"flags",
"=",
"0",
",",
"identifier",
"=",
"b''",
",",
"suffix",
"=",
"b''",
")",
":",
"# type: (int, bytes, bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",... | A method to create a new UDF Entity ID.
Parameters:
flags - The flags to set for this Entity ID.
identifier - The identifier to set for this Entity ID.
suffix - The suffix to set for this Entity ID.
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Entity",
"ID",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L909-L935 |
21,687 | clalancette/pycdlib | pycdlib/udf.py | UDFPrimaryVolumeDescriptor.parse | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Primary Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, self.desc_num, self.vol_ident,
vol_seqnum, max_vol_seqnum, interchange_level,
self.max_interchange_level, char_set_list,
max_char_set_list, self.vol_set_ident, self.desc_char_set,
self.explanatory_char_set, self.vol_abstract_length, self.vol_abstract_extent,
self.vol_copyright_length, self.vol_copyright_extent, app_ident,
recording_date, impl_ident, self.implementation_use,
self.predecessor_vol_desc_location, flags,
reserved) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if interchange_level != 2:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if flags != 0:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if reserved != b'\x00' * 22:
raise pycdlibexception.PyCdlibInvalidISO('UDF Primary Volume Descriptor reserved data not 0')
self.recording_date = UDFTimestamp()
self.recording_date.parse(recording_date)
self.app_ident = UDFEntityID()
self.app_ident.parse(app_ident)
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self.orig_extent_loc = extent
self._initialized = True | python | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Primary Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, self.desc_num, self.vol_ident,
vol_seqnum, max_vol_seqnum, interchange_level,
self.max_interchange_level, char_set_list,
max_char_set_list, self.vol_set_ident, self.desc_char_set,
self.explanatory_char_set, self.vol_abstract_length, self.vol_abstract_extent,
self.vol_copyright_length, self.vol_copyright_extent, app_ident,
recording_date, impl_ident, self.implementation_use,
self.predecessor_vol_desc_location, flags,
reserved) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if interchange_level != 2:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if flags != 0:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if reserved != b'\x00' * 22:
raise pycdlibexception.PyCdlibInvalidISO('UDF Primary Volume Descriptor reserved data not 0')
self.recording_date = UDFTimestamp()
self.recording_date.parse(recording_date)
self.app_ident = UDFEntityID()
self.app_ident.parse(app_ident)
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self.orig_extent_loc = extent
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Primary Volume Descriptor already ini... | Parse the passed in data into a UDF Primary Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Primary",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L957-L1011 |
21,688 | clalancette/pycdlib | pycdlib/udf.py | UDFPrimaryVolumeDescriptor.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Primary Volume
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Primary Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.vol_desc_seqnum, self.desc_num,
self.vol_ident, 1, 1, 2, self.max_interchange_level, 1, 1,
self.vol_set_ident,
self.desc_char_set, self.explanatory_char_set,
self.vol_abstract_length, self.vol_abstract_extent,
self.vol_copyright_length, self.vol_copyright_extent,
self.app_ident.record(), self.recording_date.record(),
self.impl_ident.record(), self.implementation_use,
self.predecessor_vol_desc_location, 0, b'\x00' * 22)[16:]
return self.desc_tag.record(rec) + rec | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Primary Volume
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Primary Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.vol_desc_seqnum, self.desc_num,
self.vol_ident, 1, 1, 2, self.max_interchange_level, 1, 1,
self.vol_set_ident,
self.desc_char_set, self.explanatory_char_set,
self.vol_abstract_length, self.vol_abstract_extent,
self.vol_copyright_length, self.vol_copyright_extent,
self.app_ident.record(), self.recording_date.record(),
self.impl_ident.record(), self.implementation_use,
self.predecessor_vol_desc_location, 0, b'\x00' * 22)[16:]
return self.desc_tag.record(rec) + rec | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Primary Volume Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(... | A method to generate the string representing this UDF Primary Volume
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Primary Volume Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Primary",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1013-L1037 |
21,689 | clalancette/pycdlib | pycdlib/udf.py | UDFPrimaryVolumeDescriptor.new | def new(self):
# type: () -> None
'''
A method to create a new UDF Primary Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(1) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 0 # FIXME: we should let the user set this
self.desc_num = 0 # FIXME: we should let the user set this
self.vol_ident = _ostaunicode_zero_pad('CDROM', 32)
# According to UDF 2.60, 2.2.2.5, the VolumeSetIdentifier should have
# at least the first 16 characters be a unique value. Further, the
# first 8 bytes of that should be a time value in ASCII hexadecimal
# representation. To make it truly unique, we use that time plus a
# random value, all ASCII encoded.
unique = format(int(time.time()), '08x') + format(random.getrandbits(26), '08x')
self.vol_set_ident = _ostaunicode_zero_pad(unique, 128)
self.desc_char_set = _unicodecharset()
self.explanatory_char_set = _unicodecharset()
self.vol_abstract_length = 0 # FIXME: we should let the user set this
self.vol_abstract_extent = 0 # FIXME: we should let the user set this
self.vol_copyright_length = 0 # FIXME: we should let the user set this
self.vol_copyright_extent = 0 # FIXME: we should let the user set this
self.app_ident = UDFEntityID()
self.app_ident.new()
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.implementation_use = b'\x00' * 64 # FIXME: we should let the user set this
self.predecessor_vol_desc_location = 0 # FIXME: we should let the user set this
self.max_interchange_level = 2
self._initialized = True | python | def new(self):
# type: () -> None
'''
A method to create a new UDF Primary Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Primary Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(1) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 0 # FIXME: we should let the user set this
self.desc_num = 0 # FIXME: we should let the user set this
self.vol_ident = _ostaunicode_zero_pad('CDROM', 32)
# According to UDF 2.60, 2.2.2.5, the VolumeSetIdentifier should have
# at least the first 16 characters be a unique value. Further, the
# first 8 bytes of that should be a time value in ASCII hexadecimal
# representation. To make it truly unique, we use that time plus a
# random value, all ASCII encoded.
unique = format(int(time.time()), '08x') + format(random.getrandbits(26), '08x')
self.vol_set_ident = _ostaunicode_zero_pad(unique, 128)
self.desc_char_set = _unicodecharset()
self.explanatory_char_set = _unicodecharset()
self.vol_abstract_length = 0 # FIXME: we should let the user set this
self.vol_abstract_extent = 0 # FIXME: we should let the user set this
self.vol_copyright_length = 0 # FIXME: we should let the user set this
self.vol_copyright_extent = 0 # FIXME: we should let the user set this
self.app_ident = UDFEntityID()
self.app_ident.new()
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.implementation_use = b'\x00' * 64 # FIXME: we should let the user set this
self.predecessor_vol_desc_location = 0 # FIXME: we should let the user set this
self.max_interchange_level = 2
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Primary Volume Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
... | A method to create a new UDF Primary Volume Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Primary",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1056-L1098 |
21,690 | clalancette/pycdlib | pycdlib/udf.py | UDFImplementationUseVolumeDescriptorImplementationUse.parse | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Implementation Use Volume
Descriptor Implementation Use field.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field already initialized')
(self.char_set, self.log_vol_ident, self.lv_info1, self.lv_info2,
self.lv_info3, impl_ident,
self.impl_use) = struct.unpack_from(self.FMT, data, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self._initialized = True | python | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Implementation Use Volume
Descriptor Implementation Use field.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field already initialized')
(self.char_set, self.log_vol_ident, self.lv_info1, self.lv_info2,
self.lv_info3, impl_ident,
self.impl_use) = struct.unpack_from(self.FMT, data, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Implementation Use Volume Descriptor Implementation Use field already initialized'",
")"... | Parse the passed in data into a UDF Implementation Use Volume
Descriptor Implementation Use field.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Implementation",
"Use",
"Volume",
"Descriptor",
"Implementation",
"Use",
"field",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1130-L1151 |
21,691 | clalancette/pycdlib | pycdlib/udf.py | UDFImplementationUseVolumeDescriptorImplementationUse.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Implementation Use
Volume Descriptor Implementation Use field.
Parameters:
None.
Returns:
A string representing this UDF Implementation Use Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field not initialized')
return struct.pack(self.FMT, self.char_set, self.log_vol_ident,
self.lv_info1, self.lv_info2, self.lv_info3,
self.impl_ident.record(), self.impl_use) | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Implementation Use
Volume Descriptor Implementation Use field.
Parameters:
None.
Returns:
A string representing this UDF Implementation Use Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field not initialized')
return struct.pack(self.FMT, self.char_set, self.log_vol_ident,
self.lv_info1, self.lv_info2, self.lv_info3,
self.impl_ident.record(), self.impl_use) | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Implementation Use Volume Descriptor Implementation Use field not initialized'",
")",
"return",
... | A method to generate the string representing this UDF Implementation Use
Volume Descriptor Implementation Use field.
Parameters:
None.
Returns:
A string representing this UDF Implementation Use Volume Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Implementation",
"Use",
"Volume",
"Descriptor",
"Implementation",
"Use",
"field",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1153-L1169 |
21,692 | clalancette/pycdlib | pycdlib/udf.py | UDFImplementationUseVolumeDescriptorImplementationUse.new | def new(self):
# type: () -> None
'''
A method to create a new UDF Implementation Use Volume Descriptor Implementation Use field.
Parameters:
None:
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field already initialized')
self.char_set = _unicodecharset()
self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.lv_info1 = b'\x00' * 36
self.lv_info2 = b'\x00' * 36
self.lv_info3 = b'\x00' * 36
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib', b'')
self.impl_use = b'\x00' * 128
self._initialized = True | python | def new(self):
# type: () -> None
'''
A method to create a new UDF Implementation Use Volume Descriptor Implementation Use field.
Parameters:
None:
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor Implementation Use field already initialized')
self.char_set = _unicodecharset()
self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.lv_info1 = b'\x00' * 36
self.lv_info2 = b'\x00' * 36
self.lv_info3 = b'\x00' * 36
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib', b'')
self.impl_use = b'\x00' * 128
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Implementation Use Volume Descriptor Implementation Use field already initialized'",
")",
"self",
".",
"ch... | A method to create a new UDF Implementation Use Volume Descriptor Implementation Use field.
Parameters:
None:
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Implementation",
"Use",
"Volume",
"Descriptor",
"Implementation",
"Use",
"field",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1171-L1193 |
21,693 | clalancette/pycdlib | pycdlib/udf.py | UDFImplementationUseVolumeDescriptor.parse | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Implementation Use Volume
Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, impl_ident,
impl_use) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
if self.impl_ident.identifier[:12] != b'*UDF LV Info':
raise pycdlibexception.PyCdlibInvalidISO("Implementation Use Identifier not '*UDF LV Info'")
self.impl_use = UDFImplementationUseVolumeDescriptorImplementationUse()
self.impl_use.parse(impl_use)
self.orig_extent_loc = extent
self._initialized = True | python | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Implementation Use Volume
Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, impl_ident,
impl_use) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
if self.impl_ident.identifier[:12] != b'*UDF LV Info':
raise pycdlibexception.PyCdlibInvalidISO("Implementation Use Identifier not '*UDF LV Info'")
self.impl_use = UDFImplementationUseVolumeDescriptorImplementationUse()
self.impl_use.parse(impl_use)
self.orig_extent_loc = extent
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Implementation Use Volume Descriptor ... | Parse the passed in data into a UDF Implementation Use Volume
Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Implementation",
"Use",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1210-L1241 |
21,694 | clalancette/pycdlib | pycdlib/udf.py | UDFImplementationUseVolumeDescriptor.new | def new(self):
# type: () -> None
'''
A method to create a new UDF Implementation Use Volume Descriptor.
Parameters:
None:
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(4) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 1
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*UDF LV Info', b'\x02\x01')
self.impl_use = UDFImplementationUseVolumeDescriptorImplementationUse()
self.impl_use.new()
self._initialized = True | python | def new(self):
# type: () -> None
'''
A method to create a new UDF Implementation Use Volume Descriptor.
Parameters:
None:
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Implementation Use Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(4) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 1
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*UDF LV Info', b'\x02\x01')
self.impl_use = UDFImplementationUseVolumeDescriptorImplementationUse()
self.impl_use.new()
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Implementation Use Volume Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag... | A method to create a new UDF Implementation Use Volume Descriptor.
Parameters:
None:
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Implementation",
"Use",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1281-L1305 |
21,695 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionHeaderDescriptor.parse | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Partition Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Header Descriptor already initialized')
(unalloc_table_length, unalloc_table_pos, unalloc_bitmap_length,
unalloc_bitmap_pos, part_integrity_table_length,
part_integrity_table_pos, freed_table_length, freed_table_pos,
freed_bitmap_length, freed_bitmap_pos,
reserved_unused) = struct.unpack_from(self.FMT, data, 0)
if unalloc_table_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated table length not 0')
if unalloc_table_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated table position not 0')
if unalloc_bitmap_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated bitmap length not 0')
if unalloc_bitmap_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated bitmap position not 0')
if part_integrity_table_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header partition integrity length not 0')
if part_integrity_table_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header partition integrity position not 0')
if freed_table_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed table length not 0')
if freed_table_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed table position not 0')
if freed_bitmap_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed bitmap length not 0')
if freed_bitmap_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed bitmap position not 0')
self._initialized = True | python | def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Partition Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Header Descriptor already initialized')
(unalloc_table_length, unalloc_table_pos, unalloc_bitmap_length,
unalloc_bitmap_pos, part_integrity_table_length,
part_integrity_table_pos, freed_table_length, freed_table_pos,
freed_bitmap_length, freed_bitmap_pos,
reserved_unused) = struct.unpack_from(self.FMT, data, 0)
if unalloc_table_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated table length not 0')
if unalloc_table_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated table position not 0')
if unalloc_bitmap_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated bitmap length not 0')
if unalloc_bitmap_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header unallocated bitmap position not 0')
if part_integrity_table_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header partition integrity length not 0')
if part_integrity_table_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header partition integrity position not 0')
if freed_table_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed table length not 0')
if freed_table_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed table position not 0')
if freed_bitmap_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed bitmap length not 0')
if freed_bitmap_pos != 0:
raise pycdlibexception.PyCdlibInvalidISO('Partition Header freed bitmap position not 0')
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Header Descriptor already initialized'",
")",
"(",
"unalloc_table_length",... | Parse the passed in data into a UDF Partition Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Partition",
"Header",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1336-L1375 |
21,696 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionVolumeDescriptor.parse | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Partition Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, self.part_flags, self.part_num,
part_contents, part_contents_use, self.access_type,
self.part_start_location, self.part_length, impl_ident,
self.implementation_use, reserved_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.part_contents = UDFEntityID()
self.part_contents.parse(part_contents)
if self.part_contents.identifier[:6] != b'+NSR02':
raise pycdlibexception.PyCdlibInvalidISO("Partition Contents Identifier not '+NSR02'")
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self.part_contents_use = UDFPartitionHeaderDescriptor()
self.part_contents_use.parse(part_contents_use)
self.orig_extent_loc = extent
self._initialized = True | python | def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Partition Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, self.part_flags, self.part_num,
part_contents, part_contents_use, self.access_type,
self.part_start_location, self.part_length, impl_ident,
self.implementation_use, reserved_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.part_contents = UDFEntityID()
self.part_contents.parse(part_contents)
if self.part_contents.identifier[:6] != b'+NSR02':
raise pycdlibexception.PyCdlibInvalidISO("Partition Contents Identifier not '+NSR02'")
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self.part_contents_use = UDFPartitionHeaderDescriptor()
self.part_contents_use.parse(part_contents_use)
self.orig_extent_loc = extent
self._initialized = True | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Volume Descriptor already i... | Parse the passed in data into a UDF Partition Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing. | [
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Partition",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1425-L1460 |
21,697 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionVolumeDescriptor.record | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Partition Volume
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Partition Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.vol_desc_seqnum, self.part_flags,
self.part_num, self.part_contents.record(),
self.part_contents_use.record(), self.access_type,
self.part_start_location, self.part_length,
self.impl_ident.record(), self.implementation_use,
b'\x00' * 156)[16:]
return self.desc_tag.record(rec) + rec | python | def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Partition Volume
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Partition Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.vol_desc_seqnum, self.part_flags,
self.part_num, self.part_contents.record(),
self.part_contents_use.record(), self.access_type,
self.part_start_location, self.part_length,
self.impl_ident.record(), self.implementation_use,
b'\x00' * 156)[16:]
return self.desc_tag.record(rec) + rec | [
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Volume Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
... | A method to generate the string representing this UDF Partition Volume
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Partition Volume Descriptor. | [
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Partition",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1462-L1483 |
21,698 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionVolumeDescriptor.new | def new(self):
# type: () -> None
'''
A method to create a new UDF Partition Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(5) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 2
self.part_flags = 1 # FIXME: how should we set this?
self.part_num = 0 # FIXME: how should we set this?
self.part_contents = UDFEntityID()
self.part_contents.new(2, b'+NSR02')
self.part_contents_use = UDFPartitionHeaderDescriptor()
self.part_contents_use.new()
self.access_type = 1
self.part_start_location = 0 # This will get set later
self.part_length = 3 # This will get set later
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.implementation_use = b'\x00' * 128 # FIXME: we should let the user set this
self._initialized = True | python | def new(self):
# type: () -> None
'''
A method to create a new UDF Partition Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(5) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 2
self.part_flags = 1 # FIXME: how should we set this?
self.part_num = 0 # FIXME: how should we set this?
self.part_contents = UDFEntityID()
self.part_contents.new(2, b'+NSR02')
self.part_contents_use = UDFPartitionHeaderDescriptor()
self.part_contents_use.new()
self.access_type = 1
self.part_start_location = 0 # This will get set later
self.part_length = 3 # This will get set later
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.implementation_use = b'\x00' * 128 # FIXME: we should let the user set this
self._initialized = True | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Volume Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",... | A method to create a new UDF Partition Volume Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Partition",
"Volume",
"Descriptor",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1503-L1538 |
21,699 | clalancette/pycdlib | pycdlib/udf.py | UDFPartitionVolumeDescriptor.set_start_location | def set_start_location(self, new_location):
# type: (int) -> None
'''
A method to set the location of the start of the partition.
Parameters:
new_location - The new extent the UDF partition should start at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor not initialized')
self.part_start_location = new_location | python | def set_start_location(self, new_location):
# type: (int) -> None
'''
A method to set the location of the start of the partition.
Parameters:
new_location - The new extent the UDF partition should start at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Volume Descriptor not initialized')
self.part_start_location = new_location | [
"def",
"set_start_location",
"(",
"self",
",",
"new_location",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Volume Descriptor not initialized'",
")",
"self"... | A method to set the location of the start of the partition.
Parameters:
new_location - The new extent the UDF partition should start at.
Returns:
Nothing. | [
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"the",
"start",
"of",
"the",
"partition",
"."
] | 1e7b77a809e905d67dc71e12d70e850be26b6233 | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1555-L1567 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.