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 75
19.8k
| code_tokens
list | docstring
stringlengths 3
17.3k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 87
242
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
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
|
train
|
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",
".",
"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'",
")"
] |
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
|
train
|
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",
".",
"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'",
")"
] |
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
|
train
|
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'",
")",
"self",
".",
"ce_block",
"=",
"block"
] |
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
|
train
|
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",
"+",
"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",
")",
")"
] |
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
|
train
|
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",
"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"
] |
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",
"successful",
"it",
"returns",
"the",
"offset",
"at",
"which",
"it",
"placed",
"this",
"entry",
".",
"If",
"unsuccessful",
"it",
"returns",
"None",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L3151-L3197
|
train
|
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",
".",
"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!'",
")"
] |
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
|
train
|
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",
")",
"&",
"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"
] |
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
|
train
|
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",
".",
"encode",
"(",
"'latin-1'",
")",
"encbyte",
"=",
"b'\\x08'",
"except",
"(",
"UnicodeEncodeError",
",",
"UnicodeDecodeError",
")",
":",
"enc",
"=",
"bytename",
".",
"encode",
"(",
"'utf-16_be'",
")",
"encbyte",
"=",
"b'\\x10'",
"return",
"encbyte",
"+",
"enc"
] |
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
|
train
|
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",
")",
")",
"+",
"(",
"struct",
".",
"pack",
"(",
"'=B'",
",",
"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
|
train
|
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",
"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"
] |
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
|
train
|
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 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"
] |
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
|
train
|
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",
".",
"new_extent_loc",
"=",
"extent"
] |
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
|
train
|
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'",
")",
"(",
"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"
] |
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
|
train
|
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",
"(",
"self",
".",
"FMT",
",",
"0",
",",
"self",
".",
"standard_ident",
",",
"1",
",",
"b'\\x00'",
"*",
"2041",
")"
] |
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
|
train
|
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",
":",
"self",
".",
"standard_ident",
"=",
"b'NSR02'",
"elif",
"version",
"==",
"3",
":",
"self",
".",
"standard_ident",
"=",
"b'NSR03'",
"else",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Invalid NSR version requested'",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
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
|
train
|
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",
"<",
"0",
":",
"return",
"self",
".",
"orig_extent_loc",
"return",
"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
|
train
|
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_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"
] |
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
|
train
|
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",
"(",
"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",
")"
] |
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
|
train
|
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",
".",
"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"
] |
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
|
train
|
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 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"
] |
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
|
train
|
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",
"(",
"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"
] |
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
|
train
|
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",
"(",
")",
"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"
] |
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
|
train
|
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",
"(",
"'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"
] |
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
|
train
|
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",
".",
"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",
"'''\n Compute the 2's complement of int value val\n '''",
"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"
] |
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
|
train
|
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",
")",
"-",
"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",
")"
] |
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
|
train
|
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",
"=",
"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"
] |
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
|
train
|
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",
".",
"identifier",
",",
"self",
".",
"suffix",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
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
|
train
|
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",
".",
"FMT",
",",
"self",
".",
"flags",
",",
"self",
".",
"identifier",
",",
"self",
".",
"suffix",
")"
] |
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
|
train
|
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",
"(",
"'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"
] |
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
|
train
|
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 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"
] |
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
|
train
|
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",
"(",
"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"
] |
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
|
train
|
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",
"(",
")",
"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"
] |
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
|
train
|
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'",
")",
"(",
"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"
] |
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
|
train
|
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",
"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",
")"
] |
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
|
train
|
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",
".",
"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"
] |
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
|
train
|
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 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"
] |
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
|
train
|
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",
"(",
")",
"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"
] |
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
|
train
|
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",
",",
"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"
] |
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
|
train
|
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 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"
] |
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
|
train
|
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",
"(",
"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"
] |
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
|
train
|
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",
"(",
")",
"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"
] |
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
|
train
|
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",
".",
"part_start_location",
"=",
"new_location"
] |
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
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFPartitionMap.parse
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Partition Map.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized')
(map_type, map_length, vol_seqnum,
self.part_num) = struct.unpack_from(self.FMT, data, 0)
if map_type != 1:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map type is not 1')
if map_length != 6:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map length is not 6')
if vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Volume Sequence Number is not 1')
self._initialized = True
|
python
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Partition Map.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized')
(map_type, map_length, vol_seqnum,
self.part_num) = struct.unpack_from(self.FMT, data, 0)
if map_type != 1:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map type is not 1')
if map_length != 6:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map length is not 6')
if vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Volume Sequence Number is not 1')
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Map already initialized'",
")",
"(",
"map_type",
",",
"map_length",
",",
"vol_seqnum",
",",
"self",
".",
"part_num",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"if",
"map_type",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'UDF Partition Map type is not 1'",
")",
"if",
"map_length",
"!=",
"6",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'UDF Partition Map length is not 6'",
")",
"if",
"vol_seqnum",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'UDF Partition Volume Sequence Number is not 1'",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Partition Map.
Parameters:
data - The data to parse.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Partition",
"Map",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1582-L1605
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFPartitionMap.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Partition Map.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized')
self.part_num = 0 # FIXME: we should let the user set this
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Partition Map.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized')
self.part_num = 0 # FIXME: we should let the user set this
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Partition Map already initialized'",
")",
"self",
".",
"part_num",
"=",
"0",
"# FIXME: we should let the user set this",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Partition Map.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Partition",
"Map",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1622-L1637
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLongAD.parse
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Long AD.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long Allocation descriptor already initialized')
(self.extent_length, self.log_block_num, self.part_ref_num,
self.impl_use) = struct.unpack_from(self.FMT, data, 0)
self._initialized = True
|
python
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Long AD.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long Allocation descriptor already initialized')
(self.extent_length, self.log_block_num, self.part_ref_num,
self.impl_use) = struct.unpack_from(self.FMT, data, 0)
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long Allocation descriptor already initialized'",
")",
"(",
"self",
".",
"extent_length",
",",
"self",
".",
"log_block_num",
",",
"self",
".",
"part_ref_num",
",",
"self",
".",
"impl_use",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Long AD.
Parameters:
data - The data to parse.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Long",
"AD",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1653-L1668
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLongAD.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Long AD.
Parameters:
None.
Returns:
A string representing this UDF Long AD.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long AD not initialized')
return struct.pack(self.FMT, self.extent_length, self.log_block_num,
self.part_ref_num, self.impl_use)
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Long AD.
Parameters:
None.
Returns:
A string representing this UDF Long AD.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long AD not initialized')
return struct.pack(self.FMT, self.extent_length, self.log_block_num,
self.part_ref_num, self.impl_use)
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long AD not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"self",
".",
"extent_length",
",",
"self",
".",
"log_block_num",
",",
"self",
".",
"part_ref_num",
",",
"self",
".",
"impl_use",
")"
] |
A method to generate the string representing this UDF Long AD.
Parameters:
None.
Returns:
A string representing this UDF Long AD.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Long",
"AD",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1670-L1684
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLongAD.new
|
def new(self, length, blocknum):
# type: (int, int) -> None
'''
A method to create a new UDF Long AD.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long AD already initialized')
self.extent_length = length
self.log_block_num = blocknum
self.part_ref_num = 0 # FIXME: we should let the user set this
self.impl_use = b'\x00' * 6
self._initialized = True
|
python
|
def new(self, length, blocknum):
# type: (int, int) -> None
'''
A method to create a new UDF Long AD.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long AD already initialized')
self.extent_length = length
self.log_block_num = blocknum
self.part_ref_num = 0 # FIXME: we should let the user set this
self.impl_use = b'\x00' * 6
self._initialized = True
|
[
"def",
"new",
"(",
"self",
",",
"length",
",",
"blocknum",
")",
":",
"# type: (int, int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long AD already initialized'",
")",
"self",
".",
"extent_length",
"=",
"length",
"self",
".",
"log_block_num",
"=",
"blocknum",
"self",
".",
"part_ref_num",
"=",
"0",
"# FIXME: we should let the user set this",
"self",
".",
"impl_use",
"=",
"b'\\x00'",
"*",
"6",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Long AD.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Long",
"AD",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1686-L1704
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLongAD.set_extent_location
|
def set_extent_location(self, new_location, tag_location):
# type: (int, int) -> None
'''
A method to set the location fields of this UDF Long AD.
Parameters:
new_location - The new relative extent that this UDF Long AD references.
tag_location - The new absolute extent that this UDF Long AD references.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long AD not initialized')
self.log_block_num = tag_location
self.impl_use = b'\x00\x00' + struct.pack('=L', new_location)
|
python
|
def set_extent_location(self, new_location, tag_location):
# type: (int, int) -> None
'''
A method to set the location fields of this UDF Long AD.
Parameters:
new_location - The new relative extent that this UDF Long AD references.
tag_location - The new absolute extent that this UDF Long AD references.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Long AD not initialized')
self.log_block_num = tag_location
self.impl_use = b'\x00\x00' + struct.pack('=L', new_location)
|
[
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
",",
"tag_location",
")",
":",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Long AD not initialized'",
")",
"self",
".",
"log_block_num",
"=",
"tag_location",
"self",
".",
"impl_use",
"=",
"b'\\x00\\x00'",
"+",
"struct",
".",
"pack",
"(",
"'=L'",
",",
"new_location",
")"
] |
A method to set the location fields of this UDF Long AD.
Parameters:
new_location - The new relative extent that this UDF Long AD references.
tag_location - The new absolute extent that this UDF Long AD references.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"location",
"fields",
"of",
"this",
"UDF",
"Long",
"AD",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1706-L1721
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeDescriptor.parse
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Logical Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, self.desc_char_set,
self.logical_vol_ident, logical_block_size, domain_ident,
logical_volume_contents_use, map_table_length, num_partition_maps,
impl_ident, self.implementation_use, self.integrity_sequence_length,
self.integrity_sequence_extent, partition_map,
end_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if logical_block_size != 2048:
raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor block size is not 2048')
self.domain_ident = UDFEntityID()
self.domain_ident.parse(domain_ident)
if self.domain_ident.identifier[:19] != b'*OSTA UDF Compliant':
raise pycdlibexception.PyCdlibInvalidISO("Volume Descriptor Identifier not '*OSTA UDF Compliant'")
if map_table_length != 6:
raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor map table length not 6')
if num_partition_maps != 1:
raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor number of partition maps not 1')
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self.partition_map = UDFPartitionMap()
self.partition_map.parse(partition_map)
self.logical_volume_contents_use = UDFLongAD()
self.logical_volume_contents_use.parse(logical_volume_contents_use)
self.orig_extent_loc = extent
self._initialized = True
|
python
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Logical Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum, self.desc_char_set,
self.logical_vol_ident, logical_block_size, domain_ident,
logical_volume_contents_use, map_table_length, num_partition_maps,
impl_ident, self.implementation_use, self.integrity_sequence_length,
self.integrity_sequence_extent, partition_map,
end_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if logical_block_size != 2048:
raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor block size is not 2048')
self.domain_ident = UDFEntityID()
self.domain_ident.parse(domain_ident)
if self.domain_ident.identifier[:19] != b'*OSTA UDF Compliant':
raise pycdlibexception.PyCdlibInvalidISO("Volume Descriptor Identifier not '*OSTA UDF Compliant'")
if map_table_length != 6:
raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor map table length not 6')
if num_partition_maps != 1:
raise pycdlibexception.PyCdlibInvalidISO('Volume Descriptor number of partition maps not 1')
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
self.partition_map = UDFPartitionMap()
self.partition_map.parse(partition_map)
self.logical_volume_contents_use = UDFLongAD()
self.logical_volume_contents_use.parse(logical_volume_contents_use)
self.orig_extent_loc = extent
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor already initialized'",
")",
"(",
"tag_unused",
",",
"self",
".",
"vol_desc_seqnum",
",",
"self",
".",
"desc_char_set",
",",
"self",
".",
"logical_vol_ident",
",",
"logical_block_size",
",",
"domain_ident",
",",
"logical_volume_contents_use",
",",
"map_table_length",
",",
"num_partition_maps",
",",
"impl_ident",
",",
"self",
".",
"implementation_use",
",",
"self",
".",
"integrity_sequence_length",
",",
"self",
".",
"integrity_sequence_extent",
",",
"partition_map",
",",
"end_unused",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"if",
"logical_block_size",
"!=",
"2048",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Volume Descriptor block size is not 2048'",
")",
"self",
".",
"domain_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"domain_ident",
".",
"parse",
"(",
"domain_ident",
")",
"if",
"self",
".",
"domain_ident",
".",
"identifier",
"[",
":",
"19",
"]",
"!=",
"b'*OSTA UDF Compliant'",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"\"Volume Descriptor Identifier not '*OSTA UDF Compliant'\"",
")",
"if",
"map_table_length",
"!=",
"6",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Volume Descriptor map table length not 6'",
")",
"if",
"num_partition_maps",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Volume Descriptor number of partition maps not 1'",
")",
"self",
".",
"impl_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"impl_ident",
".",
"parse",
"(",
"impl_ident",
")",
"self",
".",
"partition_map",
"=",
"UDFPartitionMap",
"(",
")",
"self",
".",
"partition_map",
".",
"parse",
"(",
"partition_map",
")",
"self",
".",
"logical_volume_contents_use",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"logical_volume_contents_use",
".",
"parse",
"(",
"logical_volume_contents_use",
")",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Logical Volume Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1741-L1790
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeDescriptor.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.vol_desc_seqnum, self.desc_char_set,
self.logical_vol_ident, 2048,
self.domain_ident.record(),
self.logical_volume_contents_use.record(), 6, 1,
self.impl_ident.record(), self.implementation_use,
self.integrity_sequence_length,
self.integrity_sequence_extent,
self.partition_map.record(), b'\x00' * 66)[16:]
return self.desc_tag.record(rec) + rec
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.vol_desc_seqnum, self.desc_char_set,
self.logical_vol_ident, 2048,
self.domain_ident.record(),
self.logical_volume_contents_use.record(), 6, 1,
self.impl_ident.record(), self.implementation_use,
self.integrity_sequence_length,
self.integrity_sequence_extent,
self.partition_map.record(), b'\x00' * 66)[16:]
return self.desc_tag.record(rec) + rec
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"b'\\x00'",
"*",
"16",
",",
"self",
".",
"vol_desc_seqnum",
",",
"self",
".",
"desc_char_set",
",",
"self",
".",
"logical_vol_ident",
",",
"2048",
",",
"self",
".",
"domain_ident",
".",
"record",
"(",
")",
",",
"self",
".",
"logical_volume_contents_use",
".",
"record",
"(",
")",
",",
"6",
",",
"1",
",",
"self",
".",
"impl_ident",
".",
"record",
"(",
")",
",",
"self",
".",
"implementation_use",
",",
"self",
".",
"integrity_sequence_length",
",",
"self",
".",
"integrity_sequence_extent",
",",
"self",
".",
"partition_map",
".",
"record",
"(",
")",
",",
"b'\\x00'",
"*",
"66",
")",
"[",
"16",
":",
"]",
"return",
"self",
".",
"desc_tag",
".",
"record",
"(",
"rec",
")",
"+",
"rec"
] |
A method to generate the string representing this UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Descriptor.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Logical",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1792-L1814
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeDescriptor.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(6) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 3
self.desc_char_set = _unicodecharset()
self.logical_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.domain_ident = UDFEntityID()
self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03')
self.logical_volume_contents_use = UDFLongAD()
self.logical_volume_contents_use.new(4096, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.implementation_use = b'\x00' * 128 # FIXME: let the user set this
self.integrity_sequence_length = 4096
self.integrity_sequence_extent = 0 # This will get set later
self.partition_map = UDFPartitionMap()
self.partition_map.new()
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(6) # FIXME: we should let the user set serial_number
self.vol_desc_seqnum = 3
self.desc_char_set = _unicodecharset()
self.logical_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.domain_ident = UDFEntityID()
self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03')
self.logical_volume_contents_use = UDFLongAD()
self.logical_volume_contents_use.new(4096, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.implementation_use = b'\x00' * 128 # FIXME: let the user set this
self.integrity_sequence_length = 4096
self.integrity_sequence_extent = 0 # This will get set later
self.partition_map = UDFPartitionMap()
self.partition_map.new()
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
"self",
".",
"desc_tag",
".",
"new",
"(",
"6",
")",
"# FIXME: we should let the user set serial_number",
"self",
".",
"vol_desc_seqnum",
"=",
"3",
"self",
".",
"desc_char_set",
"=",
"_unicodecharset",
"(",
")",
"self",
".",
"logical_vol_ident",
"=",
"_ostaunicode_zero_pad",
"(",
"'CDROM'",
",",
"128",
")",
"self",
".",
"domain_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"domain_ident",
".",
"new",
"(",
"0",
",",
"b'*OSTA UDF Compliant'",
",",
"b'\\x02\\x01\\x03'",
")",
"self",
".",
"logical_volume_contents_use",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"logical_volume_contents_use",
".",
"new",
"(",
"4096",
",",
"0",
")",
"self",
".",
"impl_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"impl_ident",
".",
"new",
"(",
"0",
",",
"b'*pycdlib'",
")",
"self",
".",
"implementation_use",
"=",
"b'\\x00'",
"*",
"128",
"# FIXME: let the user set this",
"self",
".",
"integrity_sequence_length",
"=",
"4096",
"self",
".",
"integrity_sequence_extent",
"=",
"0",
"# This will get set later",
"self",
".",
"partition_map",
"=",
"UDFPartitionMap",
"(",
")",
"self",
".",
"partition_map",
".",
"new",
"(",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Logical Volume Descriptor.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1834-L1871
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeDescriptor.set_integrity_location
|
def set_integrity_location(self, integrity_extent):
# type: (int) -> None
'''
A method to set the location of the UDF Integrity sequence that this descriptor references.
Parameters:
integrity_extent - The new extent that the UDF Integrity sequence should start at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor not initialized')
self.integrity_sequence_extent = integrity_extent
|
python
|
def set_integrity_location(self, integrity_extent):
# type: (int) -> None
'''
A method to set the location of the UDF Integrity sequence that this descriptor references.
Parameters:
integrity_extent - The new extent that the UDF Integrity sequence should start at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Descriptor not initialized')
self.integrity_sequence_extent = integrity_extent
|
[
"def",
"set_integrity_location",
"(",
"self",
",",
"integrity_extent",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Descriptor not initialized'",
")",
"self",
".",
"integrity_sequence_extent",
"=",
"integrity_extent"
] |
A method to set the location of the UDF Integrity sequence that this descriptor references.
Parameters:
integrity_extent - The new extent that the UDF Integrity sequence should start at.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"the",
"UDF",
"Integrity",
"sequence",
"that",
"this",
"descriptor",
"references",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1889-L1902
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFUnallocatedSpaceDescriptor.parse
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Unallocated Space Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Unallocated Space Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum,
num_alloc_descriptors, end_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if num_alloc_descriptors != 0:
raise pycdlibexception.PyCdlibInvalidISO('UDF Unallocated Space Descriptor allocated descriptors is not 0')
self.orig_extent_loc = extent
self._initialized = True
|
python
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Unallocated Space Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Unallocated Space Descriptor already initialized')
(tag_unused, self.vol_desc_seqnum,
num_alloc_descriptors, end_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if num_alloc_descriptors != 0:
raise pycdlibexception.PyCdlibInvalidISO('UDF Unallocated Space Descriptor allocated descriptors is not 0')
self.orig_extent_loc = extent
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Unallocated Space Descriptor already initialized'",
")",
"(",
"tag_unused",
",",
"self",
".",
"vol_desc_seqnum",
",",
"num_alloc_descriptors",
",",
"end_unused",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"if",
"num_alloc_descriptors",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'UDF Unallocated Space Descriptor allocated descriptors is not 0'",
")",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Unallocated Space Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Unallocated",
"Space",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L1919-L1944
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFTerminatingDescriptor.parse
|
def parse(self, extent, desc_tag):
# type: (int, UDFTag) -> None
'''
Parse the passed in data into a UDF Terminating Descriptor.
Parameters:
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor already initialized')
self.desc_tag = desc_tag
self.orig_extent_loc = extent
self._initialized = True
|
python
|
def parse(self, extent, desc_tag):
# type: (int, UDFTag) -> None
'''
Parse the passed in data into a UDF Terminating Descriptor.
Parameters:
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor already initialized')
self.desc_tag = desc_tag
self.orig_extent_loc = extent
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Terminating Descriptor.
Parameters:
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Terminating",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2033-L2051
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFTerminatingDescriptor.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Terminating
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Terminating Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16, b'\x00' * 496)[16:]
return self.desc_tag.record(rec) + rec
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Terminating
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Terminating Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16, b'\x00' * 496)[16:]
return self.desc_tag.record(rec) + rec
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"b'\\x00'",
"*",
"16",
",",
"b'\\x00'",
"*",
"496",
")",
"[",
"16",
":",
"]",
"return",
"self",
".",
"desc_tag",
".",
"record",
"(",
"rec",
")",
"+",
"rec"
] |
A method to generate the string representing this UDF Terminating
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Terminating Descriptor.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Terminating",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2053-L2068
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFTerminatingDescriptor.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Terminating Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(8) # FIXME: we should let the user set serial_number
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Terminating Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(8) # FIXME: we should let the user set serial_number
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
"self",
".",
"desc_tag",
".",
"new",
"(",
"8",
")",
"# FIXME: we should let the user set serial_number",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Terminating Descriptor.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Terminating",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2087-L2103
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFTerminatingDescriptor.set_extent_location
|
def set_extent_location(self, new_location, tag_location=None):
# type: (int, int) -> None
'''
A method to set the location of this UDF Terminating Descriptor.
Parameters:
new_location - The new extent this UDF Terminating Descriptor should be located at.
tag_location - The tag location to set for this UDF Terminator Descriptor.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized')
self.new_extent_loc = new_location
if tag_location is None:
tag_location = new_location
self.desc_tag.tag_location = tag_location
|
python
|
def set_extent_location(self, new_location, tag_location=None):
# type: (int, int) -> None
'''
A method to set the location of this UDF Terminating Descriptor.
Parameters:
new_location - The new extent this UDF Terminating Descriptor should be located at.
tag_location - The tag location to set for this UDF Terminator Descriptor.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized')
self.new_extent_loc = new_location
if tag_location is None:
tag_location = new_location
self.desc_tag.tag_location = tag_location
|
[
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
",",
"tag_location",
"=",
"None",
")",
":",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Terminating Descriptor not initialized'",
")",
"self",
".",
"new_extent_loc",
"=",
"new_location",
"if",
"tag_location",
"is",
"None",
":",
"tag_location",
"=",
"new_location",
"self",
".",
"desc_tag",
".",
"tag_location",
"=",
"tag_location"
] |
A method to set the location of this UDF Terminating Descriptor.
Parameters:
new_location - The new extent this UDF Terminating Descriptor should be located at.
tag_location - The tag location to set for this UDF Terminator Descriptor.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"this",
"UDF",
"Terminating",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2105-L2122
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeHeaderDescriptor.parse
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Logical Volume Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header Descriptor already initialized')
(self.unique_id, reserved_unused) = struct.unpack_from(self.FMT, data, 0)
self._initialized = True
|
python
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Logical Volume Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header Descriptor already initialized')
(self.unique_id, reserved_unused) = struct.unpack_from(self.FMT, data, 0)
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Header Descriptor already initialized'",
")",
"(",
"self",
".",
"unique_id",
",",
"reserved_unused",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Logical Volume Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Header",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2137-L2151
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeHeaderDescriptor.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Header Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header Descriptor already initialized')
self.unique_id = 261
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Header Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header Descriptor already initialized')
self.unique_id = 261
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Header Descriptor already initialized'",
")",
"self",
".",
"unique_id",
"=",
"261",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Logical Volume Header Descriptor.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Header",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2169-L2184
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeImplementationUse.parse
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Logical Volume Implementation Use.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use already initialized')
(impl_id, self.num_files, self.num_dirs, self.min_udf_read_revision,
self.min_udf_write_revision,
self.max_udf_write_revision) = struct.unpack_from(self.FMT, data, 0)
self.impl_id = UDFEntityID()
self.impl_id.parse(impl_id)
self.impl_use = data[46:]
self._initialized = True
|
python
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Logical Volume Implementation Use.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use already initialized')
(impl_id, self.num_files, self.num_dirs, self.min_udf_read_revision,
self.min_udf_write_revision,
self.max_udf_write_revision) = struct.unpack_from(self.FMT, data, 0)
self.impl_id = UDFEntityID()
self.impl_id.parse(impl_id)
self.impl_use = data[46:]
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Implementation Use already initialized'",
")",
"(",
"impl_id",
",",
"self",
".",
"num_files",
",",
"self",
".",
"num_dirs",
",",
"self",
".",
"min_udf_read_revision",
",",
"self",
".",
"min_udf_write_revision",
",",
"self",
".",
"max_udf_write_revision",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"impl_id",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"impl_id",
".",
"parse",
"(",
"impl_id",
")",
"self",
".",
"impl_use",
"=",
"data",
"[",
"46",
":",
"]",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Logical Volume Implementation Use.
Parameters:
data - The data to parse.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Implementation",
"Use",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2201-L2223
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeImplementationUse.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Logical Volume
Implementation Use.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Implementation Use.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use not initialized')
return struct.pack(self.FMT, self.impl_id.record(),
self.num_files, self.num_dirs,
self.min_udf_read_revision,
self.min_udf_write_revision,
self.max_udf_write_revision) + self.impl_use
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Logical Volume
Implementation Use.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Implementation Use.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use not initialized')
return struct.pack(self.FMT, self.impl_id.record(),
self.num_files, self.num_dirs,
self.min_udf_read_revision,
self.min_udf_write_revision,
self.max_udf_write_revision) + self.impl_use
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Implementation Use not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"self",
".",
"impl_id",
".",
"record",
"(",
")",
",",
"self",
".",
"num_files",
",",
"self",
".",
"num_dirs",
",",
"self",
".",
"min_udf_read_revision",
",",
"self",
".",
"min_udf_write_revision",
",",
"self",
".",
"max_udf_write_revision",
")",
"+",
"self",
".",
"impl_use"
] |
A method to generate the string representing this UDF Logical Volume
Implementation Use.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Implementation Use.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Logical",
"Volume",
"Implementation",
"Use",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2225-L2243
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeImplementationUse.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Implementation Use.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use already initialized')
self.impl_id = UDFEntityID()
self.impl_id.new(0, b'*pycdlib')
self.num_files = 0
self.num_dirs = 1
self.min_udf_read_revision = 258
self.min_udf_write_revision = 258
self.max_udf_write_revision = 258
self.impl_use = b'\x00' * 378 # FIXME: let the user set this
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Implementation Use.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Implementation Use already initialized')
self.impl_id = UDFEntityID()
self.impl_id.new(0, b'*pycdlib')
self.num_files = 0
self.num_dirs = 1
self.min_udf_read_revision = 258
self.min_udf_write_revision = 258
self.max_udf_write_revision = 258
self.impl_use = b'\x00' * 378 # FIXME: let the user set this
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Implementation Use already initialized'",
")",
"self",
".",
"impl_id",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"impl_id",
".",
"new",
"(",
"0",
",",
"b'*pycdlib'",
")",
"self",
".",
"num_files",
"=",
"0",
"self",
".",
"num_dirs",
"=",
"1",
"self",
".",
"min_udf_read_revision",
"=",
"258",
"self",
".",
"min_udf_write_revision",
"=",
"258",
"self",
".",
"max_udf_write_revision",
"=",
"258",
"self",
".",
"impl_use",
"=",
"b'\\x00'",
"*",
"378",
"# FIXME: let the user set this",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Logical Volume Implementation Use.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Implementation",
"Use",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2245-L2269
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeIntegrityDescriptor.parse
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Logical Volume Integrity Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized')
(tag_unused, recording_date, integrity_type,
next_integrity_extent_length, next_integrity_extent_extent,
logical_volume_contents_use, num_partitions,
self.length_impl_use, self.free_space_table,
self.size_table, impl_use) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.recording_date = UDFTimestamp()
self.recording_date.parse(recording_date)
if integrity_type != 1:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Type not 1')
if next_integrity_extent_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Extent length not 1')
if next_integrity_extent_extent != 0:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Extent extent not 1')
if num_partitions != 1:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity number partitions not 1')
# For now, we only support an implementation use field of up to 424
# bytes (the 'rest' of the 512 byte sector we get here). If we run
# across ones that are larger, we can go up to 2048, but anything
# larger than that is invalid (I'm not quite sure why UDF defines
# this as a 32-bit quantity, since there are no situations in which
# this can be larger than 2048 minus 88).
if self.length_impl_use > 424:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity implementation use length too large')
if self.free_space_table != 0:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity free space table not 0')
self.logical_volume_contents_use = UDFLogicalVolumeHeaderDescriptor()
self.logical_volume_contents_use.parse(logical_volume_contents_use)
self.logical_volume_impl_use = UDFLogicalVolumeImplementationUse()
self.logical_volume_impl_use.parse(impl_use)
self.orig_extent_loc = extent
self._initialized = True
|
python
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF Logical Volume Integrity Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized')
(tag_unused, recording_date, integrity_type,
next_integrity_extent_length, next_integrity_extent_extent,
logical_volume_contents_use, num_partitions,
self.length_impl_use, self.free_space_table,
self.size_table, impl_use) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.recording_date = UDFTimestamp()
self.recording_date.parse(recording_date)
if integrity_type != 1:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Type not 1')
if next_integrity_extent_length != 0:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Extent length not 1')
if next_integrity_extent_extent != 0:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity Extent extent not 1')
if num_partitions != 1:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity number partitions not 1')
# For now, we only support an implementation use field of up to 424
# bytes (the 'rest' of the 512 byte sector we get here). If we run
# across ones that are larger, we can go up to 2048, but anything
# larger than that is invalid (I'm not quite sure why UDF defines
# this as a 32-bit quantity, since there are no situations in which
# this can be larger than 2048 minus 88).
if self.length_impl_use > 424:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity implementation use length too large')
if self.free_space_table != 0:
raise pycdlibexception.PyCdlibInvalidISO('Logical Volume Integrity free space table not 0')
self.logical_volume_contents_use = UDFLogicalVolumeHeaderDescriptor()
self.logical_volume_contents_use.parse(logical_volume_contents_use)
self.logical_volume_impl_use = UDFLogicalVolumeImplementationUse()
self.logical_volume_impl_use.parse(impl_use)
self.orig_extent_loc = extent
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor already initialized'",
")",
"(",
"tag_unused",
",",
"recording_date",
",",
"integrity_type",
",",
"next_integrity_extent_length",
",",
"next_integrity_extent_extent",
",",
"logical_volume_contents_use",
",",
"num_partitions",
",",
"self",
".",
"length_impl_use",
",",
"self",
".",
"free_space_table",
",",
"self",
".",
"size_table",
",",
"impl_use",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"self",
".",
"recording_date",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"recording_date",
".",
"parse",
"(",
"recording_date",
")",
"if",
"integrity_type",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Logical Volume Integrity Type not 1'",
")",
"if",
"next_integrity_extent_length",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Logical Volume Integrity Extent length not 1'",
")",
"if",
"next_integrity_extent_extent",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Logical Volume Integrity Extent extent not 1'",
")",
"if",
"num_partitions",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Logical Volume Integrity number partitions not 1'",
")",
"# For now, we only support an implementation use field of up to 424",
"# bytes (the 'rest' of the 512 byte sector we get here). If we run",
"# across ones that are larger, we can go up to 2048, but anything",
"# larger than that is invalid (I'm not quite sure why UDF defines",
"# this as a 32-bit quantity, since there are no situations in which",
"# this can be larger than 2048 minus 88).",
"if",
"self",
".",
"length_impl_use",
">",
"424",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Logical Volume Integrity implementation use length too large'",
")",
"if",
"self",
".",
"free_space_table",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Logical Volume Integrity free space table not 0'",
")",
"self",
".",
"logical_volume_contents_use",
"=",
"UDFLogicalVolumeHeaderDescriptor",
"(",
")",
"self",
".",
"logical_volume_contents_use",
".",
"parse",
"(",
"logical_volume_contents_use",
")",
"self",
".",
"logical_volume_impl_use",
"=",
"UDFLogicalVolumeImplementationUse",
"(",
")",
"self",
".",
"logical_volume_impl_use",
".",
"parse",
"(",
"impl_use",
")",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF Logical Volume Integrity Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2288-L2341
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeIntegrityDescriptor.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Logical Volume
Integrity Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Integrity Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.recording_date.record(), 1, 0, 0,
self.logical_volume_contents_use.record(), 1,
self.length_impl_use, self.free_space_table,
self.size_table,
self.logical_volume_impl_use.record())[16:]
return self.desc_tag.record(rec) + rec
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Logical Volume
Integrity Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Integrity Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.recording_date.record(), 1, 0, 0,
self.logical_volume_contents_use.record(), 1,
self.length_impl_use, self.free_space_table,
self.size_table,
self.logical_volume_impl_use.record())[16:]
return self.desc_tag.record(rec) + rec
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"b'\\x00'",
"*",
"16",
",",
"self",
".",
"recording_date",
".",
"record",
"(",
")",
",",
"1",
",",
"0",
",",
"0",
",",
"self",
".",
"logical_volume_contents_use",
".",
"record",
"(",
")",
",",
"1",
",",
"self",
".",
"length_impl_use",
",",
"self",
".",
"free_space_table",
",",
"self",
".",
"size_table",
",",
"self",
".",
"logical_volume_impl_use",
".",
"record",
"(",
")",
")",
"[",
"16",
":",
"]",
"return",
"self",
".",
"desc_tag",
".",
"record",
"(",
"rec",
")",
"+",
"rec"
] |
A method to generate the string representing this UDF Logical Volume
Integrity Descriptor.
Parameters:
None.
Returns:
A string representing this UDF Logical Volume Integrity Descriptor.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2343-L2363
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFLogicalVolumeIntegrityDescriptor.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(9) # FIXME: we should let the user set serial_number
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.length_impl_use = 46
self.free_space_table = 0 # FIXME: let the user set this
self.size_table = 3
self.logical_volume_contents_use = UDFLogicalVolumeHeaderDescriptor()
self.logical_volume_contents_use.new()
self.logical_volume_impl_use = UDFLogicalVolumeImplementationUse()
self.logical_volume_impl_use.new()
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Integrity Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(9) # FIXME: we should let the user set serial_number
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.length_impl_use = 46
self.free_space_table = 0 # FIXME: let the user set this
self.size_table = 3
self.logical_volume_contents_use = UDFLogicalVolumeHeaderDescriptor()
self.logical_volume_contents_use.new()
self.logical_volume_impl_use = UDFLogicalVolumeImplementationUse()
self.logical_volume_impl_use.new()
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
"self",
".",
"desc_tag",
".",
"new",
"(",
"9",
")",
"# FIXME: we should let the user set serial_number",
"self",
".",
"recording_date",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"recording_date",
".",
"new",
"(",
")",
"self",
".",
"length_impl_use",
"=",
"46",
"self",
".",
"free_space_table",
"=",
"0",
"# FIXME: let the user set this",
"self",
".",
"size_table",
"=",
"3",
"self",
".",
"logical_volume_contents_use",
"=",
"UDFLogicalVolumeHeaderDescriptor",
"(",
")",
"self",
".",
"logical_volume_contents_use",
".",
"new",
"(",
")",
"self",
".",
"logical_volume_impl_use",
"=",
"UDFLogicalVolumeImplementationUse",
"(",
")",
"self",
".",
"logical_volume_impl_use",
".",
"new",
"(",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2383-L2412
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileSetDescriptor.parse
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF File Set Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized')
(tag_unused, recording_date, interchange_level, max_interchange_level,
char_set_list, max_char_set_list, self.file_set_num, file_set_desc_num,
self.log_vol_char_set, self.log_vol_ident,
self.file_set_char_set, self.file_set_ident, self.copyright_file_ident,
self.abstract_file_ident, root_dir_icb, domain_ident, next_extent,
reserved_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.recording_date = UDFTimestamp()
self.recording_date.parse(recording_date)
if interchange_level != 3:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_interchange_level != 3:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if file_set_desc_num != 0:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
self.domain_ident = UDFEntityID()
self.domain_ident.parse(domain_ident)
if self.domain_ident.identifier[:19] != b'*OSTA UDF Compliant':
raise pycdlibexception.PyCdlibInvalidISO("File Set Descriptor Identifier not '*OSTA UDF Compliant'")
self.root_dir_icb = UDFLongAD()
self.root_dir_icb.parse(root_dir_icb)
if next_extent != b'\x00' * 16:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
self.orig_extent_loc = extent
self._initialized = True
|
python
|
def parse(self, data, extent, desc_tag):
# type: (bytes, int, UDFTag) -> None
'''
Parse the passed in data into a UDF File Set Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized')
(tag_unused, recording_date, interchange_level, max_interchange_level,
char_set_list, max_char_set_list, self.file_set_num, file_set_desc_num,
self.log_vol_char_set, self.log_vol_ident,
self.file_set_char_set, self.file_set_ident, self.copyright_file_ident,
self.abstract_file_ident, root_dir_icb, domain_ident, next_extent,
reserved_unused) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.recording_date = UDFTimestamp()
self.recording_date.parse(recording_date)
if interchange_level != 3:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_interchange_level != 3:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if max_char_set_list != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
if file_set_desc_num != 0:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
self.domain_ident = UDFEntityID()
self.domain_ident.parse(domain_ident)
if self.domain_ident.identifier[:19] != b'*OSTA UDF Compliant':
raise pycdlibexception.PyCdlibInvalidISO("File Set Descriptor Identifier not '*OSTA UDF Compliant'")
self.root_dir_icb = UDFLongAD()
self.root_dir_icb.parse(root_dir_icb)
if next_extent != b'\x00' * 16:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-Only disks are supported')
self.orig_extent_loc = extent
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor already initialized'",
")",
"(",
"tag_unused",
",",
"recording_date",
",",
"interchange_level",
",",
"max_interchange_level",
",",
"char_set_list",
",",
"max_char_set_list",
",",
"self",
".",
"file_set_num",
",",
"file_set_desc_num",
",",
"self",
".",
"log_vol_char_set",
",",
"self",
".",
"log_vol_ident",
",",
"self",
".",
"file_set_char_set",
",",
"self",
".",
"file_set_ident",
",",
"self",
".",
"copyright_file_ident",
",",
"self",
".",
"abstract_file_ident",
",",
"root_dir_icb",
",",
"domain_ident",
",",
"next_extent",
",",
"reserved_unused",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"self",
".",
"recording_date",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"recording_date",
".",
"parse",
"(",
"recording_date",
")",
"if",
"interchange_level",
"!=",
"3",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-Only disks are supported'",
")",
"if",
"max_interchange_level",
"!=",
"3",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-Only disks are supported'",
")",
"if",
"char_set_list",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-Only disks are supported'",
")",
"if",
"max_char_set_list",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-Only disks are supported'",
")",
"if",
"file_set_desc_num",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-Only disks are supported'",
")",
"self",
".",
"domain_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"domain_ident",
".",
"parse",
"(",
"domain_ident",
")",
"if",
"self",
".",
"domain_ident",
".",
"identifier",
"[",
":",
"19",
"]",
"!=",
"b'*OSTA UDF Compliant'",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"\"File Set Descriptor Identifier not '*OSTA UDF Compliant'\"",
")",
"self",
".",
"root_dir_icb",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"root_dir_icb",
".",
"parse",
"(",
"root_dir_icb",
")",
"if",
"next_extent",
"!=",
"b'\\x00'",
"*",
"16",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-Only disks are supported'",
")",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF File Set Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"File",
"Set",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2448-L2499
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileSetDescriptor.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Set
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Set Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.recording_date.record(), 3, 3, 1, 1,
self.file_set_num, 0, self.log_vol_char_set,
self.log_vol_ident, self.file_set_char_set,
self.file_set_ident, self.copyright_file_ident,
self.abstract_file_ident, self.root_dir_icb.record(),
self.domain_ident.record(), b'\x00' * 16,
b'\x00' * 48)[16:]
return self.desc_tag.record(rec) + rec
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Set
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Set Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.recording_date.record(), 3, 3, 1, 1,
self.file_set_num, 0, self.log_vol_char_set,
self.log_vol_ident, self.file_set_char_set,
self.file_set_ident, self.copyright_file_ident,
self.abstract_file_ident, self.root_dir_icb.record(),
self.domain_ident.record(), b'\x00' * 16,
b'\x00' * 48)[16:]
return self.desc_tag.record(rec) + rec
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"b'\\x00'",
"*",
"16",
",",
"self",
".",
"recording_date",
".",
"record",
"(",
")",
",",
"3",
",",
"3",
",",
"1",
",",
"1",
",",
"self",
".",
"file_set_num",
",",
"0",
",",
"self",
".",
"log_vol_char_set",
",",
"self",
".",
"log_vol_ident",
",",
"self",
".",
"file_set_char_set",
",",
"self",
".",
"file_set_ident",
",",
"self",
".",
"copyright_file_ident",
",",
"self",
".",
"abstract_file_ident",
",",
"self",
".",
"root_dir_icb",
".",
"record",
"(",
")",
",",
"self",
".",
"domain_ident",
".",
"record",
"(",
")",
",",
"b'\\x00'",
"*",
"16",
",",
"b'\\x00'",
"*",
"48",
")",
"[",
"16",
":",
"]",
"return",
"self",
".",
"desc_tag",
".",
"record",
"(",
"rec",
")",
"+",
"rec"
] |
A method to generate the string representing this UDF File Set
Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Set Descriptor.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"File",
"Set",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2501-L2523
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileSetDescriptor.new
|
def new(self):
# type: () -> None
'''
A method to create a new UDF File Set Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(256) # FIXME: we should let the user set serial_number
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.domain_ident = UDFEntityID()
self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03')
self.root_dir_icb = UDFLongAD()
self.root_dir_icb.new(2048, 2)
self.file_set_num = 0
self.log_vol_char_set = _unicodecharset()
self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.file_set_char_set = _unicodecharset()
self.file_set_ident = _ostaunicode_zero_pad('CDROM', 32)
self.copyright_file_ident = b'\x00' * 32 # FIXME: let the user set this
self.abstract_file_ident = b'\x00' * 32 # FIXME: let the user set this
self._initialized = True
|
python
|
def new(self):
# type: () -> None
'''
A method to create a new UDF File Set Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(256) # FIXME: we should let the user set serial_number
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.domain_ident = UDFEntityID()
self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03')
self.root_dir_icb = UDFLongAD()
self.root_dir_icb.new(2048, 2)
self.file_set_num = 0
self.log_vol_char_set = _unicodecharset()
self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.file_set_char_set = _unicodecharset()
self.file_set_ident = _ostaunicode_zero_pad('CDROM', 32)
self.copyright_file_ident = b'\x00' * 32 # FIXME: let the user set this
self.abstract_file_ident = b'\x00' * 32 # FIXME: let the user set this
self._initialized = True
|
[
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
"self",
".",
"desc_tag",
".",
"new",
"(",
"256",
")",
"# FIXME: we should let the user set serial_number",
"self",
".",
"recording_date",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"recording_date",
".",
"new",
"(",
")",
"self",
".",
"domain_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"domain_ident",
".",
"new",
"(",
"0",
",",
"b'*OSTA UDF Compliant'",
",",
"b'\\x02\\x01\\x03'",
")",
"self",
".",
"root_dir_icb",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"root_dir_icb",
".",
"new",
"(",
"2048",
",",
"2",
")",
"self",
".",
"file_set_num",
"=",
"0",
"self",
".",
"log_vol_char_set",
"=",
"_unicodecharset",
"(",
")",
"self",
".",
"log_vol_ident",
"=",
"_ostaunicode_zero_pad",
"(",
"'CDROM'",
",",
"128",
")",
"self",
".",
"file_set_char_set",
"=",
"_unicodecharset",
"(",
")",
"self",
".",
"file_set_ident",
"=",
"_ostaunicode_zero_pad",
"(",
"'CDROM'",
",",
"32",
")",
"self",
".",
"copyright_file_ident",
"=",
"b'\\x00'",
"*",
"32",
"# FIXME: let the user set this",
"self",
".",
"abstract_file_ident",
"=",
"b'\\x00'",
"*",
"32",
"# FIXME: let the user set this",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF File Set Descriptor.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"File",
"Set",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2542-L2575
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileSetDescriptor.set_extent_location
|
def set_extent_location(self, new_location):
# type: (int) -> None
'''
A method to set the location of this UDF File Set Descriptor.
Parameters:
new_location - The new extent this UDF File Set Descriptor should be located at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized')
self.new_extent_loc = new_location
|
python
|
def set_extent_location(self, new_location):
# type: (int) -> None
'''
A method to set the location of this UDF File Set Descriptor.
Parameters:
new_location - The new extent this UDF File Set Descriptor should be located at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor not initialized')
self.new_extent_loc = new_location
|
[
"def",
"set_extent_location",
"(",
"self",
",",
"new_location",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Set Descriptor not initialized'",
")",
"self",
".",
"new_extent_loc",
"=",
"new_location"
] |
A method to set the location of this UDF File Set Descriptor.
Parameters:
new_location - The new extent this UDF File Set Descriptor should be located at.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"this",
"UDF",
"File",
"Set",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2577-L2590
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFICBTag.parse
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF ICB Tag.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag already initialized')
(self.prior_num_direct_entries, self.strategy_type, self.strategy_param,
self.max_num_entries, reserved, self.file_type,
self.parent_icb_log_block_num, self.parent_icb_part_ref_num,
self.flags) = struct.unpack_from(self.FMT, data, 0)
if self.strategy_type not in (4, 4096):
raise pycdlibexception.PyCdlibInvalidISO('UDF ICB Tag invalid strategy type')
if reserved != 0:
raise pycdlibexception.PyCdlibInvalidISO('UDF ICB Tag reserved not 0')
self._initialized = True
|
python
|
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF ICB Tag.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag already initialized')
(self.prior_num_direct_entries, self.strategy_type, self.strategy_param,
self.max_num_entries, reserved, self.file_type,
self.parent_icb_log_block_num, self.parent_icb_part_ref_num,
self.flags) = struct.unpack_from(self.FMT, data, 0)
if self.strategy_type not in (4, 4096):
raise pycdlibexception.PyCdlibInvalidISO('UDF ICB Tag invalid strategy type')
if reserved != 0:
raise pycdlibexception.PyCdlibInvalidISO('UDF ICB Tag reserved not 0')
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF ICB Tag already initialized'",
")",
"(",
"self",
".",
"prior_num_direct_entries",
",",
"self",
".",
"strategy_type",
",",
"self",
".",
"strategy_param",
",",
"self",
".",
"max_num_entries",
",",
"reserved",
",",
"self",
".",
"file_type",
",",
"self",
".",
"parent_icb_log_block_num",
",",
"self",
".",
"parent_icb_part_ref_num",
",",
"self",
".",
"flags",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"if",
"self",
".",
"strategy_type",
"not",
"in",
"(",
"4",
",",
"4096",
")",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'UDF ICB Tag invalid strategy type'",
")",
"if",
"reserved",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'UDF ICB Tag reserved not 0'",
")",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF ICB Tag.
Parameters:
data - The data to parse.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"ICB",
"Tag",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2607-L2631
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFICBTag.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF ICB Tag.
Parameters:
None.
Returns:
A string representing this UDF ICB Tag.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag not initialized')
return struct.pack(self.FMT, self.prior_num_direct_entries,
self.strategy_type, self.strategy_param,
self.max_num_entries, 0, self.file_type,
self.parent_icb_log_block_num,
self.parent_icb_part_ref_num, self.flags)
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF ICB Tag.
Parameters:
None.
Returns:
A string representing this UDF ICB Tag.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag not initialized')
return struct.pack(self.FMT, self.prior_num_direct_entries,
self.strategy_type, self.strategy_param,
self.max_num_entries, 0, self.file_type,
self.parent_icb_log_block_num,
self.parent_icb_part_ref_num, self.flags)
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF ICB Tag not initialized'",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"self",
".",
"prior_num_direct_entries",
",",
"self",
".",
"strategy_type",
",",
"self",
".",
"strategy_param",
",",
"self",
".",
"max_num_entries",
",",
"0",
",",
"self",
".",
"file_type",
",",
"self",
".",
"parent_icb_log_block_num",
",",
"self",
".",
"parent_icb_part_ref_num",
",",
"self",
".",
"flags",
")"
] |
A method to generate the string representing this UDF ICB Tag.
Parameters:
None.
Returns:
A string representing this UDF ICB Tag.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"ICB",
"Tag",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2633-L2650
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFICBTag.new
|
def new(self, file_type):
# type: (str) -> None
'''
A method to create a new UDF ICB Tag.
Parameters:
file_type - What file type this represents, one of 'dir', 'file', or 'symlink'.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag already initialized')
self.prior_num_direct_entries = 0 # FIXME: let the user set this
self.strategy_type = 4
self.strategy_param = 0 # FIXME: let the user set this
self.max_num_entries = 1
if file_type == 'dir':
self.file_type = 4
elif file_type == 'file':
self.file_type = 5
elif file_type == 'symlink':
self.file_type = 12
else:
raise pycdlibexception.PyCdlibInternalError("Invalid file type for ICB; must be one of 'dir', 'file', or 'symlink'")
self.parent_icb_log_block_num = 0 # FIXME: let the user set this
self.parent_icb_part_ref_num = 0 # FIXME: let the user set this
self.flags = 560 # hex 0x230 == binary 0010 0011 0000
self._initialized = True
|
python
|
def new(self, file_type):
# type: (str) -> None
'''
A method to create a new UDF ICB Tag.
Parameters:
file_type - What file type this represents, one of 'dir', 'file', or 'symlink'.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF ICB Tag already initialized')
self.prior_num_direct_entries = 0 # FIXME: let the user set this
self.strategy_type = 4
self.strategy_param = 0 # FIXME: let the user set this
self.max_num_entries = 1
if file_type == 'dir':
self.file_type = 4
elif file_type == 'file':
self.file_type = 5
elif file_type == 'symlink':
self.file_type = 12
else:
raise pycdlibexception.PyCdlibInternalError("Invalid file type for ICB; must be one of 'dir', 'file', or 'symlink'")
self.parent_icb_log_block_num = 0 # FIXME: let the user set this
self.parent_icb_part_ref_num = 0 # FIXME: let the user set this
self.flags = 560 # hex 0x230 == binary 0010 0011 0000
self._initialized = True
|
[
"def",
"new",
"(",
"self",
",",
"file_type",
")",
":",
"# type: (str) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF ICB Tag already initialized'",
")",
"self",
".",
"prior_num_direct_entries",
"=",
"0",
"# FIXME: let the user set this",
"self",
".",
"strategy_type",
"=",
"4",
"self",
".",
"strategy_param",
"=",
"0",
"# FIXME: let the user set this",
"self",
".",
"max_num_entries",
"=",
"1",
"if",
"file_type",
"==",
"'dir'",
":",
"self",
".",
"file_type",
"=",
"4",
"elif",
"file_type",
"==",
"'file'",
":",
"self",
".",
"file_type",
"=",
"5",
"elif",
"file_type",
"==",
"'symlink'",
":",
"self",
".",
"file_type",
"=",
"12",
"else",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"\"Invalid file type for ICB; must be one of 'dir', 'file', or 'symlink'\"",
")",
"self",
".",
"parent_icb_log_block_num",
"=",
"0",
"# FIXME: let the user set this",
"self",
".",
"parent_icb_part_ref_num",
"=",
"0",
"# FIXME: let the user set this",
"self",
".",
"flags",
"=",
"560",
"# hex 0x230 == binary 0010 0011 0000",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF ICB Tag.
Parameters:
file_type - What file type this represents, one of 'dir', 'file', or 'symlink'.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"ICB",
"Tag",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2652-L2682
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.parse
|
def parse(self, data, extent, parent, desc_tag):
# type: (bytes, int, Optional[UDFFileEntry], UDFTag) -> None
'''
Parse the passed in data into a UDF File Entry.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
parent - The parent File Entry for this file (may be None).
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized')
(tag_unused, icb_tag, self.uid, self.gid, self.perms, self.file_link_count,
record_format, record_display_attrs, record_len,
self.info_len, self.log_block_recorded, access_time, mod_time,
attr_time, checkpoint, extended_attr_icb, impl_ident, self.unique_id,
self.len_extended_attrs, len_alloc_descs) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.icb_tag = UDFICBTag()
self.icb_tag.parse(icb_tag)
if record_format != 0:
raise pycdlibexception.PyCdlibInvalidISO('File Entry record format is not 0')
if record_display_attrs != 0:
raise pycdlibexception.PyCdlibInvalidISO('File Entry record display attributes is not 0')
if record_len != 0:
raise pycdlibexception.PyCdlibInvalidISO('File Entry record length is not 0')
self.access_time = UDFTimestamp()
self.access_time.parse(access_time)
self.mod_time = UDFTimestamp()
self.mod_time.parse(mod_time)
self.attr_time = UDFTimestamp()
self.attr_time.parse(attr_time)
if checkpoint != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-only disks supported')
self.extended_attr_icb = UDFLongAD()
self.extended_attr_icb.parse(extended_attr_icb)
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
offset = struct.calcsize(self.FMT)
self.extended_attrs = data[offset:offset + self.len_extended_attrs]
offset += self.len_extended_attrs
num_alloc_descs = len_alloc_descs // 8 # a short_ad is 8 bytes
for i_unused in range(0, num_alloc_descs):
(length, pos) = struct.unpack('=LL', data[offset:offset + 8])
self.alloc_descs.append([length, pos])
offset += 8
self.orig_extent_loc = extent
self.parent = parent
self._initialized = True
|
python
|
def parse(self, data, extent, parent, desc_tag):
# type: (bytes, int, Optional[UDFFileEntry], UDFTag) -> None
'''
Parse the passed in data into a UDF File Entry.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
parent - The parent File Entry for this file (may be None).
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized')
(tag_unused, icb_tag, self.uid, self.gid, self.perms, self.file_link_count,
record_format, record_display_attrs, record_len,
self.info_len, self.log_block_recorded, access_time, mod_time,
attr_time, checkpoint, extended_attr_icb, impl_ident, self.unique_id,
self.len_extended_attrs, len_alloc_descs) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
self.icb_tag = UDFICBTag()
self.icb_tag.parse(icb_tag)
if record_format != 0:
raise pycdlibexception.PyCdlibInvalidISO('File Entry record format is not 0')
if record_display_attrs != 0:
raise pycdlibexception.PyCdlibInvalidISO('File Entry record display attributes is not 0')
if record_len != 0:
raise pycdlibexception.PyCdlibInvalidISO('File Entry record length is not 0')
self.access_time = UDFTimestamp()
self.access_time.parse(access_time)
self.mod_time = UDFTimestamp()
self.mod_time.parse(mod_time)
self.attr_time = UDFTimestamp()
self.attr_time.parse(attr_time)
if checkpoint != 1:
raise pycdlibexception.PyCdlibInvalidISO('Only DVD Read-only disks supported')
self.extended_attr_icb = UDFLongAD()
self.extended_attr_icb.parse(extended_attr_icb)
self.impl_ident = UDFEntityID()
self.impl_ident.parse(impl_ident)
offset = struct.calcsize(self.FMT)
self.extended_attrs = data[offset:offset + self.len_extended_attrs]
offset += self.len_extended_attrs
num_alloc_descs = len_alloc_descs // 8 # a short_ad is 8 bytes
for i_unused in range(0, num_alloc_descs):
(length, pos) = struct.unpack('=LL', data[offset:offset + 8])
self.alloc_descs.append([length, pos])
offset += 8
self.orig_extent_loc = extent
self.parent = parent
self._initialized = True
|
[
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"parent",
",",
"desc_tag",
")",
":",
"# type: (bytes, int, Optional[UDFFileEntry], UDFTag) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry already initialized'",
")",
"(",
"tag_unused",
",",
"icb_tag",
",",
"self",
".",
"uid",
",",
"self",
".",
"gid",
",",
"self",
".",
"perms",
",",
"self",
".",
"file_link_count",
",",
"record_format",
",",
"record_display_attrs",
",",
"record_len",
",",
"self",
".",
"info_len",
",",
"self",
".",
"log_block_recorded",
",",
"access_time",
",",
"mod_time",
",",
"attr_time",
",",
"checkpoint",
",",
"extended_attr_icb",
",",
"impl_ident",
",",
"self",
".",
"unique_id",
",",
"self",
".",
"len_extended_attrs",
",",
"len_alloc_descs",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"self",
".",
"icb_tag",
"=",
"UDFICBTag",
"(",
")",
"self",
".",
"icb_tag",
".",
"parse",
"(",
"icb_tag",
")",
"if",
"record_format",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'File Entry record format is not 0'",
")",
"if",
"record_display_attrs",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'File Entry record display attributes is not 0'",
")",
"if",
"record_len",
"!=",
"0",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'File Entry record length is not 0'",
")",
"self",
".",
"access_time",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"access_time",
".",
"parse",
"(",
"access_time",
")",
"self",
".",
"mod_time",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"mod_time",
".",
"parse",
"(",
"mod_time",
")",
"self",
".",
"attr_time",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"attr_time",
".",
"parse",
"(",
"attr_time",
")",
"if",
"checkpoint",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only DVD Read-only disks supported'",
")",
"self",
".",
"extended_attr_icb",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"extended_attr_icb",
".",
"parse",
"(",
"extended_attr_icb",
")",
"self",
".",
"impl_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"impl_ident",
".",
"parse",
"(",
"impl_ident",
")",
"offset",
"=",
"struct",
".",
"calcsize",
"(",
"self",
".",
"FMT",
")",
"self",
".",
"extended_attrs",
"=",
"data",
"[",
"offset",
":",
"offset",
"+",
"self",
".",
"len_extended_attrs",
"]",
"offset",
"+=",
"self",
".",
"len_extended_attrs",
"num_alloc_descs",
"=",
"len_alloc_descs",
"//",
"8",
"# a short_ad is 8 bytes",
"for",
"i_unused",
"in",
"range",
"(",
"0",
",",
"num_alloc_descs",
")",
":",
"(",
"length",
",",
"pos",
")",
"=",
"struct",
".",
"unpack",
"(",
"'=LL'",
",",
"data",
"[",
"offset",
":",
"offset",
"+",
"8",
"]",
")",
"self",
".",
"alloc_descs",
".",
"append",
"(",
"[",
"length",
",",
"pos",
"]",
")",
"offset",
"+=",
"8",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"_initialized",
"=",
"True"
] |
Parse the passed in data into a UDF File Entry.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
parent - The parent File Entry for this file (may be None).
desc_tag - A UDFTag object that represents the Descriptor Tag.
Returns:
Nothing.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"File",
"Entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2709-L2777
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Entry.
Parameters:
None.
Returns:
A string representing this UDF File Entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.icb_tag.record(), self.uid, self.gid,
self.perms, self.file_link_count, 0, 0, 0,
self.info_len, self.log_block_recorded,
self.access_time.record(), self.mod_time.record(),
self.attr_time.record(), 1,
self.extended_attr_icb.record(),
self.impl_ident.record(), self.unique_id,
self.len_extended_attrs, len(self.alloc_descs) * 8)[16:]
rec += self.extended_attrs
for length, pos in self.alloc_descs:
rec += struct.pack('=LL', length, pos)
return self.desc_tag.record(rec) + rec
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Entry.
Parameters:
None.
Returns:
A string representing this UDF File Entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.icb_tag.record(), self.uid, self.gid,
self.perms, self.file_link_count, 0, 0, 0,
self.info_len, self.log_block_recorded,
self.access_time.record(), self.mod_time.record(),
self.attr_time.record(), 1,
self.extended_attr_icb.record(),
self.impl_ident.record(), self.unique_id,
self.len_extended_attrs, len(self.alloc_descs) * 8)[16:]
rec += self.extended_attrs
for length, pos in self.alloc_descs:
rec += struct.pack('=LL', length, pos)
return self.desc_tag.record(rec) + rec
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"b'\\x00'",
"*",
"16",
",",
"self",
".",
"icb_tag",
".",
"record",
"(",
")",
",",
"self",
".",
"uid",
",",
"self",
".",
"gid",
",",
"self",
".",
"perms",
",",
"self",
".",
"file_link_count",
",",
"0",
",",
"0",
",",
"0",
",",
"self",
".",
"info_len",
",",
"self",
".",
"log_block_recorded",
",",
"self",
".",
"access_time",
".",
"record",
"(",
")",
",",
"self",
".",
"mod_time",
".",
"record",
"(",
")",
",",
"self",
".",
"attr_time",
".",
"record",
"(",
")",
",",
"1",
",",
"self",
".",
"extended_attr_icb",
".",
"record",
"(",
")",
",",
"self",
".",
"impl_ident",
".",
"record",
"(",
")",
",",
"self",
".",
"unique_id",
",",
"self",
".",
"len_extended_attrs",
",",
"len",
"(",
"self",
".",
"alloc_descs",
")",
"*",
"8",
")",
"[",
"16",
":",
"]",
"rec",
"+=",
"self",
".",
"extended_attrs",
"for",
"length",
",",
"pos",
"in",
"self",
".",
"alloc_descs",
":",
"rec",
"+=",
"struct",
".",
"pack",
"(",
"'=LL'",
",",
"length",
",",
"pos",
")",
"return",
"self",
".",
"desc_tag",
".",
"record",
"(",
"rec",
")",
"+",
"rec"
] |
A method to generate the string representing this UDF File Entry.
Parameters:
None.
Returns:
A string representing this UDF File Entry.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"File",
"Entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2779-L2805
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.new
|
def new(self, length, file_type, parent, log_block_size):
# type: (int, str, Optional[UDFFileEntry], int) -> None
'''
A method to create a new UDF File Entry.
Parameters:
length - The (starting) length of this UDF File Entry; this is ignored
if this is a symlink.
file_type - The type that this UDF File entry represents; one of 'dir', 'file', or 'symlink'.
parent - The parent UDF File Entry for this UDF File Entry.
log_block_size - The logical block size for extents.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized')
if file_type not in ('dir', 'file', 'symlink'):
raise pycdlibexception.PyCdlibInternalError("UDF File Entry file type must be one of 'dir', 'file', or 'symlink'")
self.desc_tag = UDFTag()
self.desc_tag.new(261) # FIXME: we should let the user set serial_number
self.icb_tag = UDFICBTag()
self.icb_tag.new(file_type)
self.uid = 4294967295 # Really -1, which means unset
self.gid = 4294967295 # Really -1, which means unset
if file_type == 'dir':
self.perms = 5285
self.file_link_count = 0
self.info_len = 0
self.log_block_recorded = 1
# The second field (position) is bogus, but will get set
# properly once reshuffle_extents is called.
self.alloc_descs.append([length, 0])
else:
self.perms = 4228
self.file_link_count = 1
self.info_len = length
self.log_block_recorded = utils.ceiling_div(length, log_block_size)
len_left = length
while len_left > 0:
# According to Ecma-167 14.14.1.1, the least-significant 30 bits
# of the allocation descriptor length field specify the length
# (the most significant two bits are properties which we don't
# currently support). In theory we should then split files
# into 2^30 = 0x40000000, but all implementations I've seen
# split it into smaller. cdrkit/cdrtools uses 0x3ffff800, and
# Windows uses 0x3ff00000. To be more compatible with cdrkit,
# we'll choose their number of 0x3ffff800.
alloc_len = min(len_left, 0x3ffff800)
# The second field (position) is bogus, but will get set
# properly once reshuffle_extents is called.
self.alloc_descs.append([alloc_len, 0])
len_left -= alloc_len
self.access_time = UDFTimestamp()
self.access_time.new()
self.mod_time = UDFTimestamp()
self.mod_time.new()
self.attr_time = UDFTimestamp()
self.attr_time.new()
self.extended_attr_icb = UDFLongAD()
self.extended_attr_icb.new(0, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.unique_id = 0 # this will get set later
self.len_extended_attrs = 0 # FIXME: let the user set this
self.extended_attrs = b''
self.parent = parent
self._initialized = True
|
python
|
def new(self, length, file_type, parent, log_block_size):
# type: (int, str, Optional[UDFFileEntry], int) -> None
'''
A method to create a new UDF File Entry.
Parameters:
length - The (starting) length of this UDF File Entry; this is ignored
if this is a symlink.
file_type - The type that this UDF File entry represents; one of 'dir', 'file', or 'symlink'.
parent - The parent UDF File Entry for this UDF File Entry.
log_block_size - The logical block size for extents.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry already initialized')
if file_type not in ('dir', 'file', 'symlink'):
raise pycdlibexception.PyCdlibInternalError("UDF File Entry file type must be one of 'dir', 'file', or 'symlink'")
self.desc_tag = UDFTag()
self.desc_tag.new(261) # FIXME: we should let the user set serial_number
self.icb_tag = UDFICBTag()
self.icb_tag.new(file_type)
self.uid = 4294967295 # Really -1, which means unset
self.gid = 4294967295 # Really -1, which means unset
if file_type == 'dir':
self.perms = 5285
self.file_link_count = 0
self.info_len = 0
self.log_block_recorded = 1
# The second field (position) is bogus, but will get set
# properly once reshuffle_extents is called.
self.alloc_descs.append([length, 0])
else:
self.perms = 4228
self.file_link_count = 1
self.info_len = length
self.log_block_recorded = utils.ceiling_div(length, log_block_size)
len_left = length
while len_left > 0:
# According to Ecma-167 14.14.1.1, the least-significant 30 bits
# of the allocation descriptor length field specify the length
# (the most significant two bits are properties which we don't
# currently support). In theory we should then split files
# into 2^30 = 0x40000000, but all implementations I've seen
# split it into smaller. cdrkit/cdrtools uses 0x3ffff800, and
# Windows uses 0x3ff00000. To be more compatible with cdrkit,
# we'll choose their number of 0x3ffff800.
alloc_len = min(len_left, 0x3ffff800)
# The second field (position) is bogus, but will get set
# properly once reshuffle_extents is called.
self.alloc_descs.append([alloc_len, 0])
len_left -= alloc_len
self.access_time = UDFTimestamp()
self.access_time.new()
self.mod_time = UDFTimestamp()
self.mod_time.new()
self.attr_time = UDFTimestamp()
self.attr_time.new()
self.extended_attr_icb = UDFLongAD()
self.extended_attr_icb.new(0, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.unique_id = 0 # this will get set later
self.len_extended_attrs = 0 # FIXME: let the user set this
self.extended_attrs = b''
self.parent = parent
self._initialized = True
|
[
"def",
"new",
"(",
"self",
",",
"length",
",",
"file_type",
",",
"parent",
",",
"log_block_size",
")",
":",
"# type: (int, str, Optional[UDFFileEntry], int) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry already initialized'",
")",
"if",
"file_type",
"not",
"in",
"(",
"'dir'",
",",
"'file'",
",",
"'symlink'",
")",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"\"UDF File Entry file type must be one of 'dir', 'file', or 'symlink'\"",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
"self",
".",
"desc_tag",
".",
"new",
"(",
"261",
")",
"# FIXME: we should let the user set serial_number",
"self",
".",
"icb_tag",
"=",
"UDFICBTag",
"(",
")",
"self",
".",
"icb_tag",
".",
"new",
"(",
"file_type",
")",
"self",
".",
"uid",
"=",
"4294967295",
"# Really -1, which means unset",
"self",
".",
"gid",
"=",
"4294967295",
"# Really -1, which means unset",
"if",
"file_type",
"==",
"'dir'",
":",
"self",
".",
"perms",
"=",
"5285",
"self",
".",
"file_link_count",
"=",
"0",
"self",
".",
"info_len",
"=",
"0",
"self",
".",
"log_block_recorded",
"=",
"1",
"# The second field (position) is bogus, but will get set",
"# properly once reshuffle_extents is called.",
"self",
".",
"alloc_descs",
".",
"append",
"(",
"[",
"length",
",",
"0",
"]",
")",
"else",
":",
"self",
".",
"perms",
"=",
"4228",
"self",
".",
"file_link_count",
"=",
"1",
"self",
".",
"info_len",
"=",
"length",
"self",
".",
"log_block_recorded",
"=",
"utils",
".",
"ceiling_div",
"(",
"length",
",",
"log_block_size",
")",
"len_left",
"=",
"length",
"while",
"len_left",
">",
"0",
":",
"# According to Ecma-167 14.14.1.1, the least-significant 30 bits",
"# of the allocation descriptor length field specify the length",
"# (the most significant two bits are properties which we don't",
"# currently support). In theory we should then split files",
"# into 2^30 = 0x40000000, but all implementations I've seen",
"# split it into smaller. cdrkit/cdrtools uses 0x3ffff800, and",
"# Windows uses 0x3ff00000. To be more compatible with cdrkit,",
"# we'll choose their number of 0x3ffff800.",
"alloc_len",
"=",
"min",
"(",
"len_left",
",",
"0x3ffff800",
")",
"# The second field (position) is bogus, but will get set",
"# properly once reshuffle_extents is called.",
"self",
".",
"alloc_descs",
".",
"append",
"(",
"[",
"alloc_len",
",",
"0",
"]",
")",
"len_left",
"-=",
"alloc_len",
"self",
".",
"access_time",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"access_time",
".",
"new",
"(",
")",
"self",
".",
"mod_time",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"mod_time",
".",
"new",
"(",
")",
"self",
".",
"attr_time",
"=",
"UDFTimestamp",
"(",
")",
"self",
".",
"attr_time",
".",
"new",
"(",
")",
"self",
".",
"extended_attr_icb",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"extended_attr_icb",
".",
"new",
"(",
"0",
",",
"0",
")",
"self",
".",
"impl_ident",
"=",
"UDFEntityID",
"(",
")",
"self",
".",
"impl_ident",
".",
"new",
"(",
"0",
",",
"b'*pycdlib'",
")",
"self",
".",
"unique_id",
"=",
"0",
"# this will get set later",
"self",
".",
"len_extended_attrs",
"=",
"0",
"# FIXME: let the user set this",
"self",
".",
"extended_attrs",
"=",
"b''",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF File Entry.
Parameters:
length - The (starting) length of this UDF File Entry; this is ignored
if this is a symlink.
file_type - The type that this UDF File entry represents; one of 'dir', 'file', or 'symlink'.
parent - The parent UDF File Entry for this UDF File Entry.
log_block_size - The logical block size for extents.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"File",
"Entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2824-L2903
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.add_file_ident_desc
|
def add_file_ident_desc(self, new_fi_desc, logical_block_size):
# type: (UDFFileIdentifierDescriptor, int) -> int
'''
A method to add a new UDF File Identifier Descriptor to this UDF File
Entry.
Parameters:
new_fi_desc - The new UDF File Identifier Descriptor to add.
logical_block_size - The logical block size to use.
Returns:
The number of extents added due to adding this File Identifier Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.icb_tag.file_type != 4:
raise pycdlibexception.PyCdlibInvalidInput('Can only add a UDF File Identifier to a directory')
self.fi_descs.append(new_fi_desc)
num_bytes_to_add = UDFFileIdentifierDescriptor.length(len(new_fi_desc.fi))
old_num_extents = 0
# If info_len is 0, then this is a brand-new File Entry, and thus the
# number of extents it is using is 0.
if self.info_len > 0:
old_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.info_len += num_bytes_to_add
new_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.log_block_recorded = new_num_extents
self.alloc_descs[0][0] = self.info_len
if new_fi_desc.is_dir():
self.file_link_count += 1
return new_num_extents - old_num_extents
|
python
|
def add_file_ident_desc(self, new_fi_desc, logical_block_size):
# type: (UDFFileIdentifierDescriptor, int) -> int
'''
A method to add a new UDF File Identifier Descriptor to this UDF File
Entry.
Parameters:
new_fi_desc - The new UDF File Identifier Descriptor to add.
logical_block_size - The logical block size to use.
Returns:
The number of extents added due to adding this File Identifier Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.icb_tag.file_type != 4:
raise pycdlibexception.PyCdlibInvalidInput('Can only add a UDF File Identifier to a directory')
self.fi_descs.append(new_fi_desc)
num_bytes_to_add = UDFFileIdentifierDescriptor.length(len(new_fi_desc.fi))
old_num_extents = 0
# If info_len is 0, then this is a brand-new File Entry, and thus the
# number of extents it is using is 0.
if self.info_len > 0:
old_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.info_len += num_bytes_to_add
new_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.log_block_recorded = new_num_extents
self.alloc_descs[0][0] = self.info_len
if new_fi_desc.is_dir():
self.file_link_count += 1
return new_num_extents - old_num_extents
|
[
"def",
"add_file_ident_desc",
"(",
"self",
",",
"new_fi_desc",
",",
"logical_block_size",
")",
":",
"# type: (UDFFileIdentifierDescriptor, int) -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"if",
"self",
".",
"icb_tag",
".",
"file_type",
"!=",
"4",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Can only add a UDF File Identifier to a directory'",
")",
"self",
".",
"fi_descs",
".",
"append",
"(",
"new_fi_desc",
")",
"num_bytes_to_add",
"=",
"UDFFileIdentifierDescriptor",
".",
"length",
"(",
"len",
"(",
"new_fi_desc",
".",
"fi",
")",
")",
"old_num_extents",
"=",
"0",
"# If info_len is 0, then this is a brand-new File Entry, and thus the",
"# number of extents it is using is 0.",
"if",
"self",
".",
"info_len",
">",
"0",
":",
"old_num_extents",
"=",
"utils",
".",
"ceiling_div",
"(",
"self",
".",
"info_len",
",",
"logical_block_size",
")",
"self",
".",
"info_len",
"+=",
"num_bytes_to_add",
"new_num_extents",
"=",
"utils",
".",
"ceiling_div",
"(",
"self",
".",
"info_len",
",",
"logical_block_size",
")",
"self",
".",
"log_block_recorded",
"=",
"new_num_extents",
"self",
".",
"alloc_descs",
"[",
"0",
"]",
"[",
"0",
"]",
"=",
"self",
".",
"info_len",
"if",
"new_fi_desc",
".",
"is_dir",
"(",
")",
":",
"self",
".",
"file_link_count",
"+=",
"1",
"return",
"new_num_extents",
"-",
"old_num_extents"
] |
A method to add a new UDF File Identifier Descriptor to this UDF File
Entry.
Parameters:
new_fi_desc - The new UDF File Identifier Descriptor to add.
logical_block_size - The logical block size to use.
Returns:
The number of extents added due to adding this File Identifier Descriptor.
|
[
"A",
"method",
"to",
"add",
"a",
"new",
"UDF",
"File",
"Identifier",
"Descriptor",
"to",
"this",
"UDF",
"File",
"Entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2923-L2960
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.remove_file_ident_desc_by_name
|
def remove_file_ident_desc_by_name(self, name, logical_block_size):
# type: (bytes, int) -> int
'''
A method to remove a UDF File Identifier Descriptor from this UDF File
Entry.
Parameters:
name - The name of the UDF File Identifier Descriptor to remove.
logical_block_size - The logical block size to use.
Returns:
The number of extents removed due to removing this File Identifier Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
tmp_fi_desc = UDFFileIdentifierDescriptor()
tmp_fi_desc.isparent = False
tmp_fi_desc.fi = name
# If flags bit 3 is set, the entries are sorted.
desc_index = len(self.fi_descs)
for index, fi_desc in enumerate(self.fi_descs):
if fi_desc.fi == name:
desc_index = index
break
if desc_index == len(self.fi_descs) or self.fi_descs[desc_index].fi != name:
raise pycdlibexception.PyCdlibInvalidInput('Cannot find file to remove')
this_desc = self.fi_descs[desc_index]
if this_desc.is_dir():
if this_desc.file_entry is None:
raise pycdlibexception.PyCdlibInternalError('No UDF File Entry for UDF File Descriptor')
if len(this_desc.file_entry.fi_descs) > 1:
raise pycdlibexception.PyCdlibInvalidInput('Directory must be empty to use rm_directory')
self.file_link_count -= 1
old_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.info_len -= UDFFileIdentifierDescriptor.length(len(this_desc.fi))
new_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.alloc_descs[0][0] = self.info_len
del self.fi_descs[desc_index]
return old_num_extents - new_num_extents
|
python
|
def remove_file_ident_desc_by_name(self, name, logical_block_size):
# type: (bytes, int) -> int
'''
A method to remove a UDF File Identifier Descriptor from this UDF File
Entry.
Parameters:
name - The name of the UDF File Identifier Descriptor to remove.
logical_block_size - The logical block size to use.
Returns:
The number of extents removed due to removing this File Identifier Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
tmp_fi_desc = UDFFileIdentifierDescriptor()
tmp_fi_desc.isparent = False
tmp_fi_desc.fi = name
# If flags bit 3 is set, the entries are sorted.
desc_index = len(self.fi_descs)
for index, fi_desc in enumerate(self.fi_descs):
if fi_desc.fi == name:
desc_index = index
break
if desc_index == len(self.fi_descs) or self.fi_descs[desc_index].fi != name:
raise pycdlibexception.PyCdlibInvalidInput('Cannot find file to remove')
this_desc = self.fi_descs[desc_index]
if this_desc.is_dir():
if this_desc.file_entry is None:
raise pycdlibexception.PyCdlibInternalError('No UDF File Entry for UDF File Descriptor')
if len(this_desc.file_entry.fi_descs) > 1:
raise pycdlibexception.PyCdlibInvalidInput('Directory must be empty to use rm_directory')
self.file_link_count -= 1
old_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.info_len -= UDFFileIdentifierDescriptor.length(len(this_desc.fi))
new_num_extents = utils.ceiling_div(self.info_len, logical_block_size)
self.alloc_descs[0][0] = self.info_len
del self.fi_descs[desc_index]
return old_num_extents - new_num_extents
|
[
"def",
"remove_file_ident_desc_by_name",
"(",
"self",
",",
"name",
",",
"logical_block_size",
")",
":",
"# type: (bytes, int) -> int",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"tmp_fi_desc",
"=",
"UDFFileIdentifierDescriptor",
"(",
")",
"tmp_fi_desc",
".",
"isparent",
"=",
"False",
"tmp_fi_desc",
".",
"fi",
"=",
"name",
"# If flags bit 3 is set, the entries are sorted.",
"desc_index",
"=",
"len",
"(",
"self",
".",
"fi_descs",
")",
"for",
"index",
",",
"fi_desc",
"in",
"enumerate",
"(",
"self",
".",
"fi_descs",
")",
":",
"if",
"fi_desc",
".",
"fi",
"==",
"name",
":",
"desc_index",
"=",
"index",
"break",
"if",
"desc_index",
"==",
"len",
"(",
"self",
".",
"fi_descs",
")",
"or",
"self",
".",
"fi_descs",
"[",
"desc_index",
"]",
".",
"fi",
"!=",
"name",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Cannot find file to remove'",
")",
"this_desc",
"=",
"self",
".",
"fi_descs",
"[",
"desc_index",
"]",
"if",
"this_desc",
".",
"is_dir",
"(",
")",
":",
"if",
"this_desc",
".",
"file_entry",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'No UDF File Entry for UDF File Descriptor'",
")",
"if",
"len",
"(",
"this_desc",
".",
"file_entry",
".",
"fi_descs",
")",
">",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Directory must be empty to use rm_directory'",
")",
"self",
".",
"file_link_count",
"-=",
"1",
"old_num_extents",
"=",
"utils",
".",
"ceiling_div",
"(",
"self",
".",
"info_len",
",",
"logical_block_size",
")",
"self",
".",
"info_len",
"-=",
"UDFFileIdentifierDescriptor",
".",
"length",
"(",
"len",
"(",
"this_desc",
".",
"fi",
")",
")",
"new_num_extents",
"=",
"utils",
".",
"ceiling_div",
"(",
"self",
".",
"info_len",
",",
"logical_block_size",
")",
"self",
".",
"alloc_descs",
"[",
"0",
"]",
"[",
"0",
"]",
"=",
"self",
".",
"info_len",
"del",
"self",
".",
"fi_descs",
"[",
"desc_index",
"]",
"return",
"old_num_extents",
"-",
"new_num_extents"
] |
A method to remove a UDF File Identifier Descriptor from this UDF File
Entry.
Parameters:
name - The name of the UDF File Identifier Descriptor to remove.
logical_block_size - The logical block size to use.
Returns:
The number of extents removed due to removing this File Identifier Descriptor.
|
[
"A",
"method",
"to",
"remove",
"a",
"UDF",
"File",
"Identifier",
"Descriptor",
"from",
"this",
"UDF",
"File",
"Entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2962-L3005
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.set_data_location
|
def set_data_location(self, current_extent, start_extent): # pylint: disable=unused-argument
# type: (int, int) -> None
'''
A method to set the location of the data that this UDF File Entry
points to.
Parameters:
current_extent - Unused
start_extent - The starting extent for this data location.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
current_assignment = start_extent
for index, desc_unused in enumerate(self.alloc_descs):
self.alloc_descs[index][1] = current_assignment
current_assignment += 1
|
python
|
def set_data_location(self, current_extent, start_extent): # pylint: disable=unused-argument
# type: (int, int) -> None
'''
A method to set the location of the data that this UDF File Entry
points to.
Parameters:
current_extent - Unused
start_extent - The starting extent for this data location.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
current_assignment = start_extent
for index, desc_unused in enumerate(self.alloc_descs):
self.alloc_descs[index][1] = current_assignment
current_assignment += 1
|
[
"def",
"set_data_location",
"(",
"self",
",",
"current_extent",
",",
"start_extent",
")",
":",
"# pylint: disable=unused-argument",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"current_assignment",
"=",
"start_extent",
"for",
"index",
",",
"desc_unused",
"in",
"enumerate",
"(",
"self",
".",
"alloc_descs",
")",
":",
"self",
".",
"alloc_descs",
"[",
"index",
"]",
"[",
"1",
"]",
"=",
"current_assignment",
"current_assignment",
"+=",
"1"
] |
A method to set the location of the data that this UDF File Entry
points to.
Parameters:
current_extent - Unused
start_extent - The starting extent for this data location.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"the",
"data",
"that",
"this",
"UDF",
"File",
"Entry",
"points",
"to",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3007-L3025
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.set_data_length
|
def set_data_length(self, length):
# type: (int) -> None
'''
A method to set the length of the data that this UDF File Entry
points to.
Parameters:
length - The new length for the data.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized')
len_diff = length - self.info_len
if len_diff > 0:
# If we are increasing the length, update the last alloc_desc up
# to the max of 0x3ffff800, and throw an exception if we overflow.
new_len = self.alloc_descs[-1][0] + len_diff
if new_len > 0x3ffff800:
raise pycdlibexception.PyCdlibInvalidInput('Cannot increase the size of a UDF file beyond the current descriptor')
self.alloc_descs[-1][0] = new_len
elif len_diff < 0:
# We are decreasing the length. It's possible we are removing one
# or more alloc_descs, so run through the list updating all of the
# descriptors and remove any we no longer need.
len_left = length
alloc_descs_needed = 0
index = 0
while len_left > 0:
this_len = min(len_left, 0x3ffff800)
alloc_descs_needed += 1
self.alloc_descs[index][0] = this_len
index += 1
len_left -= this_len
self.alloc_descs = self.alloc_descs[:alloc_descs_needed]
self.info_len = length
|
python
|
def set_data_length(self, length):
# type: (int) -> None
'''
A method to set the length of the data that this UDF File Entry
points to.
Parameters:
length - The new length for the data.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized')
len_diff = length - self.info_len
if len_diff > 0:
# If we are increasing the length, update the last alloc_desc up
# to the max of 0x3ffff800, and throw an exception if we overflow.
new_len = self.alloc_descs[-1][0] + len_diff
if new_len > 0x3ffff800:
raise pycdlibexception.PyCdlibInvalidInput('Cannot increase the size of a UDF file beyond the current descriptor')
self.alloc_descs[-1][0] = new_len
elif len_diff < 0:
# We are decreasing the length. It's possible we are removing one
# or more alloc_descs, so run through the list updating all of the
# descriptors and remove any we no longer need.
len_left = length
alloc_descs_needed = 0
index = 0
while len_left > 0:
this_len = min(len_left, 0x3ffff800)
alloc_descs_needed += 1
self.alloc_descs[index][0] = this_len
index += 1
len_left -= this_len
self.alloc_descs = self.alloc_descs[:alloc_descs_needed]
self.info_len = length
|
[
"def",
"set_data_length",
"(",
"self",
",",
"length",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Directory Record not yet initialized'",
")",
"len_diff",
"=",
"length",
"-",
"self",
".",
"info_len",
"if",
"len_diff",
">",
"0",
":",
"# If we are increasing the length, update the last alloc_desc up",
"# to the max of 0x3ffff800, and throw an exception if we overflow.",
"new_len",
"=",
"self",
".",
"alloc_descs",
"[",
"-",
"1",
"]",
"[",
"0",
"]",
"+",
"len_diff",
"if",
"new_len",
">",
"0x3ffff800",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Cannot increase the size of a UDF file beyond the current descriptor'",
")",
"self",
".",
"alloc_descs",
"[",
"-",
"1",
"]",
"[",
"0",
"]",
"=",
"new_len",
"elif",
"len_diff",
"<",
"0",
":",
"# We are decreasing the length. It's possible we are removing one",
"# or more alloc_descs, so run through the list updating all of the",
"# descriptors and remove any we no longer need.",
"len_left",
"=",
"length",
"alloc_descs_needed",
"=",
"0",
"index",
"=",
"0",
"while",
"len_left",
">",
"0",
":",
"this_len",
"=",
"min",
"(",
"len_left",
",",
"0x3ffff800",
")",
"alloc_descs_needed",
"+=",
"1",
"self",
".",
"alloc_descs",
"[",
"index",
"]",
"[",
"0",
"]",
"=",
"this_len",
"index",
"+=",
"1",
"len_left",
"-=",
"this_len",
"self",
".",
"alloc_descs",
"=",
"self",
".",
"alloc_descs",
"[",
":",
"alloc_descs_needed",
"]",
"self",
".",
"info_len",
"=",
"length"
] |
A method to set the length of the data that this UDF File Entry
points to.
Parameters:
length - The new length for the data.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"length",
"of",
"the",
"data",
"that",
"this",
"UDF",
"File",
"Entry",
"points",
"to",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3042-L3080
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.file_identifier
|
def file_identifier(self):
# type: () -> bytes
'''
A method to get the name of this UDF File Entry as a byte string.
Parameters:
None.
Returns:
The UDF File Entry as a byte string.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.file_ident is None:
return b'/'
return self.file_ident.fi
|
python
|
def file_identifier(self):
# type: () -> bytes
'''
A method to get the name of this UDF File Entry as a byte string.
Parameters:
None.
Returns:
The UDF File Entry as a byte string.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.file_ident is None:
return b'/'
return self.file_ident.fi
|
[
"def",
"file_identifier",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"if",
"self",
".",
"file_ident",
"is",
"None",
":",
"return",
"b'/'",
"return",
"self",
".",
"file_ident",
".",
"fi"
] |
A method to get the name of this UDF File Entry as a byte string.
Parameters:
None.
Returns:
The UDF File Entry as a byte string.
|
[
"A",
"method",
"to",
"get",
"the",
"name",
"of",
"this",
"UDF",
"File",
"Entry",
"as",
"a",
"byte",
"string",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3124-L3140
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.find_file_ident_desc_by_name
|
def find_file_ident_desc_by_name(self, currpath):
# type: (bytes) -> UDFFileIdentifierDescriptor
'''
A method to find a UDF File Identifier descriptor by its name.
Parameters:
currpath - The UTF-8 encoded name to look up.
Returns:
The UDF File Identifier descriptor corresponding to the passed in name.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
# If this is a directory or it is an empty directory, just skip
# all work.
if self.icb_tag.file_type != 4 or not self.fi_descs:
raise pycdlibexception.PyCdlibInvalidInput('Could not find path')
tmp = currpath.decode('utf-8')
try:
latin1_currpath = tmp.encode('latin-1')
except (UnicodeDecodeError, UnicodeEncodeError):
latin1_currpath = b''
ucs2_currpath = tmp.encode('utf-16_be')
child = None
for fi_desc in self.fi_descs:
if latin1_currpath and fi_desc.encoding == 'latin-1':
eq = fi_desc.fi == latin1_currpath
else:
eq = fi_desc.fi == ucs2_currpath
if eq:
child = fi_desc
break
if child is None:
raise pycdlibexception.PyCdlibInvalidInput('Could not find path')
return child
|
python
|
def find_file_ident_desc_by_name(self, currpath):
# type: (bytes) -> UDFFileIdentifierDescriptor
'''
A method to find a UDF File Identifier descriptor by its name.
Parameters:
currpath - The UTF-8 encoded name to look up.
Returns:
The UDF File Identifier descriptor corresponding to the passed in name.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
# If this is a directory or it is an empty directory, just skip
# all work.
if self.icb_tag.file_type != 4 or not self.fi_descs:
raise pycdlibexception.PyCdlibInvalidInput('Could not find path')
tmp = currpath.decode('utf-8')
try:
latin1_currpath = tmp.encode('latin-1')
except (UnicodeDecodeError, UnicodeEncodeError):
latin1_currpath = b''
ucs2_currpath = tmp.encode('utf-16_be')
child = None
for fi_desc in self.fi_descs:
if latin1_currpath and fi_desc.encoding == 'latin-1':
eq = fi_desc.fi == latin1_currpath
else:
eq = fi_desc.fi == ucs2_currpath
if eq:
child = fi_desc
break
if child is None:
raise pycdlibexception.PyCdlibInvalidInput('Could not find path')
return child
|
[
"def",
"find_file_ident_desc_by_name",
"(",
"self",
",",
"currpath",
")",
":",
"# type: (bytes) -> UDFFileIdentifierDescriptor",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"# If this is a directory or it is an empty directory, just skip",
"# all work.",
"if",
"self",
".",
"icb_tag",
".",
"file_type",
"!=",
"4",
"or",
"not",
"self",
".",
"fi_descs",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Could not find path'",
")",
"tmp",
"=",
"currpath",
".",
"decode",
"(",
"'utf-8'",
")",
"try",
":",
"latin1_currpath",
"=",
"tmp",
".",
"encode",
"(",
"'latin-1'",
")",
"except",
"(",
"UnicodeDecodeError",
",",
"UnicodeEncodeError",
")",
":",
"latin1_currpath",
"=",
"b''",
"ucs2_currpath",
"=",
"tmp",
".",
"encode",
"(",
"'utf-16_be'",
")",
"child",
"=",
"None",
"for",
"fi_desc",
"in",
"self",
".",
"fi_descs",
":",
"if",
"latin1_currpath",
"and",
"fi_desc",
".",
"encoding",
"==",
"'latin-1'",
":",
"eq",
"=",
"fi_desc",
".",
"fi",
"==",
"latin1_currpath",
"else",
":",
"eq",
"=",
"fi_desc",
".",
"fi",
"==",
"ucs2_currpath",
"if",
"eq",
":",
"child",
"=",
"fi_desc",
"break",
"if",
"child",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Could not find path'",
")",
"return",
"child"
] |
A method to find a UDF File Identifier descriptor by its name.
Parameters:
currpath - The UTF-8 encoded name to look up.
Returns:
The UDF File Identifier descriptor corresponding to the passed in name.
|
[
"A",
"method",
"to",
"find",
"a",
"UDF",
"File",
"Identifier",
"descriptor",
"by",
"its",
"name",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3142-L3182
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.track_file_ident_desc
|
def track_file_ident_desc(self, file_ident):
# type: (UDFFileIdentifierDescriptor) -> None
'''
A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
self.fi_descs.append(file_ident)
|
python
|
def track_file_ident_desc(self, file_ident):
# type: (UDFFileIdentifierDescriptor) -> None
'''
A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
self.fi_descs.append(file_ident)
|
[
"def",
"track_file_ident_desc",
"(",
"self",
",",
"file_ident",
")",
":",
"# type: (UDFFileIdentifierDescriptor) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"self",
".",
"fi_descs",
".",
"append",
"(",
"file_ident",
")"
] |
A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"start",
"tracking",
"a",
"UDF",
"File",
"Identifier",
"descriptor",
"in",
"this",
"UDF",
"File",
"Entry",
".",
"Both",
"tracking",
"and",
"addition",
"add",
"the",
"identifier",
"to",
"the",
"list",
"of",
"file",
"identifiers",
"but",
"tracking",
"doees",
"not",
"expand",
"or",
"otherwise",
"modify",
"the",
"UDF",
"File",
"Entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3184-L3200
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileEntry.finish_directory_parse
|
def finish_directory_parse(self):
# type: () -> None
'''
A method to finish up the parsing of this UDF File Entry directory.
In particular, this method checks to see if it is in sorted order for
future use.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.icb_tag.file_type != 4:
raise pycdlibexception.PyCdlibInternalError('Can only finish_directory for a directory')
|
python
|
def finish_directory_parse(self):
# type: () -> None
'''
A method to finish up the parsing of this UDF File Entry directory.
In particular, this method checks to see if it is in sorted order for
future use.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
if self.icb_tag.file_type != 4:
raise pycdlibexception.PyCdlibInternalError('Can only finish_directory for a directory')
|
[
"def",
"finish_directory_parse",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"if",
"self",
".",
"icb_tag",
".",
"file_type",
"!=",
"4",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Can only finish_directory for a directory'",
")"
] |
A method to finish up the parsing of this UDF File Entry directory.
In particular, this method checks to see if it is in sorted order for
future use.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"finish",
"up",
"the",
"parsing",
"of",
"this",
"UDF",
"File",
"Entry",
"directory",
".",
"In",
"particular",
"this",
"method",
"checks",
"to",
"see",
"if",
"it",
"is",
"in",
"sorted",
"order",
"for",
"future",
"use",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3202-L3218
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileIdentifierDescriptor.length
|
def length(cls, namelen):
# type: (Type[UDFFileIdentifierDescriptor], int) -> int
'''
A class method to calculate the size this UDFFileIdentifierDescriptor
would take up.
Parameters:
cls - The class to use (always UDFFileIdentifierDescriptor).
namelen - The length of the name.
Returns:
The length that the UDFFileIdentifierDescriptor would take up.
'''
if namelen > 0:
namelen += 1
to_add = struct.calcsize(cls.FMT) + namelen
return to_add + UDFFileIdentifierDescriptor.pad(to_add)
|
python
|
def length(cls, namelen):
# type: (Type[UDFFileIdentifierDescriptor], int) -> int
'''
A class method to calculate the size this UDFFileIdentifierDescriptor
would take up.
Parameters:
cls - The class to use (always UDFFileIdentifierDescriptor).
namelen - The length of the name.
Returns:
The length that the UDFFileIdentifierDescriptor would take up.
'''
if namelen > 0:
namelen += 1
to_add = struct.calcsize(cls.FMT) + namelen
return to_add + UDFFileIdentifierDescriptor.pad(to_add)
|
[
"def",
"length",
"(",
"cls",
",",
"namelen",
")",
":",
"# type: (Type[UDFFileIdentifierDescriptor], int) -> int",
"if",
"namelen",
">",
"0",
":",
"namelen",
"+=",
"1",
"to_add",
"=",
"struct",
".",
"calcsize",
"(",
"cls",
".",
"FMT",
")",
"+",
"namelen",
"return",
"to_add",
"+",
"UDFFileIdentifierDescriptor",
".",
"pad",
"(",
"to_add",
")"
] |
A class method to calculate the size this UDFFileIdentifierDescriptor
would take up.
Parameters:
cls - The class to use (always UDFFileIdentifierDescriptor).
namelen - The length of the name.
Returns:
The length that the UDFFileIdentifierDescriptor would take up.
|
[
"A",
"class",
"method",
"to",
"calculate",
"the",
"size",
"this",
"UDFFileIdentifierDescriptor",
"would",
"take",
"up",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3276-L3291
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileIdentifierDescriptor.parse
|
def parse(self, data, extent, desc_tag, parent):
# type: (bytes, int, UDFTag, UDFFileEntry) -> int
'''
Parse the passed in data into a UDF File Identifier Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
parent - The UDF File Entry representing the parent.
Returns:
The number of bytes this descriptor consumed.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor already initialized')
(tag_unused, file_version_num, self.file_characteristics,
self.len_fi, icb, self.len_impl_use) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if file_version_num != 1:
raise pycdlibexception.PyCdlibInvalidISO('File Identifier Descriptor file version number not 1')
if self.file_characteristics & 0x2:
self.isdir = True
if self.file_characteristics & 0x8:
self.isparent = True
self.icb = UDFLongAD()
self.icb.parse(icb)
start = struct.calcsize(self.FMT)
end = start + self.len_impl_use
self.impl_use = data[start:end]
start = end
end = start + self.len_fi
# The very first byte of the File Identifier describes whether this is
# an 8-bit or 16-bit encoded string; this corresponds to whether we
# encode with 'latin-1' or with 'utf-16_be'. We save that off because we have
# to write the correct thing out when we record.
if not self.isparent:
encoding = bytes(bytearray([data[start]]))
if encoding == b'\x08':
self.encoding = 'latin-1'
elif encoding == b'\x10':
self.encoding = 'utf-16_be'
else:
raise pycdlibexception.PyCdlibInvalidISO('Only UDF File Identifier Descriptor Encodings 8 or 16 are supported')
start += 1
self.fi = data[start:end]
self.orig_extent_loc = extent
self.parent = parent
self._initialized = True
return end + UDFFileIdentifierDescriptor.pad(end)
|
python
|
def parse(self, data, extent, desc_tag, parent):
# type: (bytes, int, UDFTag, UDFFileEntry) -> int
'''
Parse the passed in data into a UDF File Identifier Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
parent - The UDF File Entry representing the parent.
Returns:
The number of bytes this descriptor consumed.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor already initialized')
(tag_unused, file_version_num, self.file_characteristics,
self.len_fi, icb, self.len_impl_use) = struct.unpack_from(self.FMT, data, 0)
self.desc_tag = desc_tag
if file_version_num != 1:
raise pycdlibexception.PyCdlibInvalidISO('File Identifier Descriptor file version number not 1')
if self.file_characteristics & 0x2:
self.isdir = True
if self.file_characteristics & 0x8:
self.isparent = True
self.icb = UDFLongAD()
self.icb.parse(icb)
start = struct.calcsize(self.FMT)
end = start + self.len_impl_use
self.impl_use = data[start:end]
start = end
end = start + self.len_fi
# The very first byte of the File Identifier describes whether this is
# an 8-bit or 16-bit encoded string; this corresponds to whether we
# encode with 'latin-1' or with 'utf-16_be'. We save that off because we have
# to write the correct thing out when we record.
if not self.isparent:
encoding = bytes(bytearray([data[start]]))
if encoding == b'\x08':
self.encoding = 'latin-1'
elif encoding == b'\x10':
self.encoding = 'utf-16_be'
else:
raise pycdlibexception.PyCdlibInvalidISO('Only UDF File Identifier Descriptor Encodings 8 or 16 are supported')
start += 1
self.fi = data[start:end]
self.orig_extent_loc = extent
self.parent = parent
self._initialized = True
return end + UDFFileIdentifierDescriptor.pad(end)
|
[
"def",
"parse",
"(",
"self",
",",
"data",
",",
"extent",
",",
"desc_tag",
",",
"parent",
")",
":",
"# type: (bytes, int, UDFTag, UDFFileEntry) -> int",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Identifier Descriptor already initialized'",
")",
"(",
"tag_unused",
",",
"file_version_num",
",",
"self",
".",
"file_characteristics",
",",
"self",
".",
"len_fi",
",",
"icb",
",",
"self",
".",
"len_impl_use",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"self",
".",
"FMT",
",",
"data",
",",
"0",
")",
"self",
".",
"desc_tag",
"=",
"desc_tag",
"if",
"file_version_num",
"!=",
"1",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'File Identifier Descriptor file version number not 1'",
")",
"if",
"self",
".",
"file_characteristics",
"&",
"0x2",
":",
"self",
".",
"isdir",
"=",
"True",
"if",
"self",
".",
"file_characteristics",
"&",
"0x8",
":",
"self",
".",
"isparent",
"=",
"True",
"self",
".",
"icb",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"icb",
".",
"parse",
"(",
"icb",
")",
"start",
"=",
"struct",
".",
"calcsize",
"(",
"self",
".",
"FMT",
")",
"end",
"=",
"start",
"+",
"self",
".",
"len_impl_use",
"self",
".",
"impl_use",
"=",
"data",
"[",
"start",
":",
"end",
"]",
"start",
"=",
"end",
"end",
"=",
"start",
"+",
"self",
".",
"len_fi",
"# The very first byte of the File Identifier describes whether this is",
"# an 8-bit or 16-bit encoded string; this corresponds to whether we",
"# encode with 'latin-1' or with 'utf-16_be'. We save that off because we have",
"# to write the correct thing out when we record.",
"if",
"not",
"self",
".",
"isparent",
":",
"encoding",
"=",
"bytes",
"(",
"bytearray",
"(",
"[",
"data",
"[",
"start",
"]",
"]",
")",
")",
"if",
"encoding",
"==",
"b'\\x08'",
":",
"self",
".",
"encoding",
"=",
"'latin-1'",
"elif",
"encoding",
"==",
"b'\\x10'",
":",
"self",
".",
"encoding",
"=",
"'utf-16_be'",
"else",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Only UDF File Identifier Descriptor Encodings 8 or 16 are supported'",
")",
"start",
"+=",
"1",
"self",
".",
"fi",
"=",
"data",
"[",
"start",
":",
"end",
"]",
"self",
".",
"orig_extent_loc",
"=",
"extent",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"_initialized",
"=",
"True",
"return",
"end",
"+",
"UDFFileIdentifierDescriptor",
".",
"pad",
"(",
"end",
")"
] |
Parse the passed in data into a UDF File Identifier Descriptor.
Parameters:
data - The data to parse.
extent - The extent that this descriptor currently lives at.
desc_tag - A UDFTag object that represents the Descriptor Tag.
parent - The UDF File Entry representing the parent.
Returns:
The number of bytes this descriptor consumed.
|
[
"Parse",
"the",
"passed",
"in",
"data",
"into",
"a",
"UDF",
"File",
"Identifier",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3309-L3371
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileIdentifierDescriptor.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Identifier Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Identifier Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor not initialized')
if self.len_fi > 0:
if self.encoding == 'latin-1':
prefix = b'\x08'
elif self.encoding == 'utf-16_be':
prefix = b'\x10'
else:
raise pycdlibexception.PyCdlibInternalError('Invalid UDF encoding; this should not happen')
fi = prefix + self.fi
else:
fi = b''
rec = struct.pack(self.FMT, b'\x00' * 16, 1,
self.file_characteristics, self.len_fi,
self.icb.record(),
self.len_impl_use) + self.impl_use + fi + b'\x00' * UDFFileIdentifierDescriptor.pad(struct.calcsize(self.FMT) + self.len_impl_use + self.len_fi)
return self.desc_tag.record(rec[16:]) + rec[16:]
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Identifier Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Identifier Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier Descriptor not initialized')
if self.len_fi > 0:
if self.encoding == 'latin-1':
prefix = b'\x08'
elif self.encoding == 'utf-16_be':
prefix = b'\x10'
else:
raise pycdlibexception.PyCdlibInternalError('Invalid UDF encoding; this should not happen')
fi = prefix + self.fi
else:
fi = b''
rec = struct.pack(self.FMT, b'\x00' * 16, 1,
self.file_characteristics, self.len_fi,
self.icb.record(),
self.len_impl_use) + self.impl_use + fi + b'\x00' * UDFFileIdentifierDescriptor.pad(struct.calcsize(self.FMT) + self.len_impl_use + self.len_fi)
return self.desc_tag.record(rec[16:]) + rec[16:]
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Identifier Descriptor not initialized'",
")",
"if",
"self",
".",
"len_fi",
">",
"0",
":",
"if",
"self",
".",
"encoding",
"==",
"'latin-1'",
":",
"prefix",
"=",
"b'\\x08'",
"elif",
"self",
".",
"encoding",
"==",
"'utf-16_be'",
":",
"prefix",
"=",
"b'\\x10'",
"else",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Invalid UDF encoding; this should not happen'",
")",
"fi",
"=",
"prefix",
"+",
"self",
".",
"fi",
"else",
":",
"fi",
"=",
"b''",
"rec",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"b'\\x00'",
"*",
"16",
",",
"1",
",",
"self",
".",
"file_characteristics",
",",
"self",
".",
"len_fi",
",",
"self",
".",
"icb",
".",
"record",
"(",
")",
",",
"self",
".",
"len_impl_use",
")",
"+",
"self",
".",
"impl_use",
"+",
"fi",
"+",
"b'\\x00'",
"*",
"UDFFileIdentifierDescriptor",
".",
"pad",
"(",
"struct",
".",
"calcsize",
"(",
"self",
".",
"FMT",
")",
"+",
"self",
".",
"len_impl_use",
"+",
"self",
".",
"len_fi",
")",
"return",
"self",
".",
"desc_tag",
".",
"record",
"(",
"rec",
"[",
"16",
":",
"]",
")",
"+",
"rec",
"[",
"16",
":",
"]"
] |
A method to generate the string representing this UDF File Identifier Descriptor.
Parameters:
None.
Returns:
A string representing this UDF File Identifier Descriptor.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"UDF",
"File",
"Identifier",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3401-L3429
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileIdentifierDescriptor.new
|
def new(self, isdir, isparent, name, parent):
# type: (bool, bool, bytes, Optional[UDFFileEntry]) -> None
'''
A method to create a new UDF File Identifier.
Parameters:
isdir - Whether this File Identifier is a directory.
isparent - Whether this File Identifier is a parent (..).
name - The name for this File Identifier.
parent - The UDF File Entry representing the parent.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(257) # FIXME: we should let the user set serial_number
self.icb = UDFLongAD()
self.icb.new(2048, 2)
self.isdir = isdir
self.isparent = isparent
self.file_characteristics = 0
if self.isdir:
self.file_characteristics |= 0x2
if self.isparent:
self.file_characteristics |= 0x8
self.len_impl_use = 0 # FIXME: need to let the user set this
self.impl_use = b''
self.len_fi = 0
if not isparent:
bytename = name.decode('utf-8')
try:
self.fi = bytename.encode('latin-1')
self.encoding = 'latin-1'
except UnicodeEncodeError:
self.fi = bytename.encode('utf-16_be')
self.encoding = 'utf-16_be'
self.len_fi = len(self.fi) + 1
self.parent = parent
self._initialized = True
|
python
|
def new(self, isdir, isparent, name, parent):
# type: (bool, bool, bytes, Optional[UDFFileEntry]) -> None
'''
A method to create a new UDF File Identifier.
Parameters:
isdir - Whether this File Identifier is a directory.
isparent - Whether this File Identifier is a parent (..).
name - The name for this File Identifier.
parent - The UDF File Entry representing the parent.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(257) # FIXME: we should let the user set serial_number
self.icb = UDFLongAD()
self.icb.new(2048, 2)
self.isdir = isdir
self.isparent = isparent
self.file_characteristics = 0
if self.isdir:
self.file_characteristics |= 0x2
if self.isparent:
self.file_characteristics |= 0x8
self.len_impl_use = 0 # FIXME: need to let the user set this
self.impl_use = b''
self.len_fi = 0
if not isparent:
bytename = name.decode('utf-8')
try:
self.fi = bytename.encode('latin-1')
self.encoding = 'latin-1'
except UnicodeEncodeError:
self.fi = bytename.encode('utf-16_be')
self.encoding = 'utf-16_be'
self.len_fi = len(self.fi) + 1
self.parent = parent
self._initialized = True
|
[
"def",
"new",
"(",
"self",
",",
"isdir",
",",
"isparent",
",",
"name",
",",
"parent",
")",
":",
"# type: (bool, bool, bytes, Optional[UDFFileEntry]) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Identifier already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag",
"(",
")",
"self",
".",
"desc_tag",
".",
"new",
"(",
"257",
")",
"# FIXME: we should let the user set serial_number",
"self",
".",
"icb",
"=",
"UDFLongAD",
"(",
")",
"self",
".",
"icb",
".",
"new",
"(",
"2048",
",",
"2",
")",
"self",
".",
"isdir",
"=",
"isdir",
"self",
".",
"isparent",
"=",
"isparent",
"self",
".",
"file_characteristics",
"=",
"0",
"if",
"self",
".",
"isdir",
":",
"self",
".",
"file_characteristics",
"|=",
"0x2",
"if",
"self",
".",
"isparent",
":",
"self",
".",
"file_characteristics",
"|=",
"0x8",
"self",
".",
"len_impl_use",
"=",
"0",
"# FIXME: need to let the user set this",
"self",
".",
"impl_use",
"=",
"b''",
"self",
".",
"len_fi",
"=",
"0",
"if",
"not",
"isparent",
":",
"bytename",
"=",
"name",
".",
"decode",
"(",
"'utf-8'",
")",
"try",
":",
"self",
".",
"fi",
"=",
"bytename",
".",
"encode",
"(",
"'latin-1'",
")",
"self",
".",
"encoding",
"=",
"'latin-1'",
"except",
"UnicodeEncodeError",
":",
"self",
".",
"fi",
"=",
"bytename",
".",
"encode",
"(",
"'utf-16_be'",
")",
"self",
".",
"encoding",
"=",
"'utf-16_be'",
"self",
".",
"len_fi",
"=",
"len",
"(",
"self",
".",
"fi",
")",
"+",
"1",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to create a new UDF File Identifier.
Parameters:
isdir - Whether this File Identifier is a directory.
isparent - Whether this File Identifier is a parent (..).
name - The name for this File Identifier.
parent - The UDF File Entry representing the parent.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"File",
"Identifier",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3448-L3494
|
train
|
clalancette/pycdlib
|
pycdlib/udf.py
|
UDFFileIdentifierDescriptor.set_icb
|
def set_icb(self, new_location, tag_location):
# type: (int, int) -> None
'''
A method to set the location of the data that this UDF File Identifier
Descriptor points at. The data can either be for a directory or for a
file.
Parameters:
new_location - The new extent this UDF File Identifier Descriptor data lives at.
tag_location - The new relative extent this UDF File Identifier Descriptor data lives at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier not initialized')
self.icb.set_extent_location(new_location, tag_location)
|
python
|
def set_icb(self, new_location, tag_location):
# type: (int, int) -> None
'''
A method to set the location of the data that this UDF File Identifier
Descriptor points at. The data can either be for a directory or for a
file.
Parameters:
new_location - The new extent this UDF File Identifier Descriptor data lives at.
tag_location - The new relative extent this UDF File Identifier Descriptor data lives at.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Identifier not initialized')
self.icb.set_extent_location(new_location, tag_location)
|
[
"def",
"set_icb",
"(",
"self",
",",
"new_location",
",",
"tag_location",
")",
":",
"# type: (int, int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Identifier not initialized'",
")",
"self",
".",
"icb",
".",
"set_extent_location",
"(",
"new_location",
",",
"tag_location",
")"
] |
A method to set the location of the data that this UDF File Identifier
Descriptor points at. The data can either be for a directory or for a
file.
Parameters:
new_location - The new extent this UDF File Identifier Descriptor data lives at.
tag_location - The new relative extent this UDF File Identifier Descriptor data lives at.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"set",
"the",
"location",
"of",
"the",
"data",
"that",
"this",
"UDF",
"File",
"Identifier",
"Descriptor",
"points",
"at",
".",
"The",
"data",
"can",
"either",
"be",
"for",
"a",
"directory",
"or",
"for",
"a",
"file",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3515-L3531
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
pvd_factory
|
def pvd_factory(sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str,
app_ident_str, copyright_file, abstract_file, bibli_file,
vol_expire_date, app_use, xa):
# type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD
'''
An internal function to create a Primary Volume Descriptor.
Parameters:
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Primary Volume Descriptor.
'''
pvd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_PRIMARY)
pvd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str,
app_ident_str, copyright_file, abstract_file, bibli_file,
vol_expire_date, app_use, xa, 1, b'')
return pvd
|
python
|
def pvd_factory(sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str,
app_ident_str, copyright_file, abstract_file, bibli_file,
vol_expire_date, app_use, xa):
# type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD
'''
An internal function to create a Primary Volume Descriptor.
Parameters:
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Primary Volume Descriptor.
'''
pvd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_PRIMARY)
pvd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str,
app_ident_str, copyright_file, abstract_file, bibli_file,
vol_expire_date, app_use, xa, 1, b'')
return pvd
|
[
"def",
"pvd_factory",
"(",
"sys_ident",
",",
"vol_ident",
",",
"set_size",
",",
"seqnum",
",",
"log_block_size",
",",
"vol_set_ident",
",",
"pub_ident_str",
",",
"preparer_ident_str",
",",
"app_ident_str",
",",
"copyright_file",
",",
"abstract_file",
",",
"bibli_file",
",",
"vol_expire_date",
",",
"app_use",
",",
"xa",
")",
":",
"# type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD",
"pvd",
"=",
"PrimaryOrSupplementaryVD",
"(",
"VOLUME_DESCRIPTOR_TYPE_PRIMARY",
")",
"pvd",
".",
"new",
"(",
"0",
",",
"sys_ident",
",",
"vol_ident",
",",
"set_size",
",",
"seqnum",
",",
"log_block_size",
",",
"vol_set_ident",
",",
"pub_ident_str",
",",
"preparer_ident_str",
",",
"app_ident_str",
",",
"copyright_file",
",",
"abstract_file",
",",
"bibli_file",
",",
"vol_expire_date",
",",
"app_use",
",",
"xa",
",",
"1",
",",
"b''",
")",
"return",
"pvd"
] |
An internal function to create a Primary Volume Descriptor.
Parameters:
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Primary Volume Descriptor.
|
[
"An",
"internal",
"function",
"to",
"create",
"a",
"Primary",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L746-L785
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
enhanced_vd_factory
|
def enhanced_vd_factory(sys_ident, vol_ident, set_size, seqnum,
log_block_size, vol_set_ident, pub_ident_str,
preparer_ident_str, app_ident_str, copyright_file,
abstract_file, bibli_file, vol_expire_date, app_use,
xa):
# type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD
'''
An internal function to create an Enhanced Volume Descriptor for ISO 1999.
Parameters:
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Enhanced Volume Descriptor.
'''
svd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY)
svd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str,
app_ident_str, copyright_file, abstract_file, bibli_file,
vol_expire_date, app_use, xa, 2, b'')
return svd
|
python
|
def enhanced_vd_factory(sys_ident, vol_ident, set_size, seqnum,
log_block_size, vol_set_ident, pub_ident_str,
preparer_ident_str, app_ident_str, copyright_file,
abstract_file, bibli_file, vol_expire_date, app_use,
xa):
# type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD
'''
An internal function to create an Enhanced Volume Descriptor for ISO 1999.
Parameters:
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Enhanced Volume Descriptor.
'''
svd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY)
svd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str,
app_ident_str, copyright_file, abstract_file, bibli_file,
vol_expire_date, app_use, xa, 2, b'')
return svd
|
[
"def",
"enhanced_vd_factory",
"(",
"sys_ident",
",",
"vol_ident",
",",
"set_size",
",",
"seqnum",
",",
"log_block_size",
",",
"vol_set_ident",
",",
"pub_ident_str",
",",
"preparer_ident_str",
",",
"app_ident_str",
",",
"copyright_file",
",",
"abstract_file",
",",
"bibli_file",
",",
"vol_expire_date",
",",
"app_use",
",",
"xa",
")",
":",
"# type: (bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD",
"svd",
"=",
"PrimaryOrSupplementaryVD",
"(",
"VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY",
")",
"svd",
".",
"new",
"(",
"0",
",",
"sys_ident",
",",
"vol_ident",
",",
"set_size",
",",
"seqnum",
",",
"log_block_size",
",",
"vol_set_ident",
",",
"pub_ident_str",
",",
"preparer_ident_str",
",",
"app_ident_str",
",",
"copyright_file",
",",
"abstract_file",
",",
"bibli_file",
",",
"vol_expire_date",
",",
"app_use",
",",
"xa",
",",
"2",
",",
"b''",
")",
"return",
"svd"
] |
An internal function to create an Enhanced Volume Descriptor for ISO 1999.
Parameters:
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Enhanced Volume Descriptor.
|
[
"An",
"internal",
"function",
"to",
"create",
"an",
"Enhanced",
"Volume",
"Descriptor",
"for",
"ISO",
"1999",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L788-L828
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
joliet_vd_factory
|
def joliet_vd_factory(joliet, sys_ident, vol_ident, set_size, seqnum,
log_block_size, vol_set_ident, pub_ident_str,
preparer_ident_str, app_ident_str, copyright_file,
abstract_file, bibli_file, vol_expire_date, app_use, xa):
# type: (int, bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD
'''
An internal function to create an Joliet Volume Descriptor.
Parameters:
joliet - The joliet version to use, one of 1, 2, or 3.
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Joliet Volume Descriptor.
'''
if joliet == 1:
escape_sequence = b'%/@'
elif joliet == 2:
escape_sequence = b'%/C'
elif joliet == 3:
escape_sequence = b'%/E'
else:
raise pycdlibexception.PyCdlibInvalidInput('Invalid Joliet level; must be 1, 2, or 3')
svd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY)
svd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str,
copyright_file, abstract_file,
bibli_file, vol_expire_date, app_use, xa, 1, escape_sequence)
return svd
|
python
|
def joliet_vd_factory(joliet, sys_ident, vol_ident, set_size, seqnum,
log_block_size, vol_set_ident, pub_ident_str,
preparer_ident_str, app_ident_str, copyright_file,
abstract_file, bibli_file, vol_expire_date, app_use, xa):
# type: (int, bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD
'''
An internal function to create an Joliet Volume Descriptor.
Parameters:
joliet - The joliet version to use, one of 1, 2, or 3.
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Joliet Volume Descriptor.
'''
if joliet == 1:
escape_sequence = b'%/@'
elif joliet == 2:
escape_sequence = b'%/C'
elif joliet == 3:
escape_sequence = b'%/E'
else:
raise pycdlibexception.PyCdlibInvalidInput('Invalid Joliet level; must be 1, 2, or 3')
svd = PrimaryOrSupplementaryVD(VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY)
svd.new(0, sys_ident, vol_ident, set_size, seqnum, log_block_size,
vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str,
copyright_file, abstract_file,
bibli_file, vol_expire_date, app_use, xa, 1, escape_sequence)
return svd
|
[
"def",
"joliet_vd_factory",
"(",
"joliet",
",",
"sys_ident",
",",
"vol_ident",
",",
"set_size",
",",
"seqnum",
",",
"log_block_size",
",",
"vol_set_ident",
",",
"pub_ident_str",
",",
"preparer_ident_str",
",",
"app_ident_str",
",",
"copyright_file",
",",
"abstract_file",
",",
"bibli_file",
",",
"vol_expire_date",
",",
"app_use",
",",
"xa",
")",
":",
"# type: (int, bytes, bytes, int, int, int, bytes, bytes, bytes, bytes, bytes, bytes, bytes, float, bytes, bool) -> PrimaryOrSupplementaryVD",
"if",
"joliet",
"==",
"1",
":",
"escape_sequence",
"=",
"b'%/@'",
"elif",
"joliet",
"==",
"2",
":",
"escape_sequence",
"=",
"b'%/C'",
"elif",
"joliet",
"==",
"3",
":",
"escape_sequence",
"=",
"b'%/E'",
"else",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'Invalid Joliet level; must be 1, 2, or 3'",
")",
"svd",
"=",
"PrimaryOrSupplementaryVD",
"(",
"VOLUME_DESCRIPTOR_TYPE_SUPPLEMENTARY",
")",
"svd",
".",
"new",
"(",
"0",
",",
"sys_ident",
",",
"vol_ident",
",",
"set_size",
",",
"seqnum",
",",
"log_block_size",
",",
"vol_set_ident",
",",
"pub_ident_str",
",",
"preparer_ident_str",
",",
"app_ident_str",
",",
"copyright_file",
",",
"abstract_file",
",",
"bibli_file",
",",
"vol_expire_date",
",",
"app_use",
",",
"xa",
",",
"1",
",",
"escape_sequence",
")",
"return",
"svd"
] |
An internal function to create an Joliet Volume Descriptor.
Parameters:
joliet - The joliet version to use, one of 1, 2, or 3.
sys_ident - The system identification string to use on the new ISO.
vol_ident - The volume identification string to use on the new ISO.
set_size - The size of the set of ISOs this ISO is a part of.
seqnum - The sequence number of the set of this ISO.
log_block_size - The logical block size to use for the ISO. While ISO9660
technically supports sizes other than 2048 (the default),
this almost certainly doesn't work.
vol_set_ident - The volume set identification string to use on the new ISO.
pub_ident_str - The publisher identification string to use on the new ISO.
preparer_ident_str - The preparer identification string to use on the new ISO.
app_ident_str - The application identification string to use on the new ISO.
copyright_file - The name of a file at the root of the ISO to use as the
copyright file.
abstract_file - The name of a file at the root of the ISO to use as the
abstract file.
bibli_file - The name of a file at the root of the ISO to use as the
bibliographic file.
vol_expire_date - The date that this ISO will expire at.
app_use - Arbitrary data that the application can stuff into the primary
volume descriptor of this ISO.
xa - Whether to add the ISO9660 Extended Attribute extensions to this
ISO. The default is False.
Returns:
The newly created Joliet Volume Descriptor.
|
[
"An",
"internal",
"function",
"to",
"create",
"an",
"Joliet",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L831-L880
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.copy
|
def copy(self, orig):
# type: (PrimaryOrSupplementaryVD) -> None
'''
A method to populate and initialize this VD object from the contents
of an old VD.
Parameters:
orig_pvd - The original VD to copy data from.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is already initialized')
self.version = orig.version
self.flags = orig.flags
self.system_identifier = orig.system_identifier
self.volume_identifier = orig.volume_identifier
self.escape_sequences = orig.escape_sequences
self.space_size = orig.space_size
self.set_size = orig.set_size
self.seqnum = orig.seqnum
self.log_block_size = orig.log_block_size
self.path_tbl_size = orig.path_tbl_size
self.path_table_location_le = orig.path_table_location_le
self.optional_path_table_location_le = orig.optional_path_table_location_le
self.path_table_location_be = orig.path_table_location_be
self.optional_path_table_location_be = orig.optional_path_table_location_be
# Root dir record is a DirectoryRecord object, and we want this copy to hold
# onto exactly the same reference as the original
self.root_dir_record = orig.root_dir_record
self.volume_set_identifier = orig.volume_set_identifier
# publisher_identifier is a FileOrTextIdentifier object, and we want this copy to
# hold onto exactly the same reference as the original
self.publisher_identifier = orig.publisher_identifier
# preparer_identifier is a FileOrTextIdentifier object, and we want this copy to
# hold onto exactly the same reference as the original
self.preparer_identifier = orig.preparer_identifier
# application_identifier is a FileOrTextIdentifier object, and we want this copy to
# hold onto exactly the same reference as the original
self.application_identifier = orig.application_identifier
self.copyright_file_identifier = orig.copyright_file_identifier
self.abstract_file_identifier = orig.abstract_file_identifier
self.bibliographic_file_identifier = orig.bibliographic_file_identifier
# volume_creation_date is a VolumeDescriptorDate object, and we want this copy to
# hold onto exactly the same reference as the original
self.volume_creation_date = orig.volume_creation_date
# volume_expiration_date is a VolumeDescriptorDate object, and we want this copy to
# hold onto exactly the same reference as the original
self.volume_expiration_date = orig.volume_expiration_date
# volume_effective_date is a VolumeDescriptorDate object, and we want this copy to
# hold onto exactly the same reference as the original
self.volume_effective_date = orig.volume_effective_date
self.file_structure_version = orig.file_structure_version
self.application_use = orig.application_use
self._initialized = True
|
python
|
def copy(self, orig):
# type: (PrimaryOrSupplementaryVD) -> None
'''
A method to populate and initialize this VD object from the contents
of an old VD.
Parameters:
orig_pvd - The original VD to copy data from.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is already initialized')
self.version = orig.version
self.flags = orig.flags
self.system_identifier = orig.system_identifier
self.volume_identifier = orig.volume_identifier
self.escape_sequences = orig.escape_sequences
self.space_size = orig.space_size
self.set_size = orig.set_size
self.seqnum = orig.seqnum
self.log_block_size = orig.log_block_size
self.path_tbl_size = orig.path_tbl_size
self.path_table_location_le = orig.path_table_location_le
self.optional_path_table_location_le = orig.optional_path_table_location_le
self.path_table_location_be = orig.path_table_location_be
self.optional_path_table_location_be = orig.optional_path_table_location_be
# Root dir record is a DirectoryRecord object, and we want this copy to hold
# onto exactly the same reference as the original
self.root_dir_record = orig.root_dir_record
self.volume_set_identifier = orig.volume_set_identifier
# publisher_identifier is a FileOrTextIdentifier object, and we want this copy to
# hold onto exactly the same reference as the original
self.publisher_identifier = orig.publisher_identifier
# preparer_identifier is a FileOrTextIdentifier object, and we want this copy to
# hold onto exactly the same reference as the original
self.preparer_identifier = orig.preparer_identifier
# application_identifier is a FileOrTextIdentifier object, and we want this copy to
# hold onto exactly the same reference as the original
self.application_identifier = orig.application_identifier
self.copyright_file_identifier = orig.copyright_file_identifier
self.abstract_file_identifier = orig.abstract_file_identifier
self.bibliographic_file_identifier = orig.bibliographic_file_identifier
# volume_creation_date is a VolumeDescriptorDate object, and we want this copy to
# hold onto exactly the same reference as the original
self.volume_creation_date = orig.volume_creation_date
# volume_expiration_date is a VolumeDescriptorDate object, and we want this copy to
# hold onto exactly the same reference as the original
self.volume_expiration_date = orig.volume_expiration_date
# volume_effective_date is a VolumeDescriptorDate object, and we want this copy to
# hold onto exactly the same reference as the original
self.volume_effective_date = orig.volume_effective_date
self.file_structure_version = orig.file_structure_version
self.application_use = orig.application_use
self._initialized = True
|
[
"def",
"copy",
"(",
"self",
",",
"orig",
")",
":",
"# type: (PrimaryOrSupplementaryVD) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is already initialized'",
")",
"self",
".",
"version",
"=",
"orig",
".",
"version",
"self",
".",
"flags",
"=",
"orig",
".",
"flags",
"self",
".",
"system_identifier",
"=",
"orig",
".",
"system_identifier",
"self",
".",
"volume_identifier",
"=",
"orig",
".",
"volume_identifier",
"self",
".",
"escape_sequences",
"=",
"orig",
".",
"escape_sequences",
"self",
".",
"space_size",
"=",
"orig",
".",
"space_size",
"self",
".",
"set_size",
"=",
"orig",
".",
"set_size",
"self",
".",
"seqnum",
"=",
"orig",
".",
"seqnum",
"self",
".",
"log_block_size",
"=",
"orig",
".",
"log_block_size",
"self",
".",
"path_tbl_size",
"=",
"orig",
".",
"path_tbl_size",
"self",
".",
"path_table_location_le",
"=",
"orig",
".",
"path_table_location_le",
"self",
".",
"optional_path_table_location_le",
"=",
"orig",
".",
"optional_path_table_location_le",
"self",
".",
"path_table_location_be",
"=",
"orig",
".",
"path_table_location_be",
"self",
".",
"optional_path_table_location_be",
"=",
"orig",
".",
"optional_path_table_location_be",
"# Root dir record is a DirectoryRecord object, and we want this copy to hold",
"# onto exactly the same reference as the original",
"self",
".",
"root_dir_record",
"=",
"orig",
".",
"root_dir_record",
"self",
".",
"volume_set_identifier",
"=",
"orig",
".",
"volume_set_identifier",
"# publisher_identifier is a FileOrTextIdentifier object, and we want this copy to",
"# hold onto exactly the same reference as the original",
"self",
".",
"publisher_identifier",
"=",
"orig",
".",
"publisher_identifier",
"# preparer_identifier is a FileOrTextIdentifier object, and we want this copy to",
"# hold onto exactly the same reference as the original",
"self",
".",
"preparer_identifier",
"=",
"orig",
".",
"preparer_identifier",
"# application_identifier is a FileOrTextIdentifier object, and we want this copy to",
"# hold onto exactly the same reference as the original",
"self",
".",
"application_identifier",
"=",
"orig",
".",
"application_identifier",
"self",
".",
"copyright_file_identifier",
"=",
"orig",
".",
"copyright_file_identifier",
"self",
".",
"abstract_file_identifier",
"=",
"orig",
".",
"abstract_file_identifier",
"self",
".",
"bibliographic_file_identifier",
"=",
"orig",
".",
"bibliographic_file_identifier",
"# volume_creation_date is a VolumeDescriptorDate object, and we want this copy to",
"# hold onto exactly the same reference as the original",
"self",
".",
"volume_creation_date",
"=",
"orig",
".",
"volume_creation_date",
"# volume_expiration_date is a VolumeDescriptorDate object, and we want this copy to",
"# hold onto exactly the same reference as the original",
"self",
".",
"volume_expiration_date",
"=",
"orig",
".",
"volume_expiration_date",
"# volume_effective_date is a VolumeDescriptorDate object, and we want this copy to",
"# hold onto exactly the same reference as the original",
"self",
".",
"volume_effective_date",
"=",
"orig",
".",
"volume_effective_date",
"self",
".",
"file_structure_version",
"=",
"orig",
".",
"file_structure_version",
"self",
".",
"application_use",
"=",
"orig",
".",
"application_use",
"self",
".",
"_initialized",
"=",
"True"
] |
A method to populate and initialize this VD object from the contents
of an old VD.
Parameters:
orig_pvd - The original VD to copy data from.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"populate",
"and",
"initialize",
"this",
"VD",
"object",
"from",
"the",
"contents",
"of",
"an",
"old",
"VD",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L336-L392
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.record
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this Volume Descriptor.
Parameters:
None.
Returns:
A string representing this Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
vol_mod_date = dates.VolumeDescriptorDate()
vol_mod_date.new(time.time())
return struct.pack(self.FMT,
self._vd_type,
b'CD001',
self.version,
self.flags,
self.system_identifier,
self.volume_identifier,
0,
self.space_size,
utils.swab_32bit(self.space_size),
self.escape_sequences,
self.set_size,
utils.swab_16bit(self.set_size),
self.seqnum,
utils.swab_16bit(self.seqnum),
self.log_block_size,
utils.swab_16bit(self.log_block_size),
self.path_tbl_size,
utils.swab_32bit(self.path_tbl_size),
self.path_table_location_le,
self.optional_path_table_location_le,
utils.swab_32bit(self.path_table_location_be),
self.optional_path_table_location_be,
self.root_dir_record.record(),
self.volume_set_identifier,
self.publisher_identifier.record(),
self.preparer_identifier.record(),
self.application_identifier.record(),
self.copyright_file_identifier,
self.abstract_file_identifier,
self.bibliographic_file_identifier,
self.volume_creation_date.record(),
vol_mod_date.record(),
self.volume_expiration_date.record(),
self.volume_effective_date.record(),
self.file_structure_version, 0, self.application_use,
b'\x00' * 653)
|
python
|
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this Volume Descriptor.
Parameters:
None.
Returns:
A string representing this Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
vol_mod_date = dates.VolumeDescriptorDate()
vol_mod_date.new(time.time())
return struct.pack(self.FMT,
self._vd_type,
b'CD001',
self.version,
self.flags,
self.system_identifier,
self.volume_identifier,
0,
self.space_size,
utils.swab_32bit(self.space_size),
self.escape_sequences,
self.set_size,
utils.swab_16bit(self.set_size),
self.seqnum,
utils.swab_16bit(self.seqnum),
self.log_block_size,
utils.swab_16bit(self.log_block_size),
self.path_tbl_size,
utils.swab_32bit(self.path_tbl_size),
self.path_table_location_le,
self.optional_path_table_location_le,
utils.swab_32bit(self.path_table_location_be),
self.optional_path_table_location_be,
self.root_dir_record.record(),
self.volume_set_identifier,
self.publisher_identifier.record(),
self.preparer_identifier.record(),
self.application_identifier.record(),
self.copyright_file_identifier,
self.abstract_file_identifier,
self.bibliographic_file_identifier,
self.volume_creation_date.record(),
vol_mod_date.record(),
self.volume_expiration_date.record(),
self.volume_effective_date.record(),
self.file_structure_version, 0, self.application_use,
b'\x00' * 653)
|
[
"def",
"record",
"(",
"self",
")",
":",
"# type: () -> bytes",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"vol_mod_date",
"=",
"dates",
".",
"VolumeDescriptorDate",
"(",
")",
"vol_mod_date",
".",
"new",
"(",
"time",
".",
"time",
"(",
")",
")",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
"FMT",
",",
"self",
".",
"_vd_type",
",",
"b'CD001'",
",",
"self",
".",
"version",
",",
"self",
".",
"flags",
",",
"self",
".",
"system_identifier",
",",
"self",
".",
"volume_identifier",
",",
"0",
",",
"self",
".",
"space_size",
",",
"utils",
".",
"swab_32bit",
"(",
"self",
".",
"space_size",
")",
",",
"self",
".",
"escape_sequences",
",",
"self",
".",
"set_size",
",",
"utils",
".",
"swab_16bit",
"(",
"self",
".",
"set_size",
")",
",",
"self",
".",
"seqnum",
",",
"utils",
".",
"swab_16bit",
"(",
"self",
".",
"seqnum",
")",
",",
"self",
".",
"log_block_size",
",",
"utils",
".",
"swab_16bit",
"(",
"self",
".",
"log_block_size",
")",
",",
"self",
".",
"path_tbl_size",
",",
"utils",
".",
"swab_32bit",
"(",
"self",
".",
"path_tbl_size",
")",
",",
"self",
".",
"path_table_location_le",
",",
"self",
".",
"optional_path_table_location_le",
",",
"utils",
".",
"swab_32bit",
"(",
"self",
".",
"path_table_location_be",
")",
",",
"self",
".",
"optional_path_table_location_be",
",",
"self",
".",
"root_dir_record",
".",
"record",
"(",
")",
",",
"self",
".",
"volume_set_identifier",
",",
"self",
".",
"publisher_identifier",
".",
"record",
"(",
")",
",",
"self",
".",
"preparer_identifier",
".",
"record",
"(",
")",
",",
"self",
".",
"application_identifier",
".",
"record",
"(",
")",
",",
"self",
".",
"copyright_file_identifier",
",",
"self",
".",
"abstract_file_identifier",
",",
"self",
".",
"bibliographic_file_identifier",
",",
"self",
".",
"volume_creation_date",
".",
"record",
"(",
")",
",",
"vol_mod_date",
".",
"record",
"(",
")",
",",
"self",
".",
"volume_expiration_date",
".",
"record",
"(",
")",
",",
"self",
".",
"volume_effective_date",
".",
"record",
"(",
")",
",",
"self",
".",
"file_structure_version",
",",
"0",
",",
"self",
".",
"application_use",
",",
"b'\\x00'",
"*",
"653",
")"
] |
A method to generate the string representing this Volume Descriptor.
Parameters:
None.
Returns:
A string representing this Volume Descriptor.
|
[
"A",
"method",
"to",
"generate",
"the",
"string",
"representing",
"this",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L394-L446
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.track_rr_ce_entry
|
def track_rr_ce_entry(self, extent, offset, length):
# type: (int, int, int) -> rockridge.RockRidgeContinuationBlock
'''
Start tracking a new Rock Ridge Continuation Entry entry in this Volume
Descriptor, at the extent, offset, and length provided. Since Rock
Ridge Continuation Blocks are shared across multiple Rock Ridge
Directory Records, the most logical place to track them is in the PVD.
This method is expected to be used during parse time, when an extent,
offset and length are already assigned to the entry.
Parameters:
extent - The extent that this Continuation Entry lives at.
offset - The offset within the extent that this Continuation Entry
lives at.
length - The length of this Continuation Entry.
Returns:
The object representing the block in which the Continuation Entry was
placed in.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized')
for block in self.rr_ce_blocks:
if block.extent_location() == extent:
break
else:
# We didn't find it in the list, add it
block = rockridge.RockRidgeContinuationBlock(extent, self.log_block_size)
self.rr_ce_blocks.append(block)
block.track_entry(offset, length)
return block
|
python
|
def track_rr_ce_entry(self, extent, offset, length):
# type: (int, int, int) -> rockridge.RockRidgeContinuationBlock
'''
Start tracking a new Rock Ridge Continuation Entry entry in this Volume
Descriptor, at the extent, offset, and length provided. Since Rock
Ridge Continuation Blocks are shared across multiple Rock Ridge
Directory Records, the most logical place to track them is in the PVD.
This method is expected to be used during parse time, when an extent,
offset and length are already assigned to the entry.
Parameters:
extent - The extent that this Continuation Entry lives at.
offset - The offset within the extent that this Continuation Entry
lives at.
length - The length of this Continuation Entry.
Returns:
The object representing the block in which the Continuation Entry was
placed in.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized')
for block in self.rr_ce_blocks:
if block.extent_location() == extent:
break
else:
# We didn't find it in the list, add it
block = rockridge.RockRidgeContinuationBlock(extent, self.log_block_size)
self.rr_ce_blocks.append(block)
block.track_entry(offset, length)
return block
|
[
"def",
"track_rr_ce_entry",
"(",
"self",
",",
"extent",
",",
"offset",
",",
"length",
")",
":",
"# type: (int, int, int) -> rockridge.RockRidgeContinuationBlock",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Primary Volume Descriptor is not yet initialized'",
")",
"for",
"block",
"in",
"self",
".",
"rr_ce_blocks",
":",
"if",
"block",
".",
"extent_location",
"(",
")",
"==",
"extent",
":",
"break",
"else",
":",
"# We didn't find it in the list, add it",
"block",
"=",
"rockridge",
".",
"RockRidgeContinuationBlock",
"(",
"extent",
",",
"self",
".",
"log_block_size",
")",
"self",
".",
"rr_ce_blocks",
".",
"append",
"(",
"block",
")",
"block",
".",
"track_entry",
"(",
"offset",
",",
"length",
")",
"return",
"block"
] |
Start tracking a new Rock Ridge Continuation Entry entry in this Volume
Descriptor, at the extent, offset, and length provided. Since Rock
Ridge Continuation Blocks are shared across multiple Rock Ridge
Directory Records, the most logical place to track them is in the PVD.
This method is expected to be used during parse time, when an extent,
offset and length are already assigned to the entry.
Parameters:
extent - The extent that this Continuation Entry lives at.
offset - The offset within the extent that this Continuation Entry
lives at.
length - The length of this Continuation Entry.
Returns:
The object representing the block in which the Continuation Entry was
placed in.
|
[
"Start",
"tracking",
"a",
"new",
"Rock",
"Ridge",
"Continuation",
"Entry",
"entry",
"in",
"this",
"Volume",
"Descriptor",
"at",
"the",
"extent",
"offset",
"and",
"length",
"provided",
".",
"Since",
"Rock",
"Ridge",
"Continuation",
"Blocks",
"are",
"shared",
"across",
"multiple",
"Rock",
"Ridge",
"Directory",
"Records",
"the",
"most",
"logical",
"place",
"to",
"track",
"them",
"is",
"in",
"the",
"PVD",
".",
"This",
"method",
"is",
"expected",
"to",
"be",
"used",
"during",
"parse",
"time",
"when",
"an",
"extent",
"offset",
"and",
"length",
"are",
"already",
"assigned",
"to",
"the",
"entry",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L448-L480
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.clear_rr_ce_entries
|
def clear_rr_ce_entries(self):
# type: () -> None
'''
A method to clear out all of the extent locations of all Rock Ridge
Continuation Entries that the PVD is tracking. This can be used to
reset all data before assigning new data.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized')
for block in self.rr_ce_blocks:
block.set_extent_location(-1)
|
python
|
def clear_rr_ce_entries(self):
# type: () -> None
'''
A method to clear out all of the extent locations of all Rock Ridge
Continuation Entries that the PVD is tracking. This can be used to
reset all data before assigning new data.
Parameters:
None.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not yet initialized')
for block in self.rr_ce_blocks:
block.set_extent_location(-1)
|
[
"def",
"clear_rr_ce_entries",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Primary Volume Descriptor is not yet initialized'",
")",
"for",
"block",
"in",
"self",
".",
"rr_ce_blocks",
":",
"block",
".",
"set_extent_location",
"(",
"-",
"1",
")"
] |
A method to clear out all of the extent locations of all Rock Ridge
Continuation Entries that the PVD is tracking. This can be used to
reset all data before assigning new data.
Parameters:
None.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"clear",
"out",
"all",
"of",
"the",
"extent",
"locations",
"of",
"all",
"Rock",
"Ridge",
"Continuation",
"Entries",
"that",
"the",
"PVD",
"is",
"tracking",
".",
"This",
"can",
"be",
"used",
"to",
"reset",
"all",
"data",
"before",
"assigning",
"new",
"data",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L515-L531
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.add_to_space_size
|
def add_to_space_size(self, addition_bytes):
# type: (int) -> None
'''
A method to add bytes to the space size tracked by this Volume
Descriptor.
Parameters:
addition_bytes - The number of bytes to add to the space size.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# The 'addition' parameter is expected to be in bytes, but the space
# size we track is in extents. Round up to the next extent.
self.space_size += utils.ceiling_div(addition_bytes, self.log_block_size)
|
python
|
def add_to_space_size(self, addition_bytes):
# type: (int) -> None
'''
A method to add bytes to the space size tracked by this Volume
Descriptor.
Parameters:
addition_bytes - The number of bytes to add to the space size.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# The 'addition' parameter is expected to be in bytes, but the space
# size we track is in extents. Round up to the next extent.
self.space_size += utils.ceiling_div(addition_bytes, self.log_block_size)
|
[
"def",
"add_to_space_size",
"(",
"self",
",",
"addition_bytes",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# The 'addition' parameter is expected to be in bytes, but the space",
"# size we track is in extents. Round up to the next extent.",
"self",
".",
"space_size",
"+=",
"utils",
".",
"ceiling_div",
"(",
"addition_bytes",
",",
"self",
".",
"log_block_size",
")"
] |
A method to add bytes to the space size tracked by this Volume
Descriptor.
Parameters:
addition_bytes - The number of bytes to add to the space size.
Returns:
Nothing.
|
[
"A",
"method",
"to",
"add",
"bytes",
"to",
"the",
"space",
"size",
"tracked",
"by",
"this",
"Volume",
"Descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L548-L563
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.remove_from_space_size
|
def remove_from_space_size(self, removal_bytes):
# type: (int) -> None
'''
Remove bytes from the volume descriptor.
Parameters:
removal_bytes - The number of bytes to remove.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# The 'removal' parameter is expected to be in bytes, but the space
# size we track is in extents. Round up to the next extent.
self.space_size -= utils.ceiling_div(removal_bytes, self.log_block_size)
|
python
|
def remove_from_space_size(self, removal_bytes):
# type: (int) -> None
'''
Remove bytes from the volume descriptor.
Parameters:
removal_bytes - The number of bytes to remove.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# The 'removal' parameter is expected to be in bytes, but the space
# size we track is in extents. Round up to the next extent.
self.space_size -= utils.ceiling_div(removal_bytes, self.log_block_size)
|
[
"def",
"remove_from_space_size",
"(",
"self",
",",
"removal_bytes",
")",
":",
"# type: (int) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# The 'removal' parameter is expected to be in bytes, but the space",
"# size we track is in extents. Round up to the next extent.",
"self",
".",
"space_size",
"-=",
"utils",
".",
"ceiling_div",
"(",
"removal_bytes",
",",
"self",
".",
"log_block_size",
")"
] |
Remove bytes from the volume descriptor.
Parameters:
removal_bytes - The number of bytes to remove.
Returns:
Nothing.
|
[
"Remove",
"bytes",
"from",
"the",
"volume",
"descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L565-L579
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.add_to_ptr_size
|
def add_to_ptr_size(self, ptr_size):
# type: (int) -> bool
'''
Add the space for a path table record to the volume descriptor.
Parameters:
ptr_size - The length of the Path Table Record being added to this Volume Descriptor.
Returns:
True if extents need to be added to the Volume Descriptor, False otherwise.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# First add to the path table size.
self.path_tbl_size += ptr_size
if (utils.ceiling_div(self.path_tbl_size, 4096) * 2) > self.path_table_num_extents:
# If we overflowed the path table size, then we need to update the
# space size. Since we always add two extents for the little and
# two for the big, add four total extents. The locations will be
# fixed up during reshuffle_extents.
self.path_table_num_extents += 2
return True
return False
|
python
|
def add_to_ptr_size(self, ptr_size):
# type: (int) -> bool
'''
Add the space for a path table record to the volume descriptor.
Parameters:
ptr_size - The length of the Path Table Record being added to this Volume Descriptor.
Returns:
True if extents need to be added to the Volume Descriptor, False otherwise.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# First add to the path table size.
self.path_tbl_size += ptr_size
if (utils.ceiling_div(self.path_tbl_size, 4096) * 2) > self.path_table_num_extents:
# If we overflowed the path table size, then we need to update the
# space size. Since we always add two extents for the little and
# two for the big, add four total extents. The locations will be
# fixed up during reshuffle_extents.
self.path_table_num_extents += 2
return True
return False
|
[
"def",
"add_to_ptr_size",
"(",
"self",
",",
"ptr_size",
")",
":",
"# type: (int) -> bool",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# First add to the path table size.",
"self",
".",
"path_tbl_size",
"+=",
"ptr_size",
"if",
"(",
"utils",
".",
"ceiling_div",
"(",
"self",
".",
"path_tbl_size",
",",
"4096",
")",
"*",
"2",
")",
">",
"self",
".",
"path_table_num_extents",
":",
"# If we overflowed the path table size, then we need to update the",
"# space size. Since we always add two extents for the little and",
"# two for the big, add four total extents. The locations will be",
"# fixed up during reshuffle_extents.",
"self",
".",
"path_table_num_extents",
"+=",
"2",
"return",
"True",
"return",
"False"
] |
Add the space for a path table record to the volume descriptor.
Parameters:
ptr_size - The length of the Path Table Record being added to this Volume Descriptor.
Returns:
True if extents need to be added to the Volume Descriptor, False otherwise.
|
[
"Add",
"the",
"space",
"for",
"a",
"path",
"table",
"record",
"to",
"the",
"volume",
"descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L613-L635
|
train
|
clalancette/pycdlib
|
pycdlib/headervd.py
|
PrimaryOrSupplementaryVD.remove_from_ptr_size
|
def remove_from_ptr_size(self, ptr_size):
# type: (int) -> bool
'''
Remove the space for a path table record from the volume descriptor.
Parameters:
ptr_size - The length of the Path Table Record being removed from this Volume Descriptor.
Returns:
True if extents need to be removed from the Volume Descriptor, False otherwise.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# Next remove from the Path Table Record size.
self.path_tbl_size -= ptr_size
new_extents = utils.ceiling_div(self.path_tbl_size, 4096) * 2
need_remove_extents = False
if new_extents > self.path_table_num_extents:
# This should never happen.
raise pycdlibexception.PyCdlibInvalidInput('This should never happen')
elif new_extents < self.path_table_num_extents:
self.path_table_num_extents -= 2
need_remove_extents = True
return need_remove_extents
|
python
|
def remove_from_ptr_size(self, ptr_size):
# type: (int) -> bool
'''
Remove the space for a path table record from the volume descriptor.
Parameters:
ptr_size - The length of the Path Table Record being removed from this Volume Descriptor.
Returns:
True if extents need to be removed from the Volume Descriptor, False otherwise.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
# Next remove from the Path Table Record size.
self.path_tbl_size -= ptr_size
new_extents = utils.ceiling_div(self.path_tbl_size, 4096) * 2
need_remove_extents = False
if new_extents > self.path_table_num_extents:
# This should never happen.
raise pycdlibexception.PyCdlibInvalidInput('This should never happen')
elif new_extents < self.path_table_num_extents:
self.path_table_num_extents -= 2
need_remove_extents = True
return need_remove_extents
|
[
"def",
"remove_from_ptr_size",
"(",
"self",
",",
"ptr_size",
")",
":",
"# type: (int) -> bool",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'This Volume Descriptor is not yet initialized'",
")",
"# Next remove from the Path Table Record size.",
"self",
".",
"path_tbl_size",
"-=",
"ptr_size",
"new_extents",
"=",
"utils",
".",
"ceiling_div",
"(",
"self",
".",
"path_tbl_size",
",",
"4096",
")",
"*",
"2",
"need_remove_extents",
"=",
"False",
"if",
"new_extents",
">",
"self",
".",
"path_table_num_extents",
":",
"# This should never happen.",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidInput",
"(",
"'This should never happen'",
")",
"elif",
"new_extents",
"<",
"self",
".",
"path_table_num_extents",
":",
"self",
".",
"path_table_num_extents",
"-=",
"2",
"need_remove_extents",
"=",
"True",
"return",
"need_remove_extents"
] |
Remove the space for a path table record from the volume descriptor.
Parameters:
ptr_size - The length of the Path Table Record being removed from this Volume Descriptor.
Returns:
True if extents need to be removed from the Volume Descriptor, False otherwise.
|
[
"Remove",
"the",
"space",
"for",
"a",
"path",
"table",
"record",
"from",
"the",
"volume",
"descriptor",
"."
] |
1e7b77a809e905d67dc71e12d70e850be26b6233
|
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/headervd.py#L637-L662
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.