Exemple #1
0
int
main(int argc, char *argv[])
{
    TEST_EQUAL(0, build_directory("foo/bar/baz"));
    TEST_ASSERT(stat_mtime("foo/bar/baz") != -1);
    TEST_EQUAL(0, build_directory("./quux/"));
    TEST_ASSERT(stat_mtime("quux") != -1);
    TEST_EQUAL(0, build_directory("./foo/bar/baz"));
    TEST_ASSERT(stat_mtime("foo/bar/baz") != -1);
    TEST_EQUAL(0, build_directory("/tmp/sphinxbase_foo_bar_baz"));
    TEST_ASSERT(stat_mtime("/tmp/sphinxbase_foo_bar_baz") != -1);

    return 0;
}
Exemple #2
0
/*
 * Build a filename int buf as follows (without file extension):
 *     if dir ends with ,CTLand ctlspec does not begin with /, filename is dir/ctlspec
 *     if dir ends with ,CTL and ctlspec DOES begin with /, filename is ctlspec
 *     if dir does not end with ,CTL, filename is dir/uttid,
 * where ctlspec is the complete utterance spec in the input control file, and
 * uttid is the last component of ctlspec.
 */
static void
build_output_uttfile(char *buf, char *dir, char *uttid, char *ctlspec)
{
    int32 k;

    k = strlen(dir);
    if ((k > 4) && (strcmp(dir + k - 4, ",CTL") == 0)) {        /* HACK!! Hardwired ,CTL */
        if (ctlspec[0] != '/') {
            strcpy(buf, dir);
            buf[k - 4] = '/';
            strcpy(buf + k - 3, ctlspec);
        }
        else
            strcpy(buf, ctlspec);
    }
    else {
        strcpy(buf, dir);
        buf[k] = '/';
        strcpy(buf + k + 1, uttid);
    }
    /* Build output directory structure if possible/requested (it is
     * by default). */
    if (cmd_ln_boolean("-build_outdirs")) {
        char *dirname = ckd_salloc(buf);
        path2dirname(buf, dirname);
        build_directory(dirname);
        ckd_free(dirname);
    }
}
Exemple #3
0
void
build_filenames(cmd_ln_t *config, char const *basename,
                char **out_infile, char **out_outfile)
{
    char const *di, *do_, *ei, *eo;

    di = cmd_ln_str_r(config, "-di");
    do_ = cmd_ln_str_r(config, "-do");
    ei = cmd_ln_str_r(config, "-ei");
    eo = cmd_ln_str_r(config, "-eo");

    *out_infile = string_join(di ? di : "",
                              di ? "/" : "",
                              basename,
                              ei ? "." : "",
                              ei ? ei : "",
                              NULL);
    *out_outfile = string_join(do_ ? do_ : "",
                               do_ ? "/" : "",
                               basename,
                               eo ? "." : "",
                               eo ? eo : "",
                              NULL);
    /* Build output directory structure if possible/requested (it is
     * by default). */
    if (cmd_ln_boolean_r(config, "-build_outdirs")) {
        char *dirname = ckd_salloc(*out_outfile);
        path2dirname(*out_outfile, dirname);
        build_directory(dirname);
        ckd_free(dirname);
    }
}
Exemple #4
0
static int
build_outdir_one(cmd_ln_t *config, char const *arg, char const *uttpath)
{
    char const *dir;

    if ((dir = cmd_ln_str_r(config, arg)) != NULL) {
        char *dirname = string_join(dir, "/", uttpath, NULL);
        build_directory(dirname);
        ckd_free(dirname);
    }
    return 0;
}
Exemple #5
0
void
ctl_outfile(char *file, const char *dir, const char *ext,
	    const char *utt, const char *uttid, int build_dirs)
{
    int32 k;

    k = strlen(dir);

    if ((k > 4) && (strcmp(dir + k - 4, ",CTL") == 0)) {        /* HACK!! Hardwired ,CTL */
        if (utt[0] != '/') {
            strcpy(file, dir);
            file[k - 4] = '/';
            strcpy(file + k - 3, utt);
        }
        else
            strcpy(file, utt);
    }
    else {
        strcpy(file, dir);
        file[k] = '/';
        strcpy(file + k + 1, uttid);
    }

    if (ext && (ext[0] != '\0')) {
        strcat(file, ".");
        strcat(file, ext);
    }

    /* Build output directory structure if possible/requested */
    if (build_dirs) {
        char *dirname = ckd_salloc(file);
        path2dirname(file, dirname);
        build_directory(dirname);
        ckd_free(dirname);
    }
}