feat(local_prov): fix path separator

This commit is contained in:
2025-05-14 05:45:29 +02:00
parent 8b9e51cf30
commit 4eda4d335b

View File

@@ -56,18 +56,18 @@ pub const LocalContentProvider = struct {
initContext: *const InitContext, initContext: *const InitContext,
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
) GetItemsError!*Item { ) GetItemsError!*Item {
const path = try std.mem.replaceOwned(u8, allocator, fullName.path, "/", "\\"); const native_path = try std.mem.replaceOwned(u8, allocator, fullName.path, "/", std.fs.path.sep_str);
defer allocator.free(path); defer allocator.free(native_path);
const kind: union(enum) { directory, file } = blk: { const kind: union(enum) { directory, file } = blk: {
// FIXME: properly handle different errors // FIXME: properly handle different errors
var dir = std.fs.cwd().openDir(path, .{}); var dir = std.fs.cwd().openDir(native_path, .{});
if (dir) |*d| { if (dir) |*d| {
d.close(); d.close();
break :blk .directory; break :blk .directory;
} else |_| {} } else |_| {}
var file = std.fs.cwd().openFile(path, .{}); var file = std.fs.cwd().openFile(native_path, .{});
if (file) |*f| { if (file) |*f| {
f.close(); f.close();
break :blk .file; break :blk .file;