Add Browser - ls

This commit is contained in:
Ralf
2024-11-30 18:06:19 +03:00
parent cb02c59057
commit aebf1ee185
23 changed files with 791 additions and 117 deletions
+30 -1
View File
@@ -16,6 +16,13 @@ QString ReadFileString(const QString &filePath, bool* result)
return content;
}
QString GetBasenameWindows(const QString& path)
{
QStringList pathParts = path.split("\\", Qt::SkipEmptyParts);
return pathParts[pathParts.size()-1];
}
QString GetRootPathWindows(const QString& path)
{
if (path.startsWith("\\\\")) {
@@ -31,4 +38,26 @@ QString GetRootPathWindows(const QString& path)
}
return path;
}
}
QString GetParentPathWindows(const QString& path)
{
if (path.length() == 2 && path[1] == ':')
return path;
if (path.startsWith("\\\\") && !path.contains('\\'))
return path;
QString parentPath = path;
if (!parentPath.endsWith('\\'))
parentPath += '\\';
int lastBackslashIndex = parentPath.lastIndexOf('\\');
int secondLastBackslashIndex = parentPath.lastIndexOf('\\', lastBackslashIndex - 1);
if (secondLastBackslashIndex != -1) {
return parentPath.left(secondLastBackslashIndex);
}
return path;
}