コード例 #1
0
ファイル: paths.c プロジェクト: adurdin/fs-uae
char *fs_uae_expand_path(const char* path)
{
    char* lower = g_ascii_strdown(path, -1);
    int replace = 0;
    const char *replace_with = NULL;

    if (check_path_prefix(lower, "~", &replace)) {
        replace_with = fs_uae_home_dir();
    } else if (check_path_prefix(lower, "$home", &replace)) {
        replace_with = fs_uae_home_dir();
    } else if (check_path_prefix(lower, "$app", &replace)) {
        replace_with = fs_uae_app_dir();
    } else if (check_path_prefix(lower, "$exe", &replace)) {
        replace_with = fs_uae_exe_dir();
    } else if (check_path_prefix(lower, "$fsuae", &replace)) {
        replace_with = fs_uae_base_dir();
    } else if (check_path_prefix(lower, "$base", &replace)) {
        replace_with = fs_uae_base_dir();
    } else if (check_path_prefix(lower, "$documents", &replace)) {
        replace_with = fs_uae_documents_dir();
    } else if (check_path_prefix(lower, "$config", &replace)) {
        replace_with = g_fs_uae_config_dir_path;
    } else if (check_path_prefix(lower, "$temp", &replace)) {
        replace_with = fs_uae_temp_dir();
    }

    free(lower);
    if (replace_with) {
        const char *src = path + replace;
        return g_build_filename(replace_with, src, NULL);
    } else {
        return g_strdup(path);
    }
}
コード例 #2
0
ファイル: paths.c プロジェクト: eehrich/fs-uae
char *fs_uae_expand_path(const char* path) {
    char* lower = g_ascii_strdown(path, -1);
    int replace = 0;
    const char *replace_with = NULL;

    if (g_str_has_prefix(lower, "~/") || g_str_has_prefix(lower, "~\\")) {
        replace = 2;
        replace_with = fs_uae_home_dir();
    }
    if (g_str_has_prefix(lower, "$home/") ||
            g_str_has_prefix(lower, "$home\\")) {
        replace = 6;
        replace_with = fs_uae_home_dir();
    }
    if (g_str_has_prefix(lower, "$app/") ||
            g_str_has_prefix(lower, "$app\\")) {
        replace = 5;
        replace_with = fs_uae_app_dir();
    }
    if (g_str_has_prefix(lower, "$exe/") ||
            g_str_has_prefix(lower, "$exe\\")) {
        replace = 5;
        replace_with = fs_uae_exe_dir();
    }
    if (g_str_has_prefix(lower, "$fsuae/") ||
            g_str_has_prefix(lower, "$fsuae\\")) {
        replace = 7;
        replace_with = fs_uae_base_dir();
    }
    if (g_str_has_prefix(lower, "$base/") ||
            g_str_has_prefix(lower, "$base\\")) {
        replace = 6;
        replace_with = fs_uae_base_dir();
    }
    if (g_str_has_prefix(lower, "$documents/") ||
            g_str_has_prefix(lower, "$documents\\")) {
        replace = 11;
        replace_with = fs_uae_documents_dir();
    }
    if (g_str_has_prefix(lower, "$config/") ||
            g_str_has_prefix(lower, "$config\\")) {
        replace = 8;
        replace_with = g_fs_uae_config_dir_path;
    }

    free(lower);
    if (replace && replace_with) {
        const char *src = path + replace;
        return g_build_filename(replace_with, src, NULL);
    }
    else {
        return g_strdup(path);
    }
}
コード例 #3
0
ファイル: paths.c プロジェクト: eehrich/fs-uae
void fs_uae_set_uae_paths() {
    fs_log("fs_uae_set_uae_paths\n");
    amiga_set_paths(g_paths[FS_UAE_ROM_PATHS].path,
            g_paths[FS_UAE_FLOPPY_PATHS].path,
            g_paths[FS_UAE_CD_PATHS].path,
            g_paths[FS_UAE_HD_PATHS].path);

    static const char *library_dirs[2];
    library_dirs[0] = fs_uae_plugins_dir();
    library_dirs[1] = NULL; // terminates the list
    amiga_set_native_library_dirs(library_dirs);

    // find path for built-in drive sounds
    char *path = fs_get_program_data_file("floppy_sounds");
    if (path) {
        fs_log("found \"built-in\" driveclick directory at %s\n", path);
        amiga_set_builtin_driveclick_path(path);
        free(path);
    }
    else {
        fs_log("did not find \"built-in\" driveclick directory\n");
    }

    // find path for custom drive sounds
    path = g_build_filename(fs_uae_base_dir(), "Floppy Sounds", NULL);
    amiga_set_floppy_sounds_dir(path);
    free(path);
}
コード例 #4
0
ファイル: paths.c プロジェクト: eehrich/fs-uae
const char *fs_uae_state_dir()
{
    static const char *path = NULL;
    if (path == NULL) {
        path = fs_uae_state_dir_path();
        if (!path || !path[0]) {
            path = fs_uae_base_dir();
            fs_log("reverting state dir to: %s\n", path);
        }
        fs_log("- using state dir %s\n", path);
        int result = g_mkdir_with_parents(path, 0755);
        if (result == -1) {
            fs_emu_warning("Could not create state directory");
            path = fs_uae_base_dir();
        }
        fs_log("final state dir path: %s\n", path);
    }
    return path;
}
コード例 #5
0
ファイル: paths.c プロジェクト: eehrich/fs-uae
const char *fs_uae_kickstarts_cache_dir() {
    static const char *path = NULL;
    if (path == NULL) {
        path = g_build_filename(fs_uae_cache_dir(), "Kickstarts", NULL);
        int result = g_mkdir_with_parents(path, 0755);
        if (result == -1) {
            fs_emu_warning("Could not create kickstarts cache directory");
            path = fs_uae_base_dir();
        }
    }
    return path;
}
コード例 #6
0
ファイル: paths.c プロジェクト: eehrich/fs-uae
static char *get_or_create_default_dir(const char *name, const char *key1,
        const char *key2, const char *dashed_key, int create, int cache)
{
    char *path = NULL;

    if (path == NULL && key1 != NULL) {
        path = fs_config_get_string(key1);
    }
    if (path == NULL && key2 != NULL) {
        path = fs_config_get_string(key2);
    }
    if (path == NULL && dashed_key != NULL) {
        path = read_custom_path(dashed_key);
    }
    if (path == NULL) {
        if (cache) {
            path = g_build_filename(fs_uae_cache_dir(), name, NULL);
        } else {
            path = g_build_filename(fs_uae_base_dir(), name, NULL);
        }
    }
    char *expanded_path = fs_uae_expand_path_and_free(path);
    path = fs_uae_resolve_path(expanded_path, FS_UAE_DIR_PATHS);
    free(expanded_path);

    if (create) {
        int result = g_mkdir_with_parents(path, 0755);
        if (result == -1) {
            fs_emu_warning("Could not create %s directory", name);
            free(path);
            path = g_strdup(fs_uae_base_dir());
        }
    }
    fs_log("- using \"%s\" directory \"%s\"\n", name, path);
    return path;
}