std.fs.path: make relative a pure function

Instead of querying the operating system for current working directory
and environment variables, this function now accepts those things as
inputs.
This commit is contained in:
Andrew Kelley
2026-01-01 14:53:21 -08:00
parent b64491f2d6
commit 08447ca47e
15 changed files with 405 additions and 428 deletions
+1 -2
View File
@@ -1738,8 +1738,7 @@ pub fn pathFromRoot(b: *Build, sub_path: []const u8) []u8 {
}
fn pathFromCwd(b: *Build, sub_path: []const u8) []u8 {
const cwd = process.getCwdAlloc(b.allocator) catch @panic("OOM");
return b.pathResolve(&.{ cwd, sub_path });
return b.pathResolve(&.{ b.graph.cache.cwd, sub_path });
}
pub fn pathJoin(b: *Build, paths: []const []const u8) []u8 {