summaryrefslogtreecommitdiff
path: root/src/Command.zig
diff options
context:
space:
mode:
authorWill Pragnell <wpragnell@gmail.com>2023-09-15 16:01:33 -0700
committerWill Pragnell <wpragnell@gmail.com>2023-09-15 16:01:33 -0700
commit8f2ab46e1ebf329cff63bae3eda308b1e3174f58 (patch)
tree3c4dd4a99f2408b078a6e720c4ca495113799b83 /src/Command.zig
parentd700fb6fc760e1ea38a5b4792bd8d0e7d0d4c8e8 (diff)
windows: use cross platform consts where available
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];