MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / pathTruncate

Function pathTruncate

launcher/FileSystem.cpp:738–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738QString pathTruncate(const QString& path, int depth)
739{
740 if (path.isEmpty() || (depth < 0))
741 return "";
742
743 QString trunc = QFileInfo(path).path();
744
745 if (pathDepth(trunc) > depth) {
746 return pathTruncate(trunc, depth);
747 }
748
749 auto parts = QDir::toNativeSeparators(trunc).split(QDir::separator(), Qt::SkipEmptyParts);
750
751 if (parts.startsWith(".") && !path.startsWith(".")) {
752 parts.removeFirst();
753 }
754 if (QDir::toNativeSeparators(path).startsWith(QDir::separator())) {
755 parts.prepend("");
756 }
757
758 trunc = parts.join(QDir::separator());
759
760 return trunc;
761}
762
763QString ResolveExecutable(QString path)
764{

Callers 2

make_link_listMethod · 0.85
test_path_truncMethod · 0.85

Calls 4

QFileInfoClass · 0.85
pathDepthFunction · 0.85
isEmptyMethod · 0.45
pathMethod · 0.45

Tested by 1

test_path_truncMethod · 0.68