diff options
author | Himbeer <himbeer@disroot.org> | 2024-06-30 20:43:26 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-06-30 20:43:26 +0200 |
commit | 38cf5c885259d1669d5068e107612e1a7905e25e (patch) | |
tree | 3d7abb83e49242410d6dce1ccd1283b864bc842f /src | |
parent | 3a58fabdc6f4c7a95fc789f192478f269683f060 (diff) |
vfs: Add provideResourceZ C-string-compatible wrapper for provideResource
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/vfs.zig | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/vfs.zig b/src/lib/vfs.zig index 5bb8ca4..e424493 100644 --- a/src/lib/vfs.zig +++ b/src/lib/vfs.zig @@ -4,6 +4,8 @@ const std = @import("std"); +const mem = std.mem; + var root = undefined; pub const Error = error{ @@ -40,10 +42,10 @@ pub const Inode = struct { pub const Node = std.DoublyLinkedList(Inode).Node; pub const Tree = struct { - allocator: std.mem.Allocator, + allocator: mem.Allocator, nodes: std.DoublyLinkedList(Inode), - pub fn init(allocator: std.mem.Allocator) Tree { + pub fn init(allocator: mem.Allocator) Tree { return .{ .allocator = allocator, .nodes = std.DoublyLinkedList(Inode){}, @@ -74,7 +76,7 @@ pub const Tree = struct { } }; -pub fn init(allocator: std.mem.Allocator) void { +pub fn init(allocator: mem.Allocator) void { root = Tree.init(allocator); } @@ -109,3 +111,7 @@ pub fn provideResource(path: []const u8, resource: Resource) !void { } else return Error.NotADirectory; } else return Error.NotFound; } + +pub fn provideResourceZ(path_c: [*:0]const u8, resource: Resource) !void { + return provideResource(mem.sliceTo(path_c, 0), resource); +} |