movie: load case-insensitive filename

This commit is contained in:
Nunuhara Cabbage
2024-08-04 22:25:17 -07:00
parent ab810e8f57
commit 21abe6ff9a
4 changed files with 26 additions and 2 deletions
+1
View File
@@ -67,6 +67,7 @@ void log_message(const char *log, const char *fmt, ...);
char *unix_path(const char *path);
char *gamedir_path(const char *path);
char *gamedir_path_icase(const char *path);
char *savedir_path(const char *path);
void get_date(int *year, int *month, int *mday, int *wday);
+7 -1
View File
@@ -168,6 +168,7 @@ static int audio_callback(sts_mixer_sample_t *sample, void *data)
assert(sample == &mc->sts_stream.sample);
if (!decode_frame(&mc->audio, mc)) {
NOTICE("???");
free(sample->data);
sample->length = 0;
sample->data = NULL;
@@ -206,7 +207,12 @@ struct movie_context *movie_load(const char *filename)
{
struct movie_context *mc = xcalloc(1, sizeof(struct movie_context));
mc->voice = -1;
char *path = gamedir_path(filename);
char *path = gamedir_path_icase(filename);
if (!path) {
WARNING("%s: file does not exist", filename);
movie_free(mc);
return NULL;
}
int ret;
if ((ret = avformat_open_input(&mc->format_ctx, path, NULL, NULL)) != 0) {
WARNING("%s: avformat_open_input failed: %d", path, ret);
+6 -1
View File
@@ -112,7 +112,12 @@ struct movie_context *movie_load(const char *filename)
{
struct movie_context *mc = xcalloc(1, sizeof(struct movie_context));
mc->voice = -1;
char *path = gamedir_path(filename);
char *path = gamedir_path_icase(filename);
if (!path) {
WARNING("%s: file does not exist", filename);
movie_free(mc);
return NULL;
}
FILE *fp = file_open_utf8(path, "rb");
if (!fp) {
WARNING("%s: %s", path, strerror(errno));
+12
View File
@@ -23,6 +23,7 @@
#include <ctype.h>
#include "system4.h"
#include "system4/file.h"
#include "system4/utfsjis.h"
#include "xsystem4.h"
@@ -146,6 +147,17 @@ char *gamedir_path(const char *path)
return resolve_path(config.game_dir, path);
}
char *gamedir_path_icase(const char *path)
{
char *resolved = resolve_path(config.game_dir, path);
if (!file_exists(resolved)) {
char *tmp = path_get_icase(resolved);
free(resolved);
resolved = tmp;
}
return resolved;
}
char *savedir_path(const char *path)
{
return resolve_path(config.save_dir, path);