mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 13:20:43 +00:00
fill_pathname_parent_dir_name: return failure if path has no slash
This commit is contained in:
parent
42e93f3197
commit
aaf35f53f8
@ -602,20 +602,30 @@ void fill_pathname_basedir_noext(char *out_dir,
|
|||||||
*
|
*
|
||||||
* Copies only the parent directory name of @in_dir into @out_dir.
|
* Copies only the parent directory name of @in_dir into @out_dir.
|
||||||
* The two buffers must not overlap. Removes trailing '/'.
|
* The two buffers must not overlap. Removes trailing '/'.
|
||||||
|
* Returns true on success, false if a slash was not found in the path.
|
||||||
**/
|
**/
|
||||||
void fill_pathname_parent_dir_name(char *out_dir,
|
bool fill_pathname_parent_dir_name(char *out_dir,
|
||||||
const char *in_dir, size_t size)
|
const char *in_dir, size_t size)
|
||||||
{
|
{
|
||||||
char *temp = strdup(in_dir);
|
char *temp = strdup(in_dir);
|
||||||
char *last = find_last_slash(temp);
|
char *last = find_last_slash(temp);
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
*last = '\0';
|
*last = '\0';
|
||||||
|
|
||||||
in_dir = find_last_slash(temp) + 1;
|
in_dir = find_last_slash(temp);
|
||||||
|
|
||||||
strlcpy(out_dir, in_dir, size);
|
if (in_dir && in_dir + 1)
|
||||||
|
{
|
||||||
|
strlcpy(out_dir, in_dir + 1, size);
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = false;
|
||||||
|
|
||||||
free(temp);
|
free(temp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,8 +298,9 @@ void fill_pathname_basedir_noext(char *out_dir,
|
|||||||
*
|
*
|
||||||
* Copies only the parent directory name of @in_dir into @out_dir.
|
* Copies only the parent directory name of @in_dir into @out_dir.
|
||||||
* The two buffers must not overlap. Removes trailing '/'.
|
* The two buffers must not overlap. Removes trailing '/'.
|
||||||
|
* Returns true on success, false if a slash was not found in the path.
|
||||||
**/
|
**/
|
||||||
void fill_pathname_parent_dir_name(char *out_dir,
|
bool fill_pathname_parent_dir_name(char *out_dir,
|
||||||
const char *in_dir, size_t size);
|
const char *in_dir, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user