Branswe支持

This commit is contained in:
2026-01-31 23:36:50 +08:00
parent a974c1ff0f
commit b8cabfd1c0
5 changed files with 672 additions and 1 deletions

View File

@@ -262,7 +262,7 @@ namespace CMLeonOS
}
}
private string GetFullPath(string path)
public string GetFullPath(string path)
{
if (path.StartsWith(@"0:\"))
{
@@ -291,6 +291,69 @@ namespace CMLeonOS
}
}
}
else if (path.StartsWith("../") || path.StartsWith("..\\"))
{
// 支持多层..操作
int level = 0;
string tempPath = path;
while (tempPath.StartsWith("../") || tempPath.StartsWith("..\\"))
{
level++;
if (tempPath.StartsWith("../"))
{
tempPath = tempPath.Substring(3);
}
else if (tempPath.StartsWith("..\\"))
{
tempPath = tempPath.Substring(3);
}
}
// 向上移动level级
string resultPath = currentDirectory;
for (int i = 0; i < level; i++)
{
int lastSlash = resultPath.LastIndexOf('\\');
if (lastSlash == 2) // 0:\
{
resultPath = @"0:\";
}
else
{
resultPath = resultPath.Substring(0, lastSlash);
}
}
return resultPath;
}
else if (path.StartsWith("dir") || path.StartsWith("DIR"))
{
// 支持cd dir1/dir2/dir3等格式
string dirName = path;
// 提取数字部分
string numberPart = "";
for (int i = 3; i < path.Length; i++)
{
if (char.IsDigit(path[i]))
{
numberPart += path[i];
}
else
{
break;
}
}
// 构建完整路径
if (currentDirectory == @"0:\")
{
return $@"0:\{dirName}";
}
else
{
return $@"{currentDirectory}\{dirName}";
}
}
else
{
if (currentDirectory == @"0:\")