Commit fd4d366009

Andrew Kelley <andrew@ziglang.org>
2024-07-12 01:25:21
std.Build.Cache.Path: fix the format method
This function previously wrote a trailing directory separator, but that's not correct if the path refers to a file.
1 parent 818f9cb
Changed files (1)
lib
std
Build
Cache
lib/std/Build/Cache/Path.zig
@@ -157,12 +157,17 @@ pub fn format(
     }
     if (self.root_dir.path) |p| {
         try writer.writeAll(p);
-        try writer.writeAll(fs.path.sep_str);
+        if (self.sub_path.len > 0) {
+            try writer.writeAll(fs.path.sep_str);
+            try writer.writeAll(self.sub_path);
+        }
+        return;
     }
     if (self.sub_path.len > 0) {
         try writer.writeAll(self.sub_path);
-        try writer.writeAll(fs.path.sep_str);
+        return;
     }
+    try writer.writeByte('.');
 }
 
 pub fn eql(self: Path, other: Path) bool {