'Create a new directory in the Directory table. There is a current component
at each point in time for the directory, which is either explicitly created
through start_component, or implicitly when files are added for the first
time. Files are added into the current component, and into the cab file.
To create a directory, a base directory object needs to be specified (can be
None), the path to the physical directory, and a logical directory name.
Default specifies the DefaultDir slot in the directory table. componentflags
specifies the default flags that new components get.'

def __init__(self, db, cab, basedir, physical, _logical, default, componentflags=None):

    index = 1
    _logical = make_id(_logical)
    logical = _logical
    while (logical in _directories):
        logical = ('%s%d' % (_logical, index))
        index += 1
    _directories.add(logical)
    self.db = db
    self.cab = cab
    self.basedir = basedir
    self.physical = physical
    self.logical = logical
    self.component = None
    self.short_names = set()
    self.ids = set()
    self.keyfiles = {}
    self.componentflags = componentflags
    if basedir:
        self.absolute = os.path.join(basedir.absolute, physical)
        blogical = basedir.logical
    else:
        self.absolute = physical
        blogical = None
    add_data(db, 'Directory', [(logical, blogical, default)])
    return
