mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 06:40:48 +00:00
path_parent_dir - don't do implicit strlen inside
This commit is contained in:
parent
9b10579a54
commit
36edb15c5b
@ -5207,7 +5207,7 @@ bool input_remapping_save_file(const char *path)
|
|||||||
|
|
||||||
/* Create output directory, if required */
|
/* Create output directory, if required */
|
||||||
strlcpy(remap_file_dir, path, sizeof(remap_file_dir));
|
strlcpy(remap_file_dir, path, sizeof(remap_file_dir));
|
||||||
path_parent_dir(remap_file_dir);
|
path_parent_dir(remap_file_dir, strlen(remap_file_dir));
|
||||||
|
|
||||||
if (!string_is_empty(remap_file_dir) &&
|
if (!string_is_empty(remap_file_dir) &&
|
||||||
!path_is_directory(remap_file_dir) &&
|
!path_is_directory(remap_file_dir) &&
|
||||||
|
@ -370,8 +370,9 @@ static void frontend_ps2_init(void *data)
|
|||||||
|
|
||||||
getcwd(cwd, sizeof(cwd));
|
getcwd(cwd, sizeof(cwd));
|
||||||
#if !defined(IS_SALAMANDER) && !defined(DEBUG)
|
#if !defined(IS_SALAMANDER) && !defined(DEBUG)
|
||||||
// If it is not salamander we need to go one level up for set the CWD.
|
/* If it is not Salamander, we need to go one level
|
||||||
path_parent_dir(cwd);
|
* up for setting the CWD. */
|
||||||
|
path_parent_dir(cwd, strlen(cwd));
|
||||||
#endif
|
#endif
|
||||||
if (pfsModuleLoaded)
|
if (pfsModuleLoaded)
|
||||||
hddMounted = mount_hdd_partition();
|
hddMounted = mount_hdd_partition();
|
||||||
|
@ -449,9 +449,12 @@ bool fill_pathname_parent_dir_name(char *out_dir,
|
|||||||
void fill_pathname_parent_dir(char *out_dir,
|
void fill_pathname_parent_dir(char *out_dir,
|
||||||
const char *in_dir, size_t size)
|
const char *in_dir, size_t size)
|
||||||
{
|
{
|
||||||
|
size_t len = 0;
|
||||||
if (out_dir != in_dir)
|
if (out_dir != in_dir)
|
||||||
strlcpy(out_dir, in_dir, size);
|
len = strlcpy(out_dir, in_dir, size);
|
||||||
path_parent_dir(out_dir);
|
else
|
||||||
|
len = strlen(out_dir);
|
||||||
|
path_parent_dir(out_dir, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -538,20 +541,17 @@ void path_basedir(char *path)
|
|||||||
/**
|
/**
|
||||||
* path_parent_dir:
|
* path_parent_dir:
|
||||||
* @path : path
|
* @path : path
|
||||||
|
* @len : length of @path
|
||||||
*
|
*
|
||||||
* Extracts parent directory by mutating path.
|
* Extracts parent directory by mutating path.
|
||||||
* Assumes that path is a directory. Keeps trailing '/'.
|
* Assumes that path is a directory. Keeps trailing '/'.
|
||||||
* If the path was already at the root directory, returns empty string
|
* If the path was already at the root directory, returns empty string
|
||||||
**/
|
**/
|
||||||
void path_parent_dir(char *path)
|
void path_parent_dir(char *path, size_t len)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
len = strlen(path);
|
|
||||||
|
|
||||||
if (len && PATH_CHAR_IS_SLASH(path[len - 1]))
|
if (len && PATH_CHAR_IS_SLASH(path[len - 1]))
|
||||||
{
|
{
|
||||||
bool path_was_absolute = path_is_absolute(path);
|
bool path_was_absolute = path_is_absolute(path);
|
||||||
|
@ -121,7 +121,7 @@ bool path_mkdir(const char *dir)
|
|||||||
if (!(basedir = strdup(dir)))
|
if (!(basedir = strdup(dir)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
path_parent_dir(basedir);
|
path_parent_dir(basedir, strlen(basedir));
|
||||||
|
|
||||||
if (!*basedir || !strcmp(basedir, dir))
|
if (!*basedir || !strcmp(basedir, dir))
|
||||||
{
|
{
|
||||||
|
@ -161,12 +161,13 @@ void path_basedir(char *path);
|
|||||||
/**
|
/**
|
||||||
* path_parent_dir:
|
* path_parent_dir:
|
||||||
* @path : path
|
* @path : path
|
||||||
|
* @len : length of @path
|
||||||
*
|
*
|
||||||
* Extracts parent directory by mutating path.
|
* Extracts parent directory by mutating path.
|
||||||
* Assumes that path is a directory. Keeps trailing '/'.
|
* Assumes that path is a directory. Keeps trailing '/'.
|
||||||
* If the path was already at the root directory, returns empty string
|
* If the path was already at the root directory, returns empty string
|
||||||
**/
|
**/
|
||||||
void path_parent_dir(char *path);
|
void path_parent_dir(char *path, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_resolve_realpath:
|
* path_resolve_realpath:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user