mirror of
https://github.com/holub/mame
synced 2025-05-03 21:13:18 +03:00
Third time is a charm :-)
This commit is contained in:
parent
22c402885d
commit
8db5491763
@ -114,22 +114,22 @@ int is_path_separator(char c)
|
|||||||
static void parse_parent_path(const std::string &path, std::string::size_type *beginpos, std::string::size_type *endpos)
|
static void parse_parent_path(const std::string &path, std::string::size_type *beginpos, std::string::size_type *endpos)
|
||||||
{
|
{
|
||||||
std::string::size_type length = path.length();
|
std::string::size_type length = path.length();
|
||||||
int pos;
|
std::string::size_type pos;
|
||||||
|
|
||||||
/* skip over trailing path separators */
|
// skip over trailing path separators
|
||||||
pos = length - 1;
|
pos = length - 1;
|
||||||
while((pos > 0) && is_path_separator(path[pos]))
|
while ((pos > 0) && is_path_separator(path[pos]))
|
||||||
pos--;
|
pos--;
|
||||||
|
|
||||||
/* return endpos */
|
// return endpos
|
||||||
if (endpos != nullptr)
|
if (endpos != nullptr)
|
||||||
*endpos = pos;
|
*endpos = pos;
|
||||||
|
|
||||||
/* now skip until we find a path separator */
|
// now skip until we find a path separator
|
||||||
while((pos >= 0) && !is_path_separator(path[pos]))
|
while ((pos != std::string::npos) && !is_path_separator(path[pos]))
|
||||||
pos--;
|
pos = (pos > 0) ? pos - 1 : std::string::npos;
|
||||||
|
|
||||||
/* return beginpos */
|
// return beginpos
|
||||||
if (beginpos != nullptr)
|
if (beginpos != nullptr)
|
||||||
*beginpos = pos;
|
*beginpos = pos;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ std::string &zippath_parent(std::string &dst, const std::string &path)
|
|||||||
std::string::size_type pos;
|
std::string::size_type pos;
|
||||||
parse_parent_path(path, &pos, nullptr);
|
parse_parent_path(path, &pos, nullptr);
|
||||||
|
|
||||||
if (pos >= 0)
|
if (pos != std::string::npos)
|
||||||
dst = path.substr(0, pos + 1);
|
dst = path.substr(0, pos + 1);
|
||||||
else
|
else
|
||||||
dst.clear();
|
dst.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user