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:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user