fix: force normalization of all paths on windows

closes #442
This commit is contained in:
CJ van den Berg 2026-01-22 17:33:10 +01:00
parent 07f1446616
commit c334a0e1ee
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 51 additions and 12 deletions

View file

@ -1001,9 +1001,9 @@ fn request_path_files_async(a_: std.mem.Allocator, parent_: tp.pid_ref, project_
}.spawn_link(a_, parent_, project_, max_, path_);
}
pub fn normalize_file_path(file_path: []const u8) []const u8 {
fn normalize_file_path_project(file_path: []const u8) []const u8 {
const project = tp.env.get().str("project");
const file_path_ = if (project.len == 0)
return if (project.len == 0)
file_path
else if (project.len >= file_path.len)
file_path
@ -1011,7 +1011,6 @@ pub fn normalize_file_path(file_path: []const u8) []const u8 {
file_path[project.len + 1 ..]
else
file_path;
return normalize_file_path_dot_prefix(file_path_);
}
pub fn normalize_file_path_dot_prefix(file_path: []const u8) []const u8 {
@ -1029,6 +1028,22 @@ pub fn normalize_file_path_dot_prefix(file_path: []const u8) []const u8 {
return file_path;
}
pub fn normalize_file_path_windows(file_path_: []const u8, file_path_buf: []u8) []const u8 {
var file_path = file_path_buf[0..file_path_.len];
@memcpy(file_path, file_path_);
for (file_path, 0..) |c, i| if (c == '/') {
file_path[i] = '\\';
};
return file_path;
}
pub fn normalize_file_path(file_path: []const u8, file_path_buf: []u8) []const u8 {
return normalize_file_path_dot_prefix(normalize_file_path_project(if (builtin.os.tag == .windows)
normalize_file_path_windows(file_path, file_path_buf)
else
file_path));
}
pub fn abbreviate_home(buf: []u8, path: []const u8) []const u8 {
const a = std.heap.c_allocator;
if (builtin.os.tag == .windows) return path;