'Add a file to the current component of the directory, starting a new one
one if there is no current component. By default, the file name in the source
and the file table will be identical. If the src file is specified, it is
interpreted relative to the current directory. Optionally, a version and a
language can be specified for the entry in the File table.'

def add_file(self, file, src=None, version=None, language=None):

    if (not self.component):
        self.start_component(self.logical, current_feature, 0)
    if (not src):
        src = file
        file = os.path.basename(file)
    absolute = os.path.join(self.absolute, src)
    assert (not re.search('[\\?|><:/*]"', file))
    if (file in self.keyfiles):
        logical = self.keyfiles[file]
    else:
        logical = None
    (sequence, logical) = self.cab.append(absolute, file, logical)
    assert (logical not in self.ids)
    self.ids.add(logical)
    short = self.make_short(file)
    full = ('%s|%s' % (short, file))
    filesize = os.stat(absolute).st_size
    attributes = 512
    add_data(self.db, 'File', [(logical, self.component, full, filesize, version, language, attributes, sequence)])
    if file.endswith('.py'):
        add_data(self.db, 'RemoveFile', [((logical + 'c'), self.component, ('%sC|%sc' % (short, file)), self.logical, 2), ((logical + 'o'), self.component, ('%sO|%so' % (short, file)), self.logical, 2)])
    return logical
