mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 17:43:02 +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;
|
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)))
|
#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_is_directory:
|
||||||
* @path : path
|
* @path : path
|
||||||
@ -162,24 +167,24 @@ bool path_is_directory(const char *path)
|
|||||||
orbisDclose(dfd);
|
orbisDclose(dfd);
|
||||||
return true;
|
return true;
|
||||||
#else
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool path_is_character_special(const char *path)
|
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)
|
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 path_get_size(const char *path)
|
||||||
{
|
{
|
||||||
int32_t filesize = 0;
|
int32_t filesize = 0;
|
||||||
if (path_stat(path, &filesize) != 0)
|
if (path_stat_internal(path, &filesize) != 0)
|
||||||
return filesize;
|
return filesize;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -494,6 +494,8 @@ bool path_is_directory(const char *path);
|
|||||||
|
|
||||||
bool path_is_character_special(const char *path);
|
bool path_is_character_special(const char *path);
|
||||||
|
|
||||||
|
int path_stat(const char *path);
|
||||||
|
|
||||||
bool path_is_valid(const char *path);
|
bool path_is_valid(const char *path);
|
||||||
|
|
||||||
int32_t path_get_size(const char *path);
|
int32_t path_get_size(const char *path);
|
||||||
|
@ -1524,7 +1524,10 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef HAVE_DYNAMIC
|
#ifdef HAVE_DYNAMIC
|
||||||
case 'L':
|
case 'L':
|
||||||
if (path_is_directory(optarg))
|
{
|
||||||
|
int path_stats = path_stat(optarg);
|
||||||
|
|
||||||
|
if ((path_stats & RETRO_VFS_STAT_IS_DIRECTORY) != 0)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
@ -1538,7 +1541,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
|||||||
"Setting libretro_directory to \"%s\" instead.\n",
|
"Setting libretro_directory to \"%s\" instead.\n",
|
||||||
optarg);
|
optarg);
|
||||||
}
|
}
|
||||||
else if (filestream_exists(optarg))
|
else if ((path_stats & RETRO_VFS_STAT_IS_VALID) != 0)
|
||||||
{
|
{
|
||||||
path_set(RARCH_PATH_CORE, optarg);
|
path_set(RARCH_PATH_CORE, optarg);
|
||||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL);
|
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL);
|
||||||
@ -1551,7 +1554,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
|||||||
RARCH_WARN("--libretro argument \"%s\" is neither a file nor directory. Ignoring.\n",
|
RARCH_WARN("--libretro argument \"%s\" is neither a file nor directory. Ignoring.\n",
|
||||||
optarg);
|
optarg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'P':
|
case 'P':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user