def _add_child(self, child, logical_block_size, allow_duplicate, check_overflow):
        # type: (DirectoryRecord, int, bool, bool) -> bool
        '''
        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.

        Parameters:
         child - The child directory record object to add.
         logical_block_size - The size of a logical block for this volume descriptor.
         allow_duplicate - Whether to allow duplicate names, as there are situations where duplicate children are allowed.
         check_overflow - Whether to check for overflow; if we are parsing, we don't want to do this.
        Returns:
         True if adding this child caused the directory to overflow into another
         extent, False otherwise.
        '''
        if not self.isdir:
            raise pycdlibexception.PyCdlibInvalidInput('Trying to add a child to a record that is not a directory')

        # First ensure that this is not a duplicate.  For speed purposes, we
        # recognize that bisect_left will always choose an index to the *left*
        # of a duplicate child.  Thus, to check for duplicates we only need to
        # see if the child to be added is a duplicate with the entry that
        # bisect_left returned.
        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)

        # We now have to check if we need to add another logical block.
        # We have to iterate over the entire list again, because where we
        # placed this last entry may rearrange the empty spaces in the blocks
        # that we've already allocated.
        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
            # When we overflow our data length, we always add a full block.
            self.data_length += logical_block_size
            # We also have to make sure to update the length of the dot child,
            # as that should always reflect the length.
            self.children[0].data_length = self.data_length
            # We also have to update all of the dotdot entries.  If this is
            # the root directory record (no parent), we first update the root
            # dotdot entry.  In all cases, we update the dotdot entry of all
            # children that are directories.
            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
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.

        Parameters:
         child - The child directory record object to add.
         logical_block_size - The size of a logical block for this volume descriptor.
         allow_duplicate - Whether to allow duplicate names, as there are situations where duplicate children are allowed.
         check_overflow - Whether to check for overflow; if we are parsing, we don't want to do this.
        Returns:
         True if adding this child caused the directory to overflow into another
         extent, False otherwise.