Skip to content

Commit c3cf822

Browse files
committed
general fixes & windows compat
1 parent a2a3ee1 commit c3cf822

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

build.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub fn build(b: *std.Build) void {
129129

130130
const mkfs_fat = b.addExecutable(.{
131131
.name = "mkfs.fat",
132-
.target = b.host,
132+
.target = b.resolveTargetQuery(.{}),
133133
.optimize = .ReleaseSafe,
134134
.root_source_file = b.path("src/mkfs.fat.zig"),
135135
});
@@ -416,7 +416,7 @@ pub const InitializeDiskStep = struct {
416416
var buffer: [64]u8 = undefined;
417417
context.appendSliceAssumeCapacity(std.fmt.bufPrint(&buffer, "[{}]", .{part_id}) catch unreachable);
418418

419-
try writeDiskImage(b, asking, disk, base + auto_offset, part.size, part.data, context);
419+
try writeDiskImage(b, asking, disk, part.offset orelse base + auto_offset, part.size, part.data, context);
420420

421421
auto_offset += part.size;
422422
}
@@ -459,16 +459,16 @@ pub const InitializeDiskStep = struct {
459459
for (fs.items) |item| {
460460
switch (item) {
461461
.empty_dir => |dir| {
462-
try argv.append(b.fmt("mkdir:{s}", .{dir}));
462+
try argv.append(b.fmt("mkdir;{s}", .{dir}));
463463
},
464464
.copy_dir => |src_dst| {
465-
try argv.append(b.fmt("dir:{s}:{s}", .{
465+
try argv.append(b.fmt("dir;{s};{s}", .{
466466
src_dst.source.getPath2(b, asking),
467467
src_dst.destination,
468468
}));
469469
},
470470
.copy_file => |src_dst| {
471-
try argv.append(b.fmt("file:{s}:{s}", .{
471+
try argv.append(b.fmt("file;{s};{s}", .{
472472
src_dst.source.getPath2(b, asking),
473473
src_dst.destination,
474474
}));
@@ -524,9 +524,8 @@ pub const InitializeDiskStep = struct {
524524
}
525525
}
526526

527-
fn make(step: *std.Build.Step, progress: std.Progress.Node) !void {
527+
fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void {
528528
const b = step.owner;
529-
_ = progress;
530529

531530
const ids: *InitializeDiskStep = @fieldParentPtr("step", step);
532531

@@ -629,11 +628,10 @@ pub const Content = union(enum) {
629628
dir.* = try allocator.dupe(u8, dir.*);
630629
},
631630
.copy_dir, .copy_file => |*cp| {
632-
const cp_new = .{
631+
cp.* = .{
633632
.destination = try allocator.dupe(u8, cp.destination),
634633
.source = cp.source.dupe(b),
635634
};
636-
cp.* = cp_new;
637635
},
638636
}
639637
}
@@ -734,6 +732,8 @@ pub const mbr = struct {
734732
empty = 0x00,
735733

736734
fat12 = 0x01,
735+
fat16_small = 0x04,
736+
fat16 = 0x06,
737737
ntfs = 0x07,
738738

739739
fat32_chs = 0x0B,

build.zig.zon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
.version = "0.1.0",
44
.dependencies = .{
55
.zfat = .{
6-
.url = "https://github.com/ZigEmbeddedGroup/zfat/archive/68dbbe19258b174fe4f374a91b4cc939019d9fe7.tar.gz",
7-
.hash = "1220963601b9bc8dacc422d098368567e5c7b84d21f9ae73067fe3eb9c566aea02fd",
6+
.path = "../../libs/zfat"
87
},
98
},
109
.paths = .{

src/shared.zig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn App(comptime Context: type) type {
7070
try Context.init(file_system);
7171

7272
for (command_list) |command_sequence| {
73-
var cmd_iter = std.mem.split(u8, command_sequence, ":");
73+
var cmd_iter = std.mem.splitScalar(u8, command_sequence, ';');
7474

7575
const command_str = cmd_iter.next() orelse return mistake("bad command", .{});
7676

@@ -96,7 +96,13 @@ pub fn App(comptime Context: type) type {
9696

9797
// std.log.info("file(\"{}\", \"{}\")", .{ std.zig.fmtEscapes(src), std.zig.fmtEscapes(dst) });
9898

99-
var file = try std.fs.cwd().openFile(src, .{});
99+
var file = std.fs.cwd().openFile(src, .{}) catch |err| switch (err) {
100+
error.FileNotFound => {
101+
std.log.err("file not found: {s}", .{src});
102+
return err;
103+
},
104+
else => return err,
105+
};
100106
defer file.close();
101107

102108
try addFile(file, dst);
@@ -174,7 +180,7 @@ pub fn App(comptime Context: type) type {
174180
var list = std.ArrayList([]const u8).init(allocator);
175181
defer list.deinit();
176182

177-
var parts = std.mem.tokenize(u8, src_path, "\\/");
183+
var parts = std.mem.tokenizeAny(u8, src_path, "\\/");
178184

179185
while (parts.next()) |part| {
180186
if (std.mem.eql(u8, part, ".")) {

0 commit comments

Comments
 (0)