idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
20,100 | def file_object_supports_binary ( fp ) : if hasattr ( fp , 'mode' ) : return 'b' in fp . mode if sys . version_info >= ( 3 , 0 ) : return isinstance ( fp , ( io . RawIOBase , io . BufferedIOBase ) ) return isinstance ( fp , ( cStringIO . OutputType , cStringIO . InputType , io . RawIOBase , io . BufferedIOBase ) ) | A function to check whether a file - like object supports binary mode . |
20,101 | def parse ( self , instr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This IsoHybrid object is already initialized' ) if len ( instr ) != 512 : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid size of the instr' ) if instr [ 0 : 32 ] == self . ORIG_HEADER : self . header = self . ORIG_HEADER elif instr [ 0 : 32 ] == self . MAC_AFP : self . header = self . MAC_AFP else : return False ( self . mbr , self . rba , unused1 , self . mbr_id , unused2 ) = struct . unpack_from ( self . FMT , instr [ : 32 + struct . calcsize ( self . FMT ) ] , 32 ) if unused1 != 0 : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid IsoHybrid section' ) if unused2 != 0 : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid IsoHybrid section' ) offset = 32 + struct . calcsize ( self . FMT ) for i in range ( 1 , 5 ) : if bytes ( bytearray ( [ instr [ offset ] ] ) ) == b'\x80' : self . part_entry = i ( const_unused , self . bhead , self . bsect , self . bcyle , self . ptype , self . ehead , self . esect , self . ecyle , self . part_offset , self . psize ) = struct . unpack_from ( '=BBBBBBBBLL' , instr [ : offset + 16 ] , offset ) break offset += 16 else : raise pycdlibexception . PyCdlibInvalidISO ( 'No valid partition found in IsoHybrid!' ) if bytes ( bytearray ( [ instr [ - 2 ] ] ) ) != b'\x55' or bytes ( bytearray ( [ instr [ - 1 ] ] ) ) != b'\xaa' : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid tail on isohybrid section' ) self . geometry_heads = self . ehead + 1 self . geometry_sectors = 32 self . _initialized = True return True | A method to parse ISO hybridization info out of an existing ISO . |
20,102 | def new ( self , mac , part_entry , mbr_id , part_offset , geometry_sectors , geometry_heads , part_type ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This IsoHybrid object is already initialized' ) if mac : self . header = self . MAC_AFP else : self . header = self . ORIG_HEADER isohybrid_data_hd0 = b'\x33\xed\xfa\x8e\xd5\xbc\x00\x7c\xfb\xfc\x66\x31\xdb\x66\x31\xc9\x66\x53\x66\x51\x06\x57\x8e\xdd\x8e\xc5\x52\xbe\x00\x7c\xbf\x00\x06\xb9\x00\x01\xf3\xa5\xea\x4b\x06\x00\x00\x52\xb4\x41\xbb\xaa\x55\x31\xc9\x30\xf6\xf9\xcd\x13\x72\x16\x81\xfb\x55\xaa\x75\x10\x83\xe1\x01\x74\x0b\x66\xc7\x06\xf1\x06\xb4\x42\xeb\x15\xeb\x00\x5a\x51\xb4\x08\xcd\x13\x83\xe1\x3f\x5b\x51\x0f\xb6\xc6\x40\x50\xf7\xe1\x53\x52\x50\xbb\x00\x7c\xb9\x04\x00\x66\xa1\xb0\x07\xe8\x44\x00\x0f\x82\x80\x00\x66\x40\x80\xc7\x02\xe2\xf2\x66\x81\x3e\x40\x7c\xfb\xc0\x78\x70\x75\x09\xfa\xbc\xec\x7b\xea\x44\x7c\x00\x00\xe8\x83\x00\x69\x73\x6f\x6c\x69\x6e\x75\x78\x2e\x62\x69\x6e\x20\x6d\x69\x73\x73\x69\x6e\x67\x20\x6f\x72\x20\x63\x6f\x72\x72\x75\x70\x74\x2e\x0d\x0a\x66\x60\x66\x31\xd2\x66\x03\x06\xf8\x7b\x66\x13\x16\xfc\x7b\x66\x52\x66\x50\x06\x53\x6a\x01\x6a\x10\x89\xe6\x66\xf7\x36\xe8\x7b\xc0\xe4\x06\x88\xe1\x88\xc5\x92\xf6\x36\xee\x7b\x88\xc6\x08\xe1\x41\xb8\x01\x02\x8a\x16\xf2\x7b\xcd\x13\x8d\x64\x10\x66\x61\xc3\xe8\x1e\x00\x4f\x70\x65\x72\x61\x74\x69\x6e\x67\x20\x73\x79\x73\x74\x65\x6d\x20\x6c\x6f\x61\x64\x20\x65\x72\x72\x6f\x72\x2e\x0d\x0a\x5e\xac\xb4\x0e\x8a\x3e\x62\x04\xb3\x07\xcd\x10\x3c\x0a\x75\xf1\xcd\x18\xf4\xeb\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' self . mbr = isohybrid_data_hd0 self . rba = 0 self . mbr_id = mbr_id if self . mbr_id is None : self . mbr_id = random . getrandbits ( 32 ) self . part_entry = part_entry self . bhead = ( part_offset // geometry_sectors ) % geometry_heads self . bsect = ( part_offset % geometry_sectors ) + 1 self . bcyle = part_offset // ( geometry_heads * geometry_sectors ) self . bsect += ( self . bcyle & 0x300 ) >> 2 self . bcyle &= 0xff self . ptype = part_type self . ehead = geometry_heads - 1 self . part_offset = part_offset self . geometry_heads = geometry_heads self . geometry_sectors = geometry_sectors self . _initialized = True | A method to add ISO hybridization to an ISO . |
20,103 | def _calc_cc ( self , iso_size ) : cylsize = self . geometry_heads * self . geometry_sectors * 512 frac = iso_size % cylsize padding = 0 if frac > 0 : padding = cylsize - frac cc = ( iso_size + padding ) // cylsize if cc > 1024 : cc = 1024 return ( cc , padding ) | A method to calculate the cc and the padding values for this hybridization . |
20,104 | def record ( self , iso_size ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This IsoHybrid object is not yet initialized' ) outlist = [ struct . pack ( '=32s400sLLLH' , self . header , self . mbr , self . rba , 0 , self . mbr_id , 0 ) ] for i in range ( 1 , 5 ) : if i == self . part_entry : cc , padding_unused = self . _calc_cc ( iso_size ) esect = self . geometry_sectors + ( ( ( cc - 1 ) & 0x300 ) >> 2 ) ecyle = ( cc - 1 ) & 0xff psize = cc * self . geometry_heads * self . geometry_sectors - self . part_offset outlist . append ( struct . pack ( '=BBBBBBBBLL' , 0x80 , self . bhead , self . bsect , self . bcyle , self . ptype , self . ehead , esect , ecyle , self . part_offset , psize ) ) else : outlist . append ( b'\x00' * 16 ) outlist . append ( b'\x55\xaa' ) return b'' . join ( outlist ) | A method to generate a string containing the ISO hybridization . |
20,105 | def record_padding ( self , iso_size ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This IsoHybrid object is not yet initialized' ) return b'\x00' * self . _calc_cc ( iso_size ) [ 1 ] | A method to record padding for the ISO hybridization . |
20,106 | def update_rba ( self , current_extent ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This IsoHybrid object is not yet initialized' ) self . rba = current_extent | A method to update the current rba for the ISO hybridization . |
20,107 | def parse ( self , xastr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This XARecord is already initialized!' ) ( self . _group_id , self . _user_id , self . _attributes , signature , self . _filenum , unused ) = struct . unpack_from ( self . FMT , xastr , 0 ) if signature != b'XA' : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid signature on the XARecord!' ) if unused != b'\x00\x00\x00\x00\x00' : raise pycdlibexception . PyCdlibInvalidISO ( 'Unused fields should be 0' ) self . _initialized = True | Parse an Extended Attribute Record out of a string . |
20,108 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This XARecord is already initialized!' ) self . _group_id = 0 self . _user_id = 0 self . _attributes = 0 self . _filenum = 0 self . _initialized = True | Create a new Extended Attribute Record . |
20,109 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This XARecord is not yet initialized!' ) return struct . pack ( self . FMT , self . _group_id , self . _user_id , self . _attributes , b'XA' , self . _filenum , b'\x00' * 5 ) | Record this Extended Attribute Record . |
20,110 | def _new ( self , vd , name , parent , seqnum , isdir , length , xa ) : self . date = dates . DirectoryRecordDate ( ) self . date . new ( ) if length > 2 ** 32 - 1 : raise pycdlibexception . PyCdlibInvalidInput ( 'Maximum supported file length is 2^32-1' ) self . data_length = length self . file_ident = name self . isdir = isdir self . seqnum = seqnum self . orig_extent_loc = None self . len_fi = len ( self . file_ident ) self . dr_len = struct . calcsize ( self . FMT ) + self . len_fi self . file_flags = 0 if self . isdir : self . file_flags |= ( 1 << self . FILE_FLAG_DIRECTORY_BIT ) self . file_unit_size = 0 self . interleave_gap_size = 0 self . xattr_len = 0 self . parent = parent if parent is None : self . is_root = True if xa : self . xa_record = XARecord ( ) self . xa_record . new ( ) self . dr_len += XARecord . length ( ) self . dr_len += ( self . dr_len % 2 ) if self . is_root : self . _printable_name = b'/' elif self . file_ident == b'\x00' : self . _printable_name = b'.' elif self . file_ident == b'\x01' : self . _printable_name = b'..' else : self . _printable_name = self . file_ident self . vd = vd self . _initialized = True | Internal method to create a new Directory Record . |
20,111 | def new_symlink ( self , vd , name , parent , rr_target , seqnum , rock_ridge , rr_name , xa ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record already initialized' ) self . _new ( vd , name , parent , seqnum , False , 0 , xa ) if rock_ridge : self . _rr_new ( rock_ridge , rr_name , rr_target , False , False , False , 0o0120555 ) | Create a new symlink Directory Record . This implies that the new record will be Rock Ridge . |
20,112 | def new_file ( self , vd , length , isoname , parent , seqnum , rock_ridge , rr_name , xa , file_mode ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record already initialized' ) self . _new ( vd , isoname , parent , seqnum , False , length , xa ) if rock_ridge : self . _rr_new ( rock_ridge , rr_name , b'' , False , False , False , file_mode ) | Create a new file Directory Record . |
20,113 | def new_root ( self , vd , seqnum , log_block_size ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record already initialized' ) self . _new ( vd , b'\x00' , None , seqnum , True , log_block_size , False ) | Create a new root Directory Record . |
20,114 | def new_dot ( self , vd , parent , seqnum , rock_ridge , log_block_size , xa , file_mode ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record already initialized' ) self . _new ( vd , b'\x00' , parent , seqnum , True , log_block_size , xa ) if rock_ridge : self . _rr_new ( rock_ridge , b'' , b'' , False , False , False , file_mode ) | Create a new dot Directory Record . |
20,115 | def new_dotdot ( self , vd , parent , seqnum , rock_ridge , log_block_size , rr_relocated_parent , xa , file_mode ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record already initialized' ) self . _new ( vd , b'\x01' , parent , seqnum , True , log_block_size , xa ) if rock_ridge : self . _rr_new ( rock_ridge , b'' , b'' , False , False , rr_relocated_parent , file_mode ) | Create a new dotdot Directory Record . |
20,116 | def new_dir ( self , vd , name , parent , seqnum , rock_ridge , rr_name , log_block_size , rr_relocated_child , rr_relocated , xa , file_mode ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record already initialized' ) self . _new ( vd , name , parent , seqnum , True , log_block_size , xa ) if rock_ridge : self . _rr_new ( rock_ridge , rr_name , b'' , rr_relocated_child , rr_relocated , False , file_mode ) if rr_relocated_child and self . rock_ridge : self . isdir = False self . file_flags = 0 self . rock_ridge . add_to_file_links ( ) | Create a new directory Directory Record . |
20,117 | def change_existence ( self , is_hidden ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) if is_hidden : self . file_flags |= ( 1 << self . FILE_FLAG_EXISTENCE_BIT ) else : self . file_flags &= ~ ( 1 << self . FILE_FLAG_EXISTENCE_BIT ) | Change the ISO9660 existence flag of this Directory Record . |
20,118 | def _recalculate_extents_and_offsets ( self , index , logical_block_size ) : if index == 0 : dirrecord_offset = 0 num_extents = 1 else : dirrecord_offset = self . children [ index - 1 ] . offset_to_here num_extents = self . children [ index - 1 ] . extents_to_here for i in range ( index , len ( self . children ) ) : c = self . children [ i ] dirrecord_len = c . dr_len if ( dirrecord_offset + dirrecord_len ) > logical_block_size : num_extents += 1 dirrecord_offset = 0 dirrecord_offset += dirrecord_len c . extents_to_here = num_extents c . offset_to_here = dirrecord_offset c . index_in_parent = i return num_extents , dirrecord_offset | Internal method to recalculate the extents and offsets associated with children of this directory record . |
20,119 | def _add_child ( self , child , logical_block_size , allow_duplicate , check_overflow ) : if not self . isdir : raise pycdlibexception . PyCdlibInvalidInput ( 'Trying to add a child to a record that is not a directory' ) index = bisect . bisect_left ( self . children , child ) if index != len ( self . children ) and self . children [ index ] . file_ident == child . file_ident : if not self . children [ index ] . is_associated_file ( ) and not child . is_associated_file ( ) : if not ( self . rock_ridge is not None and self . file_identifier ( ) == b'RR_MOVED' ) : if not allow_duplicate : raise pycdlibexception . PyCdlibInvalidInput ( 'Failed adding duplicate name to parent' ) else : self . children [ index ] . data_continuation = child index += 1 self . children . insert ( index , child ) if child . rock_ridge is not None and not child . is_dot ( ) and not child . is_dotdot ( ) : lo = 0 hi = len ( self . rr_children ) while lo < hi : mid = ( lo + hi ) // 2 rr = self . rr_children [ mid ] . rock_ridge if rr is not None : if rr . name ( ) < child . rock_ridge . name ( ) : lo = mid + 1 else : hi = mid else : raise pycdlibexception . PyCdlibInternalError ( 'Expected all children to have Rock Ridge, but one did not' ) rr_index = lo self . rr_children . insert ( rr_index , child ) num_extents , offset_unused = self . _recalculate_extents_and_offsets ( index , logical_block_size ) overflowed = False if check_overflow and ( num_extents * logical_block_size > self . data_length ) : overflowed = True self . data_length += logical_block_size self . children [ 0 ] . data_length = self . data_length if self . parent is None : self . children [ 1 ] . data_length = self . data_length for c in self . children : if not c . is_dir ( ) : continue if len ( c . children ) > 1 : c . children [ 1 ] . data_length = self . data_length return overflowed | An internal method to add a child to this object . Note that this is called both during parsing and when adding a new object to the system so it it shouldn t have any functionality that is not appropriate for both . |
20,120 | def add_child ( self , child , logical_block_size , allow_duplicate = False ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) return self . _add_child ( child , logical_block_size , allow_duplicate , True ) | A method to add a new child to this directory record . |
20,121 | def track_child ( self , child , logical_block_size , allow_duplicate = False ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) self . _add_child ( child , logical_block_size , allow_duplicate , False ) | A method to track an existing child of this directory record . |
20,122 | def remove_child ( self , child , index , logical_block_size ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) if index < 0 : raise pycdlibexception . PyCdlibInternalError ( 'Invalid child index to remove' ) if child . rock_ridge is not None : if child . isdir or child . rock_ridge . child_link_record_exists ( ) : if len ( self . children ) < 2 : raise pycdlibexception . PyCdlibInvalidISO ( 'Expected a dot and dotdot entry, but missing; ISO is corrupt' ) if self . children [ 0 ] . rock_ridge is None or self . children [ 1 ] . rock_ridge is None : raise pycdlibexception . PyCdlibInvalidISO ( 'Missing Rock Ridge entry on dot or dotdot; ISO is corrupt' ) if self . parent is None : self . children [ 0 ] . rock_ridge . remove_from_file_links ( ) self . children [ 1 ] . rock_ridge . remove_from_file_links ( ) else : if self . rock_ridge is None : raise pycdlibexception . PyCdlibInvalidISO ( 'Child has Rock Ridge, but parent does not; ISO is corrupt' ) self . rock_ridge . remove_from_file_links ( ) self . children [ 0 ] . rock_ridge . remove_from_file_links ( ) del self . children [ index ] num_extents , dirrecord_offset = self . _recalculate_extents_and_offsets ( index , logical_block_size ) underflow = False total_size = ( num_extents - 1 ) * logical_block_size + dirrecord_offset if ( self . data_length - total_size ) > logical_block_size : self . data_length -= logical_block_size self . children [ 0 ] . data_length = self . data_length if self . parent is None : self . children [ 1 ] . data_length = self . data_length for c in self . children : if not c . is_dir ( ) : continue if len ( c . children ) > 1 : c . children [ 1 ] . data_length = self . data_length underflow = True return underflow | A method to remove a child from this Directory Record . |
20,123 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) self . date = dates . DirectoryRecordDate ( ) self . date . new ( ) padlen = struct . calcsize ( self . FMT ) + self . len_fi padstr = b'\x00' * ( padlen % 2 ) extent_loc = self . _extent_location ( ) xa_rec = b'' if self . xa_record is not None : xa_rec = b'\x00' * self . xa_pad_size + self . xa_record . record ( ) rr_rec = b'' if self . rock_ridge is not None : rr_rec = self . rock_ridge . record_dr_entries ( ) outlist = [ struct . pack ( self . FMT , self . dr_len , self . xattr_len , extent_loc , utils . swab_32bit ( extent_loc ) , self . data_length , utils . swab_32bit ( self . data_length ) , self . date . record ( ) , self . file_flags , self . file_unit_size , self . interleave_gap_size , self . seqnum , utils . swab_16bit ( self . seqnum ) , self . len_fi ) + self . file_ident + padstr + xa_rec + rr_rec ] outlist . append ( b'\x00' * ( len ( outlist [ 0 ] ) % 2 ) ) return b'' . join ( outlist ) | A method to generate the string representing this Directory Record . |
20,124 | def is_associated_file ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) return self . file_flags & ( 1 << self . FILE_FLAG_ASSOCIATED_FILE_BIT ) | A method to determine whether this file is associated with another file on the ISO . |
20,125 | def set_ptr ( self , ptr ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) self . ptr = ptr | A method to set the Path Table Record associated with this Directory Record . |
20,126 | def set_data_location ( self , current_extent , tag_location ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) self . new_extent_loc = current_extent if self . ptr is not None : self . ptr . update_extent_location ( current_extent ) | A method to set the new extent location that the data for this Directory Record should live at . |
20,127 | def get_data_length ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) if self . inode is not None : return self . inode . get_data_length ( ) return self . data_length | A method to get the length of the data that this Directory Record points to . |
20,128 | def set_data_length ( self , length ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record not yet initialized' ) self . data_length = length | A method to set the length of the data that this Directory Record points to . |
20,129 | def new ( self , length , fp , manage_fp , offset ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Inode is already initialized' ) self . data_length = length self . data_fp = fp self . manage_fp = manage_fp self . fp_offset = offset self . original_data_location = self . DATA_IN_EXTERNAL_FP self . _initialized = True | Initialize a new Inode . |
20,130 | def parse ( self , extent , length , fp , log_block_size ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Inode is already initialized' ) self . orig_extent_loc = extent self . data_length = length self . data_fp = fp self . manage_fp = False self . fp_offset = extent * log_block_size self . original_data_location = self . DATA_ON_ORIGINAL_ISO self . _initialized = True | Parse an existing Inode . This just saves off the extent for later use . |
20,131 | def add_boot_info_table ( self , boot_info_table ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Inode is not yet initialized' ) self . boot_info_table = boot_info_table | A method to add a boot info table to this Inode . |
20,132 | def update_fp ( self , fp , length ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Inode is not yet initialized' ) self . original_data_location = self . DATA_IN_EXTERNAL_FP self . data_fp = fp self . data_length = length self . fp_offset = 0 | Update the Inode to use a different file object and length . |
20,133 | def string_to_timestruct ( input_string ) : try : timestruct = time . strptime ( input_string . decode ( 'utf-8' ) , VolumeDescriptorDate . TIME_FMT ) except ValueError : timestruct = time . struct_time ( ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ) return timestruct | A cacheable function to take an input string and decode it into a time . struct_time from the time module . If the string cannot be decoded because of an illegal value then the all - zero time . struct_time will be returned instead . |
20,134 | def parse ( self , datestr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record Date already initialized' ) ( self . years_since_1900 , self . month , self . day_of_month , self . hour , self . minute , self . second , self . gmtoffset ) = struct . unpack_from ( self . FMT , datestr , 0 ) self . _initialized = True | Parse a Directory Record date out of a string . |
20,135 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record Date already initialized' ) tm = time . time ( ) local = time . localtime ( tm ) self . years_since_1900 = local . tm_year - 1900 self . month = local . tm_mon self . day_of_month = local . tm_mday self . hour = local . tm_hour self . minute = local . tm_min self . second = local . tm_sec self . gmtoffset = utils . gmtoffset_from_tm ( tm , local ) self . _initialized = True | Create a new Directory Record date based on the current time . |
20,136 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Directory Record Date not initialized' ) return struct . pack ( self . FMT , self . years_since_1900 , self . month , self . day_of_month , self . hour , self . minute , self . second , self . gmtoffset ) | Return a string representation of the Directory Record date . |
20,137 | def parse ( self , datestr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'This Volume Descriptor Date object is already initialized' ) if len ( datestr ) != 17 : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid ISO9660 date string' ) timestruct = string_to_timestruct ( datestr [ : - 3 ] ) self . year = timestruct . tm_year self . month = timestruct . tm_mon self . dayofmonth = timestruct . tm_mday self . hour = timestruct . tm_hour self . minute = timestruct . tm_min self . second = timestruct . tm_sec if timestruct . tm_year == 0 and timestruct . tm_mon == 0 and timestruct . tm_mday == 0 and timestruct . tm_hour == 0 and timestruct . tm_min == 0 and timestruct . tm_sec == 0 : self . hundredthsofsecond = 0 self . gmtoffset = 0 self . date_str = self . EMPTY_STRING else : self . hundredthsofsecond = int ( datestr [ 14 : 15 ] ) self . gmtoffset , = struct . unpack_from ( '=b' , datestr , 16 ) self . date_str = datestr self . _initialized = True | Parse a Volume Descriptor Date out of a string . A string of all zeros is valid which means that the date in this field was not specified . |
20,138 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SP record already initialized!' ) ( su_len , su_entry_version_unused , check_byte1 , check_byte2 , self . bytes_to_skip ) = struct . unpack_from ( '=BBBBB' , rrstr [ : 7 ] , 2 ) if su_len != RRSPRecord . length ( ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on rock ridge extension' ) if check_byte1 != 0xbe or check_byte2 != 0xef : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid check bytes on rock ridge extension' ) self . _initialized = True | Parse a Rock Ridge Sharing Protocol record out of a string . |
20,139 | def new ( self , bytes_to_skip ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SP record already initialized!' ) self . bytes_to_skip = bytes_to_skip self . _initialized = True | Create a new Rock Ridge Sharing Protocol record . |
20,140 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SP record not yet initialized!' ) return b'SP' + struct . pack ( '=BBBBB' , RRSPRecord . length ( ) , SU_ENTRY_VERSION , 0xbe , 0xef , self . bytes_to_skip ) | Generate a string representing the Rock Ridge Sharing Protocol record . |
20,141 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'RR record already initialized!' ) self . rr_flags = 0 self . _initialized = True | Create a new Rock Ridge Rock Ridge record . |
20,142 | def append_field ( self , fieldname ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'RR record not yet initialized!' ) if fieldname == 'PX' : bit = 0 elif fieldname == 'PN' : bit = 1 elif fieldname == 'SL' : bit = 2 elif fieldname == 'NM' : bit = 3 elif fieldname == 'CL' : bit = 4 elif fieldname == 'PL' : bit = 5 elif fieldname == 'RE' : bit = 6 elif fieldname == 'TF' : bit = 7 else : raise pycdlibexception . PyCdlibInternalError ( 'Unknown RR field name %s' % ( fieldname ) ) self . rr_flags |= ( 1 << bit ) | Mark a field as present in the Rock Ridge records . |
20,143 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'RR record not yet initialized!' ) return b'RR' + struct . pack ( '=BBB' , RRRRRecord . length ( ) , SU_ENTRY_VERSION , self . rr_flags ) | Generate a string representing the Rock Ridge Rock Ridge record . |
20,144 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CE record already initialized!' ) ( su_len , su_entry_version_unused , bl_cont_area_le , bl_cont_area_be , offset_cont_area_le , offset_cont_area_be , len_cont_area_le , len_cont_area_be ) = struct . unpack_from ( '=BBLLLLLL' , rrstr [ : 28 ] , 2 ) if su_len != RRCERecord . length ( ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on rock ridge extension' ) if bl_cont_area_le != utils . swab_32bit ( bl_cont_area_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'CE record big and little endian continuation area do not agree' ) if offset_cont_area_le != utils . swab_32bit ( offset_cont_area_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'CE record big and little endian continuation area offset do not agree' ) if len_cont_area_le != utils . swab_32bit ( len_cont_area_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'CE record big and little endian continuation area length do not agree' ) self . bl_cont_area = bl_cont_area_le self . offset_cont_area = offset_cont_area_le self . len_cont_area = len_cont_area_le self . _initialized = True | Parse a Rock Ridge Continuation Entry record out of a string . |
20,145 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CE record already initialized!' ) self . bl_cont_area = 0 self . offset_cont_area = 0 self . len_cont_area = 0 self . _initialized = True | Create a new Rock Ridge Continuation Entry record . |
20,146 | def update_extent ( self , extent ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CE record not yet initialized!' ) self . bl_cont_area = extent | Update the extent for this CE record . |
20,147 | def update_offset ( self , offset ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CE record not yet initialized!' ) self . offset_cont_area = offset | Update the offset for this CE record . |
20,148 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CE record not yet initialized!' ) return b'CE' + struct . pack ( '=BBLLLLLL' , RRCERecord . length ( ) , SU_ENTRY_VERSION , self . bl_cont_area , utils . swab_32bit ( self . bl_cont_area ) , self . offset_cont_area , utils . swab_32bit ( self . offset_cont_area ) , self . len_cont_area , utils . swab_32bit ( self . len_cont_area ) ) | Generate a string representing the Rock Ridge Continuation Entry record . |
20,149 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PX record already initialized!' ) ( su_len , su_entry_version_unused , posix_file_mode_le , posix_file_mode_be , posix_file_links_le , posix_file_links_be , posix_file_user_id_le , posix_file_user_id_be , posix_file_group_id_le , posix_file_group_id_be ) = struct . unpack_from ( '=BBLLLLLLLL' , rrstr [ : 38 ] , 2 ) if posix_file_mode_le != utils . swab_32bit ( posix_file_mode_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'PX record big and little-endian file mode do not agree' ) if posix_file_links_le != utils . swab_32bit ( posix_file_links_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'PX record big and little-endian file links do not agree' ) if posix_file_user_id_le != utils . swab_32bit ( posix_file_user_id_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'PX record big and little-endian file user ID do not agree' ) if posix_file_group_id_le != utils . swab_32bit ( posix_file_group_id_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'PX record big and little-endian file group ID do not agree' ) if su_len == 36 : posix_file_serial_number_le = 0 elif su_len == 44 : ( posix_file_serial_number_le , posix_file_serial_number_be ) = struct . unpack_from ( '=LL' , rrstr [ : 44 ] , 36 ) if posix_file_serial_number_le != utils . swab_32bit ( posix_file_serial_number_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'PX record big and little-endian file serial number do not agree' ) else : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on Rock Ridge PX record' ) self . posix_file_mode = posix_file_mode_le self . posix_file_links = posix_file_links_le self . posix_user_id = posix_file_user_id_le self . posix_group_id = posix_file_group_id_le self . posix_serial_number = posix_file_serial_number_le self . _initialized = True return su_len | Parse a Rock Ridge POSIX File Attributes record out of a string . |
20,150 | def new ( self , mode ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PX record already initialized!' ) self . posix_file_mode = mode self . posix_file_links = 1 self . posix_user_id = 0 self . posix_group_id = 0 self . posix_serial_number = 0 self . _initialized = True | Create a new Rock Ridge POSIX File Attributes record . |
20,151 | def record ( self , rr_version ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PX record not yet initialized!' ) outlist = [ b'PX' , struct . pack ( '=BBLLLLLLLL' , RRPXRecord . length ( rr_version ) , SU_ENTRY_VERSION , self . posix_file_mode , utils . swab_32bit ( self . posix_file_mode ) , self . posix_file_links , utils . swab_32bit ( self . posix_file_links ) , self . posix_user_id , utils . swab_32bit ( self . posix_user_id ) , self . posix_group_id , utils . swab_32bit ( self . posix_group_id ) ) ] if rr_version == '1.12' : outlist . append ( struct . pack ( '=LL' , self . posix_serial_number , utils . swab_32bit ( self . posix_serial_number ) ) ) return b'' . join ( outlist ) | Generate a string representing the Rock Ridge POSIX File Attributes record . |
20,152 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ER record already initialized!' ) ( su_len , su_entry_version_unused , len_id , len_des , len_src , self . ext_ver ) = struct . unpack_from ( '=BBBBBB' , rrstr [ : 8 ] , 2 ) if su_len > len ( rrstr ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Length of ER record much too long' ) total_length = len_id + len_des + len_src if total_length > su_len : raise pycdlibexception . PyCdlibInvalidISO ( 'Combined length of ER ID, des, and src longer than record' ) fmtstr = '=%ds%ds%ds' % ( len_id , len_des , len_src ) ( self . ext_id , self . ext_des , self . ext_src ) = struct . unpack_from ( fmtstr , rrstr , 8 ) self . _initialized = True | Parse a Rock Ridge Extensions Reference record out of a string . |
20,153 | def new ( self , ext_id , ext_des , ext_src ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ER record already initialized!' ) self . ext_id = ext_id self . ext_des = ext_des self . ext_src = ext_src self . ext_ver = 1 self . _initialized = True | Create a new Rock Ridge Extensions Reference record . |
20,154 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ER record not yet initialized!' ) return b'ER' + struct . pack ( '=BBBBBB' , RRERRecord . length ( self . ext_id , self . ext_des , self . ext_src ) , SU_ENTRY_VERSION , len ( self . ext_id ) , len ( self . ext_des ) , len ( self . ext_src ) , self . ext_ver ) + self . ext_id + self . ext_des + self . ext_src | Generate a string representing the Rock Ridge Extensions Reference record . |
20,155 | def length ( ext_id , ext_des , ext_src ) : return 8 + len ( ext_id ) + len ( ext_des ) + len ( ext_src ) | Static method to return the length of the Rock Ridge Extensions Reference record . |
20,156 | def new ( self , extension_sequence ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ES record already initialized!' ) self . extension_sequence = extension_sequence self . _initialized = True | Create a new Rock Ridge Extension Selector record . |
20,157 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ES record not yet initialized!' ) return b'ES' + struct . pack ( '=BBB' , RRESRecord . length ( ) , SU_ENTRY_VERSION , self . extension_sequence ) | Generate a string representing the Rock Ridge Extension Selector record . |
20,158 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PN record already initialized!' ) ( su_len , su_entry_version_unused , dev_t_high_le , dev_t_high_be , dev_t_low_le , dev_t_low_be ) = struct . unpack_from ( '=BBLLLL' , rrstr [ : 20 ] , 2 ) if su_len != RRPNRecord . length ( ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on rock ridge extension' ) if dev_t_high_le != utils . swab_32bit ( dev_t_high_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Dev_t high little-endian does not match big-endian' ) if dev_t_low_le != utils . swab_32bit ( dev_t_low_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Dev_t low little-endian does not match big-endian' ) self . dev_t_high = dev_t_high_le self . dev_t_low = dev_t_low_le self . _initialized = True | Parse a Rock Ridge POSIX Device Number record out of a string . |
20,159 | def new ( self , dev_t_high , dev_t_low ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PN record already initialized!' ) self . dev_t_high = dev_t_high self . dev_t_low = dev_t_low self . _initialized = True | Create a new Rock Ridge POSIX device number record . |
20,160 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PN record not yet initialized!' ) return b'PN' + struct . pack ( '=BBLLLL' , RRPNRecord . length ( ) , SU_ENTRY_VERSION , self . dev_t_high , utils . swab_32bit ( self . dev_t_high ) , self . dev_t_low , utils . swab_32bit ( self . dev_t_low ) ) | Generate a string representing the Rock Ridge POSIX Device Number record . |
20,161 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record already initialized!' ) ( su_len , su_entry_version_unused , self . flags ) = struct . unpack_from ( '=BBB' , rrstr [ : 5 ] , 2 ) cr_offset = 5 data_len = su_len - 5 while data_len > 0 : ( cr_flags , len_cp ) = struct . unpack_from ( '=BB' , rrstr [ : cr_offset + 2 ] , cr_offset ) data_len -= 2 cr_offset += 2 self . symlink_components . append ( self . Component ( cr_flags , len_cp , rrstr [ cr_offset : cr_offset + len_cp ] ) ) cr_offset += len_cp data_len -= len_cp self . _initialized = True | Parse a Rock Ridge Symbolic Link record out of a string . |
20,162 | def add_component ( self , symlink_comp ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record not yet initialized!' ) if ( self . current_length ( ) + RRSLRecord . Component . length ( symlink_comp ) ) > 255 : raise pycdlibexception . PyCdlibInvalidInput ( 'Symlink would be longer than 255' ) self . symlink_components . append ( self . Component . factory ( symlink_comp ) ) | Add a new component to this symlink record . |
20,163 | def current_length ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record not yet initialized!' ) strlist = [ ] for comp in self . symlink_components : strlist . append ( comp . name ( ) ) return RRSLRecord . length ( strlist ) | Calculate the current length of this symlink record . |
20,164 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record not yet initialized!' ) outlist = [ b'SL' , struct . pack ( '=BBB' , self . current_length ( ) , SU_ENTRY_VERSION , self . flags ) ] for comp in self . symlink_components : outlist . append ( comp . record ( ) ) return b'' . join ( outlist ) | Generate a string representing the Rock Ridge Symbolic Link record . |
20,165 | def name ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record not yet initialized!' ) outlist = [ ] continued = False for comp in self . symlink_components : name = comp . name ( ) if name == b'/' : outlist = [ ] continued = False name = b'' if not continued : outlist . append ( name ) else : outlist [ - 1 ] += name continued = comp . is_continued ( ) return b'/' . join ( outlist ) | Generate a string that contains all components of the symlink . |
20,166 | def set_last_component_continued ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record not yet initialized!' ) if not self . symlink_components : raise pycdlibexception . PyCdlibInternalError ( 'Trying to set continued on a non-existent component!' ) self . symlink_components [ - 1 ] . set_continued ( ) | Set the previous component of this SL record to continued . |
20,167 | def last_component_continued ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SL record not yet initialized!' ) if not self . symlink_components : raise pycdlibexception . PyCdlibInternalError ( 'Trying to get continued on a non-existent component!' ) return self . symlink_components [ - 1 ] . is_continued ( ) | Determines whether the previous component of this SL record is a continued one or not . |
20,168 | def length ( symlink_components ) : length = RRSLRecord . header_length ( ) for comp in symlink_components : length += RRSLRecord . Component . length ( comp ) return length | Static method to return the length of the Rock Ridge Symbolic Link record . |
20,169 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'NM record already initialized!' ) ( su_len , su_entry_version_unused , self . posix_name_flags ) = struct . unpack_from ( '=BBB' , rrstr [ : 5 ] , 2 ) name_len = su_len - 5 if ( self . posix_name_flags & 0x7 ) not in ( 0 , 1 , 2 , 4 ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid Rock Ridge NM flags' ) if name_len != 0 : if ( self . posix_name_flags & ( 1 << 1 ) ) or ( self . posix_name_flags & ( 1 << 2 ) ) or ( self . posix_name_flags & ( 1 << 5 ) ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid name in Rock Ridge NM entry (0x%x %d)' % ( self . posix_name_flags , name_len ) ) self . posix_name += rrstr [ 5 : 5 + name_len ] self . _initialized = True | Parse a Rock Ridge Alternate Name record out of a string . |
20,170 | def new ( self , rr_name ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'NM record already initialized!' ) self . posix_name = rr_name self . posix_name_flags = 0 self . _initialized = True | Create a new Rock Ridge Alternate Name record . |
20,171 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'NM record not yet initialized!' ) return b'NM' + struct . pack ( b'=BBB' , RRNMRecord . length ( self . posix_name ) , SU_ENTRY_VERSION , self . posix_name_flags ) + self . posix_name | Generate a string representing the Rock Ridge Alternate Name record . |
20,172 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CL record already initialized!' ) ( su_len , su_entry_version_unused , child_log_block_num_le , child_log_block_num_be ) = struct . unpack_from ( '=BBLL' , rrstr [ : 12 ] , 2 ) if su_len != RRCLRecord . length ( ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on rock ridge extension' ) if child_log_block_num_le != utils . swab_32bit ( child_log_block_num_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Little endian block num does not equal big endian; corrupt ISO' ) self . child_log_block_num = child_log_block_num_le self . _initialized = True | Parse a Rock Ridge Child Link record out of a string . |
20,173 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CL record already initialized!' ) self . child_log_block_num = 0 self . _initialized = True | Create a new Rock Ridge Child Link record . |
20,174 | def set_log_block_num ( self , bl ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'CL record not yet initialized!' ) self . child_log_block_num = bl | Set the logical block number for the child . |
20,175 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PL record already initialized!' ) ( su_len , su_entry_version_unused , parent_log_block_num_le , parent_log_block_num_be ) = struct . unpack_from ( '=BBLL' , rrstr [ : 12 ] , 2 ) if su_len != RRPLRecord . length ( ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on rock ridge extension' ) if parent_log_block_num_le != utils . swab_32bit ( parent_log_block_num_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Little endian block num does not equal big endian; corrupt ISO' ) self . parent_log_block_num = parent_log_block_num_le self . _initialized = True | Parse a Rock Ridge Parent Link record out of a string . |
20,176 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PL record already initialized!' ) self . parent_log_block_num = 0 self . _initialized = True | Generate a string representing the Rock Ridge Parent Link record . |
20,177 | def set_log_block_num ( self , bl ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PL record not yet initialized!' ) self . parent_log_block_num = bl | Set the logical block number for the parent . |
20,178 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'TF record already initialized!' ) ( su_len , su_entry_version_unused , self . time_flags , ) = struct . unpack_from ( '=BBB' , rrstr [ : 5 ] , 2 ) if su_len < 5 : raise pycdlibexception . PyCdlibInvalidISO ( 'Not enough bytes in the TF record' ) tflen = 7 if self . time_flags & ( 1 << 7 ) : tflen = 17 offset = 5 for index , fieldname in enumerate ( self . FIELDNAMES ) : if self . time_flags & ( 1 << index ) : if tflen == 7 : setattr ( self , fieldname , dates . DirectoryRecordDate ( ) ) elif tflen == 17 : setattr ( self , fieldname , dates . VolumeDescriptorDate ( ) ) getattr ( self , fieldname ) . parse ( rrstr [ offset : offset + tflen ] ) offset += tflen self . _initialized = True | Parse a Rock Ridge Time Stamp record out of a string . |
20,179 | def new ( self , time_flags ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'TF record already initialized!' ) self . time_flags = time_flags tflen = 7 if self . time_flags & ( 1 << 7 ) : tflen = 17 for index , fieldname in enumerate ( self . FIELDNAMES ) : if self . time_flags & ( 1 << index ) : if tflen == 7 : setattr ( self , fieldname , dates . DirectoryRecordDate ( ) ) elif tflen == 17 : setattr ( self , fieldname , dates . VolumeDescriptorDate ( ) ) getattr ( self , fieldname ) . new ( ) self . _initialized = True | Create a new Rock Ridge Time Stamp record . |
20,180 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'TF record not yet initialized!' ) outlist = [ b'TF' , struct . pack ( '=BBB' , RRTFRecord . length ( self . time_flags ) , SU_ENTRY_VERSION , self . time_flags ) ] for fieldname in self . FIELDNAMES : field = getattr ( self , fieldname ) if field is not None : outlist . append ( field . record ( ) ) return b'' . join ( outlist ) | Generate a string representing the Rock Ridge Time Stamp record . |
20,181 | def length ( time_flags ) : tf_each_size = 7 if time_flags & ( 1 << 7 ) : tf_each_size = 17 time_flags &= 0x7f tf_num = 0 while time_flags : time_flags &= time_flags - 1 tf_num += 1 return 5 + tf_each_size * tf_num | Static method to return the length of the Rock Ridge Time Stamp record . |
20,182 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SF record already initialized!' ) ( su_len , su_entry_version_unused , ) = struct . unpack_from ( '=BB' , rrstr [ : 4 ] , 2 ) if su_len == 12 : ( virtual_file_size_le , virtual_file_size_be ) = struct . unpack_from ( '=LL' , rrstr [ : 12 ] , 4 ) if virtual_file_size_le != utils . swab_32bit ( virtual_file_size_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Virtual file size little-endian does not match big-endian' ) self . virtual_file_size_low = virtual_file_size_le elif su_len == 21 : ( virtual_file_size_high_le , virtual_file_size_high_be , virtual_file_size_low_le , virtual_file_size_low_be , self . table_depth ) = struct . unpack_from ( '=LLLLB' , rrstr [ : 21 ] , 4 ) if virtual_file_size_high_le != utils . swab_32bit ( virtual_file_size_high_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Virtual file size high little-endian does not match big-endian' ) if virtual_file_size_low_le != utils . swab_32bit ( virtual_file_size_low_be ) : raise pycdlibexception . PyCdlibInvalidISO ( 'Virtual file size low little-endian does not match big-endian' ) self . virtual_file_size_low = virtual_file_size_low_le self . virtual_file_size_high = virtual_file_size_high_le else : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on Rock Ridge SF record (expected 12 or 21)' ) self . _initialized = True | Parse a Rock Ridge Sparse File record out of a string . |
20,183 | def new ( self , file_size_high , file_size_low , table_depth ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SF record already initialized!' ) self . virtual_file_size_high = file_size_high self . virtual_file_size_low = file_size_low self . table_depth = table_depth self . _initialized = True | Create a new Rock Ridge Sparse File record . |
20,184 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'SF record not yet initialized!' ) length = 12 if self . virtual_file_size_high is not None : length = 21 ret = b'SF' + struct . pack ( '=BB' , length , SU_ENTRY_VERSION ) if self . virtual_file_size_high is not None and self . table_depth is not None : ret += struct . pack ( '=LLLLB' , self . virtual_file_size_high , utils . swab_32bit ( self . virtual_file_size_high ) , self . virtual_file_size_low , utils . swab_32bit ( self . virtual_file_size_low ) , self . table_depth ) else : ret += struct . pack ( '=LL' , self . virtual_file_size_low , utils . swab_32bit ( self . virtual_file_size_low ) ) return ret | Generate a string representing the Rock Ridge Sparse File record . |
20,185 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'RE record not yet initialized!' ) return b'RE' + struct . pack ( '=BB' , RRRERecord . length ( ) , SU_ENTRY_VERSION ) | Generate a string representing the Rock Ridge Relocated Directory record . |
20,186 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ST record already initialized!' ) ( su_len , su_entry_version_unused ) = struct . unpack_from ( '=BB' , rrstr [ : 4 ] , 2 ) if su_len != 4 : raise pycdlibexception . PyCdlibInvalidISO ( 'Invalid length on rock ridge extension' ) self . _initialized = True | Parse a Rock Ridge System Terminator record out of a string . |
20,187 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'ST record not yet initialized!' ) return b'ST' + struct . pack ( '=BB' , RRSTRecord . length ( ) , SU_ENTRY_VERSION ) | Generate a string representing the Rock Ridge System Terminator record . |
20,188 | def parse ( self , rrstr ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PD record already initialized!' ) ( su_len_unused , su_entry_version_unused ) = struct . unpack_from ( '=BB' , rrstr [ : 4 ] , 2 ) self . padding = rrstr [ 4 : ] self . _initialized = True | Parse a Rock Ridge Platform Dependent record out of a string . |
20,189 | def new ( self ) : if self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PD record already initialized!' ) self . _initialized = True self . padding = b'' | Create a new Rock Ridge Platform Dependent record . |
20,190 | def record ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'PD record not yet initialized!' ) return b'PD' + struct . pack ( '=BB' , RRPDRecord . length ( self . padding ) , SU_ENTRY_VERSION ) + self . padding | Generate a string representing the Rock Ridge Platform Dependent record . |
20,191 | def has_entry ( self , name ) : return getattr ( self . dr_entries , name ) or getattr ( self . ce_entries , name ) | An internal method to tell if we have already parsed an entry of the named type . |
20,192 | def _record ( self , entries ) : outlist = [ ] if entries . sp_record is not None : outlist . append ( entries . sp_record . record ( ) ) if entries . rr_record is not None : outlist . append ( entries . rr_record . record ( ) ) for nm_record in entries . nm_records : outlist . append ( nm_record . record ( ) ) if entries . px_record is not None : outlist . append ( entries . px_record . record ( self . rr_version ) ) for sl_record in entries . sl_records : outlist . append ( sl_record . record ( ) ) if entries . tf_record is not None : outlist . append ( entries . tf_record . record ( ) ) if entries . cl_record is not None : outlist . append ( entries . cl_record . record ( ) ) if entries . pl_record is not None : outlist . append ( entries . pl_record . record ( ) ) if entries . re_record is not None : outlist . append ( entries . re_record . record ( ) ) for es_record in entries . es_records : outlist . append ( es_record . record ( ) ) if entries . er_record is not None : outlist . append ( entries . er_record . record ( ) ) if entries . ce_record is not None : outlist . append ( entries . ce_record . record ( ) ) for pd_record in entries . pd_records : outlist . append ( pd_record . record ( ) ) if entries . st_record is not None : outlist . append ( entries . st_record . record ( ) ) if entries . sf_record is not None : outlist . append ( entries . sf_record . record ( ) ) return b'' . join ( outlist ) | Return a string representing the Rock Ridge entry . |
20,193 | def record_dr_entries ( self ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Rock Ridge extension not yet initialized' ) return self . _record ( self . dr_entries ) | Return a string representing the Rock Ridge entries in the Directory Record . |
20,194 | def record_ce_entries ( self ) : 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 . |
20,195 | def _add_ce_record ( self , curr_dr_len , thislen ) : 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 . |
20,196 | def _add_name ( self , rr_name , curr_dr_len ) : 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 ( ) 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 . |
20,197 | def add_to_file_links ( self ) : 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 . |
20,198 | def copy_file_links ( self , src ) : if not self . _initialized : raise pycdlibexception . PyCdlibInternalError ( 'Rock Ridge extension not yet initialized' ) 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 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 . |
20,199 | def get_file_mode ( self ) : 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.