mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 22:08:34 +00:00
Ensure that g_settings.libretro is absolute path.
Avoid issues when relative libretro paths are stored in ROM history.
This commit is contained in:
parent
ef257a6e8e
commit
df79b8ea3d
@ -290,6 +290,10 @@ static void load_symbols(bool is_dummy)
|
||||
strlcpy(g_settings.libretro, libretro_core_buffer, sizeof(g_settings.libretro));
|
||||
}
|
||||
|
||||
// Need to use absolute path for this setting. It can be saved to ROM history,
|
||||
// and a relative path would break in that scenario.
|
||||
path_resolve_realpath(g_settings.libretro, sizeof(g_settings.libretro));
|
||||
|
||||
RARCH_LOG("Loading dynamic libretro from: \"%s\"\n", g_settings.libretro);
|
||||
lib_handle = dylib_load(g_settings.libretro);
|
||||
if (!lib_handle)
|
||||
|
4
file.h
4
file.h
@ -84,6 +84,10 @@ void path_basedir(char *path);
|
||||
// Assumes that path is a directory. Keeps trailing '/'.
|
||||
void path_parent_dir(char *path);
|
||||
|
||||
// Turns relative paths into absolute path.
|
||||
// If relative, rebases on current working dir.
|
||||
void path_resolve_realpath(char *buf, size_t size);
|
||||
|
||||
bool path_is_absolute(const char *path);
|
||||
|
||||
// Path-name operations.
|
||||
|
24
file_path.c
24
file_path.c
@ -532,6 +532,30 @@ bool path_is_absolute(const char *path)
|
||||
#endif
|
||||
}
|
||||
|
||||
void path_resolve_realpath(char *buf, size_t size)
|
||||
{
|
||||
#ifndef RARCH_CONSOLE
|
||||
char tmp[PATH_MAX];
|
||||
strlcpy(tmp, buf, sizeof(tmp));
|
||||
|
||||
#ifdef _WIN32
|
||||
if (!_fullpath(buf, tmp, size))
|
||||
strlcpy(buf, tmp, size);
|
||||
#else
|
||||
rarch_assert(size >= PATH_MAX);
|
||||
// NOTE: realpath() expects at least PATH_MAX bytes in buf.
|
||||
// Technically, PATH_MAX needn't be defined, but we rely on it anyways.
|
||||
// POSIX 2008 can automatically allocate for you, but don't rely on that.
|
||||
if (!realpath(tmp, buf))
|
||||
strlcpy(buf, tmp, size);
|
||||
#endif
|
||||
|
||||
#else
|
||||
(void)buf;
|
||||
(void)size;
|
||||
#endif
|
||||
}
|
||||
|
||||
void fill_pathname_resolve_relative(char *out_path, const char *in_refpath, const char *in_path, size_t size)
|
||||
{
|
||||
if (path_is_absolute(in_path))
|
||||
|
Loading…
Reference in New Issue
Block a user