summaryrefslogtreecommitdiff
path: root/src/Command.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Command.zig')
-rw-r--r--src/Command.zig7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/Command.zig b/src/Command.zig
index b2d7e74ef..b9d282aa7 100644
--- a/src/Command.zig
+++ b/src/Command.zig
@@ -223,8 +223,6 @@ pub fn getData(self: Command, comptime DT: type) ?*DT {
/// Search for "cmd" in the PATH and return the absolute path. This will
/// always allocate if there is a non-null result. The caller must free the
/// resulting value.
-///
-/// TODO: windows
pub fn expandPath(alloc: Allocator, cmd: []const u8) !?[]u8 {
// If the command already contains a slash, then we return it as-is
// because it is assumed to be absolute or relative.
@@ -243,8 +241,7 @@ pub fn expandPath(alloc: Allocator, cmd: []const u8) !?[]u8 {
defer if (builtin.os.tag == .windows) alloc.free(PATH);
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
- const path_separator = if (builtin.os.tag == .windows) ";" else ":";
- var it = std.mem.tokenize(u8, PATH, path_separator);
+ var it = std.mem.tokenize(u8, PATH, &[_]u8{std.fs.path.delimiter});
var seen_eacces = false;
while (it.next()) |search_path| {
// We need enough space in our path buffer to store this
@@ -253,7 +250,7 @@ pub fn expandPath(alloc: Allocator, cmd: []const u8) !?[]u8 {
// Copy in the full path
mem.copy(u8, &path_buf, search_path);
- path_buf[search_path.len] = if (builtin.os.tag == .windows) '\\' else '/';
+ path_buf[search_path.len] = std.fs.path.sep;
mem.copy(u8, path_buf[search_path.len + 1 ..], cmd);
path_buf[path_len] = 0;
const full_path = path_buf[0..path_len :0];