feat(windows): fix windows bugs
This commit is contained in:
@@ -19,8 +19,8 @@ fn loadChildren(container: *Container) void {
|
||||
}
|
||||
|
||||
var dir = std.fs.cwd().openDir(container.item.nativePath.path, .{ .iterate = true }) catch {
|
||||
const errorContent = std.fmt.allocPrint(container.item.allocator, "Could not open directory '{s}'.", .{container.item.nativePath.path}) catch return;
|
||||
container.item.errors.append(.{ .content = errorContent }) catch return;
|
||||
// const errorContent = std.fmt.allocPrint(container.item.allocator, "Could not open directory '{s}'.", .{container.item.nativePath.path}) catch return;
|
||||
// container.item.errors.append(.{ .content = errorContent }) catch return;
|
||||
return;
|
||||
};
|
||||
defer dir.close();
|
||||
@@ -56,9 +56,27 @@ pub const LocalContentProvider = struct {
|
||||
initContext: *const InitContext,
|
||||
allocator: std.mem.Allocator,
|
||||
) GetItemsError!*Item {
|
||||
const stat = std.fs.cwd().statFile(fullName.path) catch return GetItemsError.NotExists;
|
||||
const path = try std.mem.replaceOwned(u8, allocator, fullName.path, "/", "\\");
|
||||
defer allocator.free(path);
|
||||
|
||||
return switch (stat.kind) {
|
||||
const kind: union(enum) { directory, file } = blk: {
|
||||
// FIXME: properly handle different errors
|
||||
var dir = std.fs.cwd().openDir(path, .{});
|
||||
if (dir) |*d| {
|
||||
d.close();
|
||||
break :blk .directory;
|
||||
} else |_| {}
|
||||
|
||||
var file = std.fs.cwd().openFile(path, .{});
|
||||
if (file) |*f| {
|
||||
f.close();
|
||||
break :blk .file;
|
||||
} else |_| {}
|
||||
|
||||
return GetItemsError.NotExists;
|
||||
};
|
||||
|
||||
return switch (kind) {
|
||||
.directory => blk: {
|
||||
const container = try allocator.create(Container);
|
||||
container.* = Container{
|
||||
@@ -106,9 +124,6 @@ pub const LocalContentProvider = struct {
|
||||
|
||||
break :blk &element.item;
|
||||
},
|
||||
else => @panic(
|
||||
"Unsupported file type\n",
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user