static bool playlist_read_file( playlist_t *playlist, const char *path) { unsigned i; char buf[PLAYLIST_ENTRIES][1024]; intfstream_t *file = intfstream_open_file( path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); /* If playlist file does not exist, * create an empty playlist instead. */ if (!file) return true; for (i = 0; i < PLAYLIST_ENTRIES; i++) buf[i][0] = '\0'; for (playlist->size = 0; playlist->size < playlist->cap; ) { unsigned i; struct playlist_entry *entry = NULL; for (i = 0; i < PLAYLIST_ENTRIES; i++) { char *last = NULL; *buf[i] = '\0'; if (!intfstream_gets(file, buf[i], sizeof(buf[i]))) goto end; /* Read playlist entry and terminate string with NUL character * regardless of Windows or Unix line endings */ if((last = strrchr(buf[i], '\r'))) *last = '\0'; else if((last = strrchr(buf[i], '\n'))) *last = '\0'; } entry = &playlist->entries[playlist->size]; if (!*buf[2] || !*buf[3]) continue; if (*buf[0]) entry->path = strdup(buf[0]); if (*buf[1]) entry->label = strdup(buf[1]); entry->core_path = strdup(buf[2]); entry->core_name = strdup(buf[3]); if (*buf[4]) entry->crc32 = strdup(buf[4]); if (*buf[5]) entry->db_name = strdup(buf[5]); playlist->size++; } end: intfstream_close(file); free(file); return true; }
/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Resolves all shader parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ bool video_shader_resolve_parameters(config_file_t *conf, struct video_shader *shader) { unsigned i; struct video_shader_parameter *param = &shader->parameters[0]; shader->num_parameters = 0; /* Find all parameters in our shaders. */ for (i = 0; i < shader->passes; i++) { intfstream_t *file = NULL; size_t line_size = 4096 * sizeof(char); char *line = NULL; const char *path = shader->pass[i].source.path; if (string_is_empty(path)) continue; #if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) /* First try to use the more robust slang * implementation to support #includes. */ /* FIXME: The check for slang can be removed * if it's sufficiently tested for * GLSL/Cg as well, it should be the same implementation. */ if (string_is_equal(path_get_extension(path), "slang") && slang_preprocess_parse_parameters(path, shader)) continue; /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif file = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) continue; line = (char*)malloc(4096 * sizeof(char)); line[0] = '\0'; /* even though the pass is set in the loop too, not all passes have parameters */ param->pass = i; while (shader->num_parameters < ARRAY_SIZE(shader->parameters) && intfstream_gets(file, line, line_size)) { int ret = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", param->id, param->desc, ¶m->initial, ¶m->minimum, ¶m->maximum, ¶m->step); if (ret < 5) continue; param->id[63] = '\0'; param->desc[63] = '\0'; if (ret == 5) param->step = 0.1f * (param->maximum - param->minimum); param->pass = i; RARCH_LOG("Found #pragma parameter %s (%s) %f %f %f %f in pass %d\n", param->desc, param->id, param->initial, param->minimum, param->maximum, param->step, param->pass); param->current = param->initial; shader->num_parameters++; param++; } free(line); intfstream_close(file); free(file); } if (conf && !video_shader_resolve_current_parameters(conf, shader)) return false; return true; }