mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
properly check for basepacks
This commit is contained in:
parent
ef5eab2263
commit
326f8ed071
3 changed files with 15 additions and 7 deletions
|
@ -43,8 +43,8 @@ static inline fs_dir_t *fs_find_dir(const char *realpath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mount_cmp(const void *p1, const void *p2) {
|
static int mount_cmp(const void *p1, const void *p2) {
|
||||||
const char *s1 = *(const char **)p1;
|
const char *s1 = sys_file_name(*(const char **)p1);
|
||||||
const char *s2 = *(const char **)p2;
|
const char *s2 = sys_file_name(*(const char **)p2);
|
||||||
|
|
||||||
// check if one or both of these are basepacks
|
// check if one or both of these are basepacks
|
||||||
const int plen = strlen(FS_BASEPACK_PREFIX);
|
const int plen = strlen(FS_BASEPACK_PREFIX);
|
||||||
|
|
|
@ -49,15 +49,22 @@ int sys_strcasecmp(const char *s1, const char *s2) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sys_file_extension(const char *fname) {
|
const char *sys_file_extension(const char *fpath) {
|
||||||
|
const char *fname = sys_file_name(fpath);
|
||||||
const char *dot = strrchr(fname, '.');
|
const char *dot = strrchr(fname, '.');
|
||||||
const char *sep = strrchr(fname, '/');
|
|
||||||
if (!sep) sep = strrchr(fname, '\\');
|
|
||||||
if (!dot || !dot[1]) return NULL; // no dot
|
if (!dot || !dot[1]) return NULL; // no dot
|
||||||
if (dot <= sep + 1) return NULL; // dot is before the last separator or right after it (e.g. /.local)
|
if (dot == fname) return NULL; // dot is the first char (e.g. .local)
|
||||||
return dot + 1;
|
return dot + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *sys_file_name(const char *fpath) {
|
||||||
|
const char *sep1 = strrchr(fpath, '/');
|
||||||
|
const char *sep2 = strrchr(fpath, '\\');
|
||||||
|
const char *sep = sep1 > sep2 ? sep1 : sep2;
|
||||||
|
if (!sep) return fpath;
|
||||||
|
return sep + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* this calls a platform-specific impl function after forming the error message */
|
/* this calls a platform-specific impl function after forming the error message */
|
||||||
|
|
||||||
static void sys_fatal_impl(const char *msg) __attribute__ ((noreturn));
|
static void sys_fatal_impl(const char *msg) __attribute__ ((noreturn));
|
||||||
|
|
|
@ -20,7 +20,8 @@ int sys_strcasecmp(const char *s1, const char *s2);
|
||||||
// path stuff
|
// path stuff
|
||||||
const char *sys_user_path(void);
|
const char *sys_user_path(void);
|
||||||
const char *sys_exe_path(void);
|
const char *sys_exe_path(void);
|
||||||
const char *sys_file_extension(const char *fname);
|
const char *sys_file_extension(const char *fpath);
|
||||||
|
const char *sys_file_name(const char *fpath);
|
||||||
|
|
||||||
// shows an error message in some way and terminates the game
|
// shows an error message in some way and terminates the game
|
||||||
void sys_fatal(const char *fmt, ...) __attribute__ ((noreturn));
|
void sys_fatal(const char *fmt, ...) __attribute__ ((noreturn));
|
||||||
|
|
Loading…
Reference in a new issue