idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
20,100 | def record_ce_entries ( self ) : # type: () -> bytes if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Rock Ridge extension not yet initialized' ) return self . _record ( self . ce_entries ) | Return a string representing the Rock Ridge entries in the Continuation Entry . | 60 | 14 |
20,101 | def _add_ce_record ( self , curr_dr_len , thislen ) : # type: (int, int) -> int if self . dr_entries . ce_record is None : self . dr_entries . ce_record = RRCERecord ( ) self . dr_entries . ce_record . new ( ) curr_dr_len += RRCERecord . length ( ) self . dr_entries . ce_record . add_record ( thislen ) return curr_dr_len | An internal method to add a new length to a Continuation Entry . If the Continuation Entry does not yet exist this method creates it . | 118 | 28 |
20,102 | def _add_name ( self , rr_name , curr_dr_len ) : # type: (bytes, int) -> int # The length we are putting in this object (as opposed to the # continuation entry) is the maximum, minus how much is already in the # DR, minus 5 for the NM metadata. We know that at least part of the # NM record will always fit in this DR. That's because the DR is a # maximum size of 255, and the ISO9660 fields uses a maximum of 34 bytes # for metadata and 8+1+3+1+5 (8 for name, 1 for dot, 3 for extension, # 1 for semicolon, and 5 for version number, allowed up to 32767), which # leaves the System Use entry with 255 - 34 - 18 = 203 bytes. Before # this record, the only records we ever put in place could be the SP or # the RR record, and the combination of them is never > 203, so we will # always put some NM data in here. len_here = ALLOWED_DR_SIZE - curr_dr_len - 5 if len_here < len ( rr_name ) : curr_dr_len = self . _add_ce_record ( curr_dr_len , 0 ) len_here = ALLOWED_DR_SIZE - curr_dr_len - 5 curr_nm = RRNMRecord ( ) curr_nm . new ( rr_name [ : len_here ] ) self . dr_entries . nm_records . append ( curr_nm ) curr_dr_len += RRNMRecord . length ( rr_name [ : len_here ] ) offset = len_here while offset < len ( rr_name ) : curr_nm . set_continued ( ) # We clip the length for this NM entry to 250, as that is # the maximum possible size for an NM entry. length = min ( len ( rr_name [ offset : ] ) , 250 ) curr_nm = RRNMRecord ( ) curr_nm . new ( rr_name [ offset : offset + length ] ) self . ce_entries . nm_records . append ( curr_nm ) if self . dr_entries . ce_record is not None : self . dr_entries . ce_record . add_record ( RRNMRecord . length ( rr_name [ offset : offset + length ] ) ) offset += length return curr_dr_len | An internal method to add the appropriate name records to the ISO . | 546 | 13 |
20,103 | def add_to_file_links ( self ) : # type: () -> None if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Rock Ridge extension not yet initialized' ) if self . dr_entries . px_record is None : if self . ce_entries . px_record is None : raise pycdlibexception . PyCdlibInvalidInput ( 'No Rock Ridge file links' ) self . ce_entries . px_record . posix_file_links += 1 else : self . dr_entries . px_record . posix_file_links += 1 | Increment the number of POSIX file links on this entry by one . | 142 | 15 |
20,104 | def copy_file_links ( self , src ) : # type: (RockRidge) -> None if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Rock Ridge extension not yet initialized' ) # First, get the src data if src . dr_entries . px_record is None : if src . ce_entries . px_record is None : raise pycdlibexception . PyCdlibInvalidInput ( 'No Rock Ridge file links' ) num_links = src . ce_entries . px_record . posix_file_links else : num_links = src . dr_entries . px_record . posix_file_links # Now apply it to this record. if self . dr_entries . px_record is None : if self . ce_entries . px_record is None : raise pycdlibexception . PyCdlibInvalidInput ( 'No Rock Ridge file links' ) self . ce_entries . px_record . posix_file_links = num_links else : self . dr_entries . px_record . posix_file_links = num_links | Copy the number of file links from the source Rock Ridge entry into this Rock Ridge entry . | 263 | 18 |
20,105 | def get_file_mode ( self ) : # type: () -> int if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Rock Ridge extension not yet initialized' ) if self . dr_entries . px_record is None : if self . ce_entries . px_record is None : raise pycdlibexception . PyCdlibInvalidInput ( 'No Rock Ridge file mode' ) return self . ce_entries . px_record . posix_file_mode return self . dr_entries . px_record . posix_file_mode | Get the POSIX file mode bits for this Rock Ridge entry . | 136 | 13 |
20,106 | 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 . | 51 | 15 |
20,107 | 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 . | 142 | 14 |
20,108 | 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 . | 142 | 14 |
20,109 | 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 . | 62 | 14 |
20,110 | 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 . | 209 | 13 |
20,111 | 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 . | 274 | 50 |
20,112 | 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 . | 93 | 16 |
20,113 | 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 . | 146 | 18 |
20,114 | 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 . | 119 | 15 |
20,115 | 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 . | 83 | 17 |
20,116 | def _compute_csum ( data ) : # type: (bytes) -> int 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 | A method to compute a simple checksum over the given data . | 135 | 13 |
20,117 | 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 . | 265 | 17 |
20,118 | 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 . | 64 | 16 |
20,119 | 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 . | 202 | 15 |
20,120 | 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 . | 74 | 15 |
20,121 | 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 . | 110 | 13 |
20,122 | 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 . | 77 | 16 |
20,123 | 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 . | 477 | 15 |
20,124 | 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 . | 231 | 15 |
20,125 | 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 . | 101 | 13 |
20,126 | 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 . | 140 | 15 |
20,127 | 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 . | 126 | 15 |
20,128 | 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 . | 137 | 13 |
20,129 | 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 . | 129 | 14 |
20,130 | 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 ''' 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 | Parse the passed in data into a UDF Timestamp . | 499 | 13 |
20,131 | 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 . | 152 | 13 |
20,132 | 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 . | 209 | 11 |
20,133 | 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 . | 81 | 13 |
20,134 | 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 . | 64 | 13 |
20,135 | 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 . | 187 | 11 |
20,136 | 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 . | 574 | 16 |
20,137 | 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 . | 241 | 16 |
20,138 | 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 . | 530 | 14 |
20,139 | 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 . | 148 | 20 |
20,140 | 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 . | 113 | 20 |
20,141 | 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 . | 189 | 18 |
20,142 | 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 . | 233 | 17 |
20,143 | 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 . | 165 | 15 |
20,144 | 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 . | 518 | 17 |
20,145 | 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 . | 315 | 17 |
20,146 | 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 . | 173 | 17 |
20,147 | 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 . | 282 | 15 |
20,148 | 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 . | 67 | 13 |
20,149 | 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 . | 190 | 14 |
20,150 | 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 . | 66 | 12 |
20,151 | 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 . | 99 | 13 |
20,152 | 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 . | 80 | 13 |
20,153 | 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 . | 107 | 11 |
20,154 | 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 . | 99 | 14 |
20,155 | 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 . | 477 | 17 |
20,156 | 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 . | 191 | 17 |
20,157 | 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 . | 317 | 15 |
20,158 | 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 . | 71 | 17 |
20,159 | 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 . | 175 | 18 |
20,160 | 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 . | 81 | 16 |
20,161 | 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 . | 92 | 16 |
20,162 | 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 . | 84 | 14 |
20,163 | 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 . | 103 | 16 |
20,164 | 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 . | 85 | 18 |
20,165 | 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 . | 59 | 16 |
20,166 | 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 . | 160 | 16 |
20,167 | 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 . | 120 | 16 |
20,168 | 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 . | 157 | 14 |
20,169 | 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 . | 590 | 18 |
20,170 | 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 . | 153 | 18 |
20,171 | 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 . | 208 | 16 |
20,172 | 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 . | 577 | 16 |
20,173 | 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 . | 203 | 16 |
20,174 | 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 . | 328 | 14 |
20,175 | 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 . | 68 | 16 |
20,176 | 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 . | 209 | 14 |
20,177 | 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 . | 123 | 14 |
20,178 | 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 . | 264 | 12 |
20,179 | 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 . | 642 | 13 |
20,180 | 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 . | 252 | 13 |
20,181 | 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 . | 733 | 11 |
20,182 | 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 . | 341 | 21 |
20,183 | 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 . | 454 | 20 |
20,184 | 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 . | 122 | 18 |
20,185 | 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 . | 333 | 18 |
20,186 | 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 . | 66 | 17 |
20,187 | 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 . | 311 | 15 |
20,188 | 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 . | 74 | 47 |
20,189 | 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 . | 85 | 32 |
20,190 | 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 . | 82 | 20 |
20,191 | 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 . | 491 | 17 |
20,192 | 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 . | 264 | 17 |
20,193 | 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 . | 320 | 12 |
20,194 | 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 . | 78 | 35 |
20,195 | 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 . | 231 | 12 |
20,196 | 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 . | 233 | 15 |
20,197 | 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 . | 327 | 13 |
20,198 | 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 . | 671 | 19 |
20,199 | 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 . | 458 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.