mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Create path_stat and use it
This commit is contained in:
parent
388a931f95
commit
f117d763d6
@ -137,10 +137,15 @@ void path_vfs_init(const struct retro_vfs_interface_info* vfs_info)
|
||||
path_mkdir_cb = vfs_iface->mkdir;
|
||||
}
|
||||
|
||||
#define path_stat(path, size) ((path_stat_cb != NULL) ? path_stat_cb((path), (size)) : retro_vfs_stat_impl((path), (size)))
|
||||
#define path_stat_internal(path, size) ((path_stat_cb != NULL) ? path_stat_cb((path), (size)) : retro_vfs_stat_impl((path), (size)))
|
||||
|
||||
#define path_mkdir_norecurse(dir) ((path_mkdir_cb != NULL) ? path_mkdir_cb((dir)) : retro_vfs_mkdir_impl((dir)))
|
||||
|
||||
int path_stat(const char *path)
|
||||
{
|
||||
return path_stat_internal(path, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* path_is_directory:
|
||||
* @path : path
|
||||
@ -162,24 +167,24 @@ bool path_is_directory(const char *path)
|
||||
orbisDclose(dfd);
|
||||
return true;
|
||||
#else
|
||||
return (path_stat(path, NULL) & RETRO_VFS_STAT_IS_DIRECTORY) != 0;
|
||||
return (path_stat_internal(path, NULL) & RETRO_VFS_STAT_IS_DIRECTORY) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool path_is_character_special(const char *path)
|
||||
{
|
||||
return (path_stat(path, NULL) & RETRO_VFS_STAT_IS_CHARACTER_SPECIAL) != 0;
|
||||
return (path_stat_internal(path, NULL) & RETRO_VFS_STAT_IS_CHARACTER_SPECIAL) != 0;
|
||||
}
|
||||
|
||||
bool path_is_valid(const char *path)
|
||||
{
|
||||
return (path_stat(path, NULL) & RETRO_VFS_STAT_IS_VALID) != 0;
|
||||
return (path_stat_internal(path, NULL) & RETRO_VFS_STAT_IS_VALID) != 0;
|
||||
}
|
||||
|
||||
int32_t path_get_size(const char *path)
|
||||
{
|
||||
int32_t filesize = 0;
|
||||
if (path_stat(path, &filesize) != 0)
|
||||
if (path_stat_internal(path, &filesize) != 0)
|
||||
return filesize;
|
||||
|
||||
return -1;
|
||||
|
@ -494,6 +494,8 @@ bool path_is_directory(const char *path);
|
||||
|
||||
bool path_is_character_special(const char *path);
|
||||
|
||||
int path_stat(const char *path);
|
||||
|
||||
bool path_is_valid(const char *path);
|
||||
|
||||
int32_t path_get_size(const char *path);
|
||||
|
51
retroarch.c
51
retroarch.c
@ -1524,34 +1524,37 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
case 'L':
|
||||
if (path_is_directory(optarg))
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
int path_stats = path_stat(optarg);
|
||||
|
||||
path_clear(RARCH_PATH_CORE);
|
||||
strlcpy(settings->paths.directory_libretro, optarg,
|
||||
sizeof(settings->paths.directory_libretro));
|
||||
if ((path_stats & RETRO_VFS_STAT_IS_DIRECTORY) != 0)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL);
|
||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY, NULL);
|
||||
RARCH_WARN("Using old --libretro behavior. "
|
||||
"Setting libretro_directory to \"%s\" instead.\n",
|
||||
optarg);
|
||||
path_clear(RARCH_PATH_CORE);
|
||||
strlcpy(settings->paths.directory_libretro, optarg,
|
||||
sizeof(settings->paths.directory_libretro));
|
||||
|
||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL);
|
||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY, NULL);
|
||||
RARCH_WARN("Using old --libretro behavior. "
|
||||
"Setting libretro_directory to \"%s\" instead.\n",
|
||||
optarg);
|
||||
}
|
||||
else if ((path_stats & RETRO_VFS_STAT_IS_VALID) != 0)
|
||||
{
|
||||
path_set(RARCH_PATH_CORE, optarg);
|
||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL);
|
||||
|
||||
/* We requested explicit core, so use PLAIN core type. */
|
||||
retroarch_set_current_core_type(CORE_TYPE_PLAIN, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_WARN("--libretro argument \"%s\" is neither a file nor directory. Ignoring.\n",
|
||||
optarg);
|
||||
}
|
||||
}
|
||||
else if (filestream_exists(optarg))
|
||||
{
|
||||
path_set(RARCH_PATH_CORE, optarg);
|
||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL);
|
||||
|
||||
/* We requested explicit core, so use PLAIN core type. */
|
||||
retroarch_set_current_core_type(CORE_TYPE_PLAIN, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_WARN("--libretro argument \"%s\" is neither a file nor directory. Ignoring.\n",
|
||||
optarg);
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
case 'P':
|
||||
|
Loading…
x
Reference in New Issue
Block a user