mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 22:59:19 +02:00
substr_path refactor
This commit is contained in:
@@ -391,10 +391,10 @@ void replace_slashes(std::string &Filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns potential path part from provided file name
|
// returns potential path part from provided file name
|
||||||
std::string substr_path(std::string const &Filename)
|
std::string_view substr_path(std::string const &Filename)
|
||||||
{
|
{
|
||||||
|
if (auto pos = Filename.rfind('/'); pos != std::string_view::npos)
|
||||||
return (Filename.rfind('/') != std::string::npos ? Filename.substr(0, Filename.rfind('/') + 1) : "");
|
return Filename.substr(0, pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns length of common prefix between two provided strings
|
// returns length of common prefix between two provided strings
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void erase_leading_slashes(std::string &Filename);
|
|||||||
void replace_slashes(std::string &Filename);
|
void replace_slashes(std::string &Filename);
|
||||||
|
|
||||||
// returns potential path part from provided file name
|
// returns potential path part from provided file name
|
||||||
std::string substr_path(std::string const &Filename);
|
std::string_view substr_path(std::string const &Filename);
|
||||||
|
|
||||||
// returns common prefix of two provided strings
|
// returns common prefix of two provided strings
|
||||||
std::ptrdiff_t len_common_prefix(std::string const &Left, std::string const &Right);
|
std::ptrdiff_t len_common_prefix(std::string const &Left, std::string const &Right);
|
||||||
|
|||||||
Reference in New Issue
Block a user