Skip to content

Commit

Permalink
Allow all systems to check for backslashes (Windows) as last slash in…
Browse files Browse the repository at this point in the history
… path. Improves portable core logic (#15612)
  • Loading branch information
Ryunam authored Aug 17, 2023
1 parent 24287b1 commit c5c86fe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libretro-common/file/file_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,21 +347,20 @@ size_t fill_pathname(char *out_path, const char *in_path,
* @size : size of path
*
* Find last slash in path. Tries to find
* a backslash on Windows too which takes precedence
* over regular slash.
* a backslash as used for Windows paths,
* otherwise checks for a regular slash.
* @return pointer to last slash/backslash found in @str.
**/
char *find_last_slash(const char *str)
{
const char *slash = strrchr(str, '/');
#ifdef _WIN32
const char *backslash = strrchr(str, '\\');

if (!slash || (backslash > slash))
return (char*)backslash;
#endif
return (char*)slash;
else
return (char*)slash;
}

/**
Expand Down

0 comments on commit c5c86fe

Please sign in to comment.