mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
sdl ui: fix choosing the root path (#8443)
This commit is contained in:
parent
6d6e53e1e2
commit
24b3acbce8
@ -48,14 +48,16 @@ int is_path_separator(char c)
|
||||
|
||||
bool is_root(std::string_view path)
|
||||
{
|
||||
// FIXME: get rid of the assumption that paths are DOS-like
|
||||
|
||||
#if defined(OSD_WINDOWS)
|
||||
// skip drive letter
|
||||
if (path.length() >= 2 && isalpha(path[0]) && (path[1] == ':'))
|
||||
path.remove_prefix(2);
|
||||
|
||||
// skip path separators
|
||||
return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos;
|
||||
#else
|
||||
return (path.length() == 1) && (path[0] == '/');
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -202,12 +204,16 @@ osd_file::error zippath_resolve(std::string_view path, osd::directory::entry::en
|
||||
osd::directory::entry::entry_type current_entry_type = osd::directory::entry::entry_type::NONE;
|
||||
bool went_up = false;
|
||||
do
|
||||
{
|
||||
if (!is_root(apath))
|
||||
{
|
||||
// trim the path of trailing path separators
|
||||
auto i = apath.find_last_not_of(PATH_SEPARATOR);
|
||||
if (i == std::string::npos)
|
||||
break;
|
||||
apath = apath.substr(0, i + 1);
|
||||
}
|
||||
|
||||
apath_trimmed = apath;
|
||||
|
||||
// stat the path
|
||||
|
Loading…
Reference in New Issue
Block a user