aboutsummaryrefslogtreecommitdiff
path: root/src/fs.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-12 20:33:58 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-12 20:33:58 -0700
commitf12ed9904b03e11f755dce7b614925ea087f40da (patch)
treecfbbcab5ee4931d67b8e15d8175291675019ab92 /src/fs.zig
parent1010bae1a350d12f7db49b8ca7f94aa748790b77 (diff)
downloadbun-f12ed9904b03e11f755dce7b614925ea087f40da.tar.gz
bun-f12ed9904b03e11f755dce7b614925ea087f40da.tar.zst
bun-f12ed9904b03e11f755dce7b614925ea087f40da.zip
okay I think that's most of resolving packages/imports algorithm!!!
Former-commit-id: 80037859ec5236e13314a336e28d5f46a96c3300
Diffstat (limited to 'src/fs.zig')
-rw-r--r--src/fs.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/fs.zig b/src/fs.zig
index 2337bdb19..e5ab8e832 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -629,6 +629,7 @@ pub const Path = struct {
text: string,
namespace: string = "unspecified",
name: PathName,
+ is_disabled: bool = false,
pub fn generateKey(p: *Path, allocator: *std.mem.Allocator) !string {
return try std.fmt.allocPrint(allocator, "{s}://{s}", .{ p.namespace, p.text });
@@ -643,6 +644,26 @@ pub const Path = struct {
return str;
}
+ // for now, assume you won't try to normalize a path longer than 1024 chars
+ pub fn normalizeNoAlloc(str: string, comptime remap_windows_paths: bool) string {
+ if (str.len == 0 or (str.len == 1 and (str[0] == ' ' or str[0] == '\\'))) return ".";
+
+ if (remap_windows_paths) {
+ std.mem.copy(u8, &normalize_buf, str);
+ var i: usize = 0;
+ while (i < str.len) : (i += 1) {
+ if (str[i] == '\\') {
+ normalize_buf[i] = '/';
+ }
+ }
+ }
+
+ if (resolvePath(&normalize_buf, str)) |out| {
+ return out;
+ }
+ return str;
+ }
+
pub fn init(text: string) Path {
return Path{ .pretty = text, .text = text, .namespace = "file", .name = PathName.init(text) };
}