def _rm_dr_link(self, rec):
        # type: (dr.DirectoryRecord) -> int
        '''
        An internal method to remove a Directory Record link given the record.

        Parameters:
         rec - The Directory Record to remove.
        Returns:
         The number of bytes to remove from the ISO.
        '''
        if not rec.is_file():
            raise pycdlibexception.PyCdlibInvalidInput('Cannot remove a directory with rm_hard_link (try rm_directory instead)')

        num_bytes_to_remove = 0

        logical_block_size = rec.vd.logical_block_size()

        done = False
        while not done:
            num_bytes_to_remove += self._remove_child_from_dr(rec,
                                                              rec.index_in_parent,
                                                              logical_block_size)

            if rec.inode is not None:
                found_index = None
                for index, link in enumerate(rec.inode.linked_records):
                    if id(link) == id(rec):
                        found_index = index
                        break
                else:
                    # This should never happen
                    raise pycdlibexception.PyCdlibInternalError('Could not find inode corresponding to record')

                del rec.inode.linked_records[found_index]

                # We only remove the size of the child from the ISO if there are no
                # other references to this file on the ISO.
                if not rec.inode.linked_records:
                    found_index = None
                    for index, ino in enumerate(self.inodes):
                        if id(ino) == id(rec.inode):
                            found_index = index
                            break
                    else:
                        # This should never happen
                        raise pycdlibexception.PyCdlibInternalError('Could not find inode corresponding to record')
                    del self.inodes[found_index]

                    num_bytes_to_remove += rec.get_data_length()

            if rec.data_continuation is not None:
                rec = rec.data_continuation
            else:
                done = True

        return num_bytes_to_remove
def _rm_dr_link ( self , rec ) : if not rec . is_file ( ) : raise pycdlibexception . PyCdlibInvalidInput ( 'Cannot remove a directory with rm_hard_link (try rm_directory instead)' ) num_bytes_to_remove = 0 logical_block_size = rec . vd . logical_block_size ( ) done = False while not done : num_bytes_to_remove += self . _remove_child_from_dr ( rec , rec . index_in_parent , logical_block_size ) if rec . inode is not None : found_index = None for index , link in enumerate ( rec . inode . linked_records ) : if id ( link ) == id ( rec ) : found_index = index break else : raise pycdlibexception . PyCdlibInternalError ( 'Could not find inode corresponding to record' ) del rec . inode . linked_records [ found_index ] if not rec . inode . linked_records : found_index = None for index , ino in enumerate ( self . inodes ) : if id ( ino ) == id ( rec . inode ) : found_index = index break else : raise pycdlibexception . PyCdlibInternalError ( 'Could not find inode corresponding to record' ) del self . inodes [ found_index ] num_bytes_to_remove += rec . get_data_length ( ) if rec . data_continuation is not None : rec = rec . data_continuation else : done = True return num_bytes_to_remove
An internal method to remove a Directory Record link given the record.

        Parameters:
         rec - The Directory Record to remove.
        Returns:
         The number of bytes to remove from the ISO.