forked from qt-creator/qt-creator
QmlDesigner: Improve directoryName
Change-Id: Ic8e05cbf6cc139ba140cbec6f904cbba942e2d61 Reviewed-by: Burak Hancerli <burak.hancerli@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -401,12 +401,12 @@ bool isNotExisting(ProjectStorageUpdater::FileState state)
|
|||||||
return !isExisting(state);
|
return !isExisting(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::PathString directoryName(std::string_view directoryPath)
|
std::string_view directoryName(std::string_view directoryPath)
|
||||||
{
|
{
|
||||||
using namespace std::views;
|
auto last = directoryPath.rfind('/');
|
||||||
auto isNotSlash = std::bind_front(std::ranges::not_equal_to{}, '/');
|
if (last == std::string_view::npos)
|
||||||
auto directoryName = directoryPath | reverse | take_while(isNotSlash) | reverse;
|
return {""};
|
||||||
return {directoryName.begin(), directoryName.end()};
|
return directoryPath.substr(last + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user