manager: allow parent path annotations

- Allows unlimited amount of `..\` or `../` at the start of DestPath string.
- Each of then will go back one folder.
- Similar to how Linux works or Visual Studio project styles.
- This allows us to install/update lwjgl3ify in PrismLauncher.
This commit is contained in:
Pascal
2025-06-27 09:10:18 +02:00
parent 09c1ac8b08
commit f5596ab0ba
4 changed files with 62 additions and 33 deletions

View File

@@ -67,4 +67,18 @@ public static class Extensions
return @this.UpdateUrl?.Replace("{ref}", @this.RefTag);
return @this.UpdateUrl;
}
public static string GetDestPath(this InstallAction @this, string installDir)
{
var path = @this.DestPath;
var root = Path.GetPathRoot(path);
var start = installDir;
while (root.Length == 3 && root.StartsWith(".."))
{
path = path[root.Length..];
root = Path.GetPathRoot(path);
start = Path.GetDirectoryName(start);
}
return Path.Combine(start, path);
}
}