MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / pathTruncate

Function pathTruncate

launcher/FileSystem.cpp:756–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754}
755
756QString pathTruncate(const QString& path, int depth)
757{
758 if (path.isEmpty() || (depth < 0))
759 return "";
760
761 QString trunc = QFileInfo(path).path();
762
763 if (pathDepth(trunc) > depth) {
764 return pathTruncate(trunc, depth);
765 }
766
767#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
768 auto parts = QDir::toNativeSeparators(trunc).split(QDir::separator(), QString::SkipEmptyParts);
769#else
770 auto parts = QDir::toNativeSeparators(trunc).split(QDir::separator(), Qt::SkipEmptyParts);
771#endif
772
773 if (parts.startsWith(".") && !path.startsWith(".")) {
774 parts.removeFirst();
775 }
776 if (QDir::toNativeSeparators(path).startsWith(QDir::separator())) {
777 parts.prepend("");
778 }
779
780 trunc = parts.join(QDir::separator());
781
782 return trunc;
783}
784
785QString ResolveExecutable(QString path)
786{

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