idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
20,200 | def _is_symlink ( self ) : 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 . |
20,201 | def child_link_extent ( self ) : 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 . |
20,202 | def parent_link_extent ( self ) : 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 . |
20,203 | def update_ce_block ( self , block ) : 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 . |
20,204 | def track_entry ( self , offset , length ) : 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' ) if offset + length > self . _max_block_size : raise pycdlibexception . PyCdlibInvalidISO ( 'No room in continuation block to track entry' ) bisect . insort_left ( self . _entries , RockRidgeContinuationEntry ( offset , length ) ) | Track an already allocated entry in this Rock Ridge Continuation Block . |
20,205 | def add_entry ( self , length ) : offset = - 1 for index , entry in enumerate ( self . _entries ) : if index == 0 : if entry . offset != 0 and length <= entry . offset : offset = 0 break else : lastentry = self . _entries [ index - 1 ] lastend = lastentry . offset + lastentry . length - 1 gapsize = entry . offset - lastend - 1 if gapsize >= length : offset = lastend + 1 break else : 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 . |
20,206 | def remove_entry ( self , offset , length ) : 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 . |
20,207 | def crc_ccitt ( data ) : crc = 0 if not have_py_3 : for x in data : crc = crc_ccitt_table [ ord ( x ) ^ ( ( crc >> 8 ) & 0xFF ) ] ^ ( ( crc << 8 ) & 0xFF00 ) 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 . |
20,208 | def _ostaunicode ( src ) : if have_py_3 : bytename = src else : bytename = src . decode ( 'utf-8' ) 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 . |
20,209 | def _ostaunicode_zero_pad ( src , fulllen ) : 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 . |
20,210 | def _compute_csum ( data ) : def identity ( x ) : 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 . |
20,211 | def symlink_to_bytes ( symlink_target ) : symlink_data = bytearray ( ) for comp in symlink_target . split ( '/' ) : if comp == '' : 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 . |
20,212 | def set_extent_location ( self , extent ) : 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 . |
20,213 | def parse ( self , data , extent ) : 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 . |
20,214 | def record ( self ) : 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 . |
20,215 | def new ( self , version ) : 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 . |
20,216 | def extent_location ( self ) : 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 . |
20,217 | def parse ( self , data , extent ) : 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 : 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 . |
20,218 | def record ( self , crc_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 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 . |
20,219 | def new ( self , tag_ident , tag_serial = 0 ) : 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 self . _initialized = True | A method to create a new UDF Descriptor Tag . |
20,220 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,221 | def record ( self ) : 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 . |
20,222 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Anchor Volume Structure already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 2 ) self . main_vd_length = 32768 self . main_vd_extent = 0 self . reserve_vd_length = 32768 self . reserve_vd_extent = 0 self . _initialized = True | A method to create a new UDF Anchor Volume Structure . |
20,223 | def set_extent_location ( self , new_location , main_vd_extent , reserve_vd_extent ) : 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 . |
20,224 | def parse ( self , data ) : 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 ) : if ( val & ( 1 << ( bits - 1 ) ) ) != 0 : val = val - ( 1 << bits ) return val 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 . |
20,225 | def record ( self ) : 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 . |
20,226 | def new ( self ) : 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 ) 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 . |
20,227 | def parse ( self , data ) : 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 . |
20,228 | def record ( self ) : 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 . |
20,229 | def new ( self , flags = 0 , identifier = b'' , suffix = b'' ) : 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 . |
20,230 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,231 | def record ( self ) : 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 . |
20,232 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Primary Volume Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 1 ) self . vol_desc_seqnum = 0 self . desc_num = 0 self . vol_ident = _ostaunicode_zero_pad ( 'CDROM' , 32 ) 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 self . vol_abstract_extent = 0 self . vol_copyright_length = 0 self . vol_copyright_extent = 0 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 self . predecessor_vol_desc_location = 0 self . max_interchange_level = 2 self . _initialized = True | A method to create a new UDF Primary Volume Descriptor . |
20,233 | def parse ( self , data ) : 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 . |
20,234 | def record ( self ) : 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 . |
20,235 | def new ( self ) : 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 . |
20,236 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,237 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Implementation Use Volume Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 4 ) 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 . |
20,238 | def parse ( self , data ) : 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 . |
20,239 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,240 | def record ( self ) : 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 . |
20,241 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Partition Volume Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 5 ) self . vol_desc_seqnum = 2 self . part_flags = 1 self . part_num = 0 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 self . part_length = 3 self . impl_ident = UDFEntityID ( ) self . impl_ident . new ( 0 , b'*pycdlib' ) self . implementation_use = b'\x00' * 128 self . _initialized = True | A method to create a new UDF Partition Volume Descriptor . |
20,242 | def set_start_location ( self , new_location ) : 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 . |
20,243 | def parse ( self , data ) : 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 . |
20,244 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Partition Map already initialized' ) self . part_num = 0 self . _initialized = True | A method to create a new UDF Partition Map . |
20,245 | def parse ( self , data ) : 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 . |
20,246 | def record ( self ) : 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 . |
20,247 | def new ( self , length , blocknum ) : 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 self . impl_use = b'\x00' * 6 self . _initialized = True | A method to create a new UDF Long AD . |
20,248 | def set_extent_location ( self , new_location , tag_location ) : 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 . |
20,249 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,250 | def record ( self ) : 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 . |
20,251 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Logical Volume Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 6 ) 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 self . integrity_sequence_length = 4096 self . integrity_sequence_extent = 0 self . partition_map = UDFPartitionMap ( ) self . partition_map . new ( ) self . _initialized = True | A method to create a new UDF Logical Volume Descriptor . |
20,252 | def set_integrity_location ( self , integrity_extent ) : 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 . |
20,253 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,254 | def parse ( self , extent , desc_tag ) : 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 . |
20,255 | def record ( self ) : 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 . |
20,256 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Terminating Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 8 ) self . _initialized = True | A method to create a new UDF Terminating Descriptor . |
20,257 | def set_extent_location ( self , new_location , tag_location = 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 . |
20,258 | def parse ( self , data ) : 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 . |
20,259 | def new ( self ) : 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 . |
20,260 | def parse ( self , data ) : 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 . |
20,261 | def record ( self ) : 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 . |
20,262 | def new ( self ) : 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 self . _initialized = True | A method to create a new UDF Logical Volume Implementation Use . |
20,263 | def parse ( self , data , extent , desc_tag ) : 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' ) 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 . |
20,264 | def record ( self ) : 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 . |
20,265 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF Logical Volume Integrity Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 9 ) self . recording_date = UDFTimestamp ( ) self . recording_date . new ( ) self . length_impl_use = 46 self . free_space_table = 0 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 . |
20,266 | def parse ( self , data , extent , desc_tag ) : 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 . |
20,267 | def record ( self ) : 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 . |
20,268 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF File Set Descriptor already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 256 ) 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 self . abstract_file_ident = b'\x00' * 32 self . _initialized = True | A method to create a new UDF File Set Descriptor . |
20,269 | def set_extent_location ( self , new_location ) : 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 . |
20,270 | def parse ( self , data ) : 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 . |
20,271 | def record ( self ) : 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 . |
20,272 | def new ( self , file_type ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF ICB Tag already initialized' ) self . prior_num_direct_entries = 0 self . strategy_type = 4 self . strategy_param = 0 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 self . parent_icb_part_ref_num = 0 self . flags = 560 self . _initialized = True | A method to create a new UDF ICB Tag . |
20,273 | def parse ( self , data , extent , parent , desc_tag ) : 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 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 . |
20,274 | def record ( self ) : 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 . |
20,275 | def new ( self , length , file_type , parent , log_block_size ) : 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 ) self . icb_tag = UDFICBTag ( ) self . icb_tag . new ( file_type ) self . uid = 4294967295 self . gid = 4294967295 if file_type == 'dir' : self . perms = 5285 self . file_link_count = 0 self . info_len = 0 self . log_block_recorded = 1 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 : alloc_len = min ( len_left , 0x3ffff800 ) 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 self . len_extended_attrs = 0 self . extended_attrs = b'' self . parent = parent self . _initialized = True | A method to create a new UDF File Entry . |
20,276 | def add_file_ident_desc ( self , new_fi_desc , logical_block_size ) : 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 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 . |
20,277 | def remove_file_ident_desc_by_name ( self , name , logical_block_size ) : 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 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 . |
20,278 | def set_data_location ( self , current_extent , start_extent ) : 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 . |
20,279 | def set_data_length ( self , length ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) len_diff = length - self . info_len if len_diff > 0 : 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 : 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 . |
20,280 | def file_identifier ( self ) : 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 . |
20,281 | def find_file_ident_desc_by_name ( self , currpath ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF File Entry not initialized' ) 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 . |
20,282 | def track_file_ident_desc ( self , file_ident ) : 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 . |
20,283 | def finish_directory_parse ( self ) : 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 . |
20,284 | def length ( cls , namelen ) : 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 . |
20,285 | def parse ( self , data , extent , desc_tag , parent ) : 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 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 . |
20,286 | def record ( self ) : 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 . |
20,287 | def new ( self , isdir , isparent , name , parent ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'UDF File Identifier already initialized' ) self . desc_tag = UDFTag ( ) self . desc_tag . new ( 257 ) 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 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 . |
20,288 | def set_icb ( self , new_location , tag_location ) : 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 . |
20,289 | 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 ) : 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 . |
20,290 | 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 ) : 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 . |
20,291 | 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 ) : 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 . |
20,292 | def copy ( self , orig ) : 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 self . root_dir_record = orig . root_dir_record self . volume_set_identifier = orig . volume_set_identifier self . publisher_identifier = orig . publisher_identifier self . preparer_identifier = orig . preparer_identifier 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 self . volume_creation_date = orig . volume_creation_date self . volume_expiration_date = orig . volume_expiration_date 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 . |
20,293 | def record ( self ) : 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 . |
20,294 | def track_rr_ce_entry ( self , extent , offset , length ) : 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 : 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 . |
20,295 | def clear_rr_ce_entries ( self ) : 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 . |
20,296 | def add_to_space_size ( self , addition_bytes ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This Volume Descriptor is not yet initialized' ) 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 . |
20,297 | def remove_from_space_size ( self , removal_bytes ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This Volume Descriptor is not yet initialized' ) self . space_size -= utils . ceiling_div ( removal_bytes , self . log_block_size ) | Remove bytes from the volume descriptor . |
20,298 | def add_to_ptr_size ( self , ptr_size ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This Volume Descriptor is not yet initialized' ) self . path_tbl_size += ptr_size if ( utils . ceiling_div ( self . path_tbl_size , 4096 ) * 2 ) > self . path_table_num_extents : self . path_table_num_extents += 2 return True return False | Add the space for a path table record to the volume descriptor . |
20,299 | def remove_from_ptr_size ( self , ptr_size ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This Volume Descriptor is not yet initialized' ) 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 : 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.