From 89085aa7830219f49a0659b4dba2579d9eb78343 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 10 Dec 2023 19:36:20 -0600 Subject: [PATCH] windows package manager fixes --- core/os/path.onyx | 28 ++++++++++++++-------------- scripts/onyx-pkg.onyx | 6 ++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/core/os/path.onyx b/core/os/path.onyx index 9d540d90..a14c1e10 100644 --- a/core/os/path.onyx +++ b/core/os/path.onyx @@ -6,11 +6,11 @@ use core.conv #local Path_Allocator :: context.temp_allocator -PATH_SEP :: '/' -// #if runtime.compiler_os == .Windows { -// PATH_SEP :: '\\' -// } else { -// } +#if runtime.compiler_os == .Windows { + PATH_SEP :: '\\' +} else { + PATH_SEP :: '/' +} #doc """ Removes: @@ -31,24 +31,24 @@ path_clean :: (path: str, allocator := Path_Allocator) -> str { r, dotdot := 0, 0; if rooted { - string.append(&out, "/"); + string.append(&out, PATH_SEP); r, dotdot = 1, 1; } while r < n { - if path[r] == '/' do r += 1; - elseif path[r] == '.' && (r+1 == n || path[r + 1] == '/') do r += 1; - elseif path[r] == '.' && path[r + 1] == '.' && (r+2 == n || path[r+2] == '/') { + if path[r] == PATH_SEP do r += 1; + elseif path[r] == '.' && (r+1 == n || path[r + 1] == PATH_SEP) do r += 1; + elseif path[r] == '.' && path[r + 1] == '.' && (r+2 == n || path[r+2] == PATH_SEP) { r += 2; if out.length > dotdot { out.length -= 1; - while out.length > dotdot && out[out.length] != '/' { + while out.length > dotdot && out[out.length] != PATH_SEP { out.length -= 1; } } elseif !rooted { if out.length > 0 { - string.append(&out, "/"); + string.append(&out, PATH_SEP); } string.append(&out, ".."); dotdot = out.length; @@ -56,10 +56,10 @@ path_clean :: (path: str, allocator := Path_Allocator) -> str { } else { if (rooted && out.length != 1) || (!rooted && out.length != 0) { - string.append(&out, "/"); + string.append(&out, PATH_SEP); } - while r < n && path[r] != '/' { + while r < n && path[r] != PATH_SEP { string.append(&out, path[r]); r += 1; } @@ -107,7 +107,7 @@ path_directory :: (path: str) -> str { """ path_extension :: (path: str) -> str { for i: range.{ path.length - 1, 0, -1 } { - if path[i] == '/' do break; + if path[i] == PATH_SEP do break; if path[i] == '.' do return path[i .. path.length]; } return ""; diff --git a/scripts/onyx-pkg.onyx b/scripts/onyx-pkg.onyx index 5d98f632..0159a926 100644 --- a/scripts/onyx-pkg.onyx +++ b/scripts/onyx-pkg.onyx @@ -760,6 +760,12 @@ strip_protocol_and_www_from_repo :: (repo: str) -> str { to_return = to_return[0 .. to_return.count - ".git".count]; } + #if runtime.compiler_os == .Windows { + to_return = string.alloc_copy(to_return); + + string.replace(to_return, '/', '\\'); + } + return to_return; } -- 2.25.1