Skip to content

Commit eaf1084

Browse files
Change command separator to ;
1 parent 76191fd commit eaf1084

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

build.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub fn build(b: *std.Build) void {
138138
b.installArtifact(mkfs_fat);
139139

140140
// Usage:
141-
var self_dep = std.Build.Dependency{
141+
var self_dep: std.Build.Dependency = .{
142142
.builder = b,
143143
};
144144
usageDemo(b, &self_dep, debug_step);
@@ -175,7 +175,7 @@ fn installDebugDisk(
175175
pub fn initializeDisk(dependency: *std.Build.Dependency, size: u64, content: Content) *InitializeDiskStep {
176176
const ids = dependency.builder.allocator.create(InitializeDiskStep) catch @panic("out of memory");
177177

178-
ids.* = InitializeDiskStep{
178+
ids.* = .{
179179
.step = std.Build.Step.init(.{
180180
.owner = dependency.builder, // TODO: Is this correct?
181181
.id = .custom,
@@ -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
}));
@@ -564,7 +564,7 @@ pub const InitializeDiskStep = struct {
564564
try disk.writeAll("\x00");
565565
try disk.seekTo(0);
566566

567-
var context = HumanContext{};
567+
var context: HumanContext = .{};
568568
context.appendSliceAssumeCapacity("disk");
569569

570570
const disk_image = DiskImage{
@@ -943,9 +943,9 @@ pub const FileSystem = struct {
943943
/// <ops...> is a list of operations that should be performed on the file system:
944944
/// - format Formats the disk image.
945945
/// - mount Mounts the file system, must be before all following:
946-
/// - mkdir:<dst> Creates directory <dst> and all necessary parents.
947-
/// - file:<src>:<dst> Copy <src> to path <dst>. If <dst> exists, it will be overwritten.
948-
/// - dir:<src>:<dst> Copy <src> recursively into <dst>. If <dst> exists, they will be merged.
946+
/// - mkdir;<dst> Creates directory <dst> and all necessary parents.
947+
/// - file;<src>;<dst> Copy <src> to path <dst>. If <dst> exists, it will be overwritten.
948+
/// - dir;<src>;<dst> Copy <src> recursively into <dst>. If <dst> exists, they will be merged.
949949
///
950950
/// <dst> paths are always rooted, even if they don't start with a /, and always use / as a path separator.
951951
///
@@ -986,7 +986,7 @@ pub const FileSystemBuilder = struct {
986986
format: FileSystem.Format,
987987
label: []const u8,
988988
}) FileSystem {
989-
return FileSystem{
989+
return .{
990990
.format = options.format,
991991
.label = fsb.b.dupe(options.label),
992992
.items = fsb.list.toOwnedSlice(fsb.b.allocator) catch @panic("out of memory"),

src/mkfs.fat.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn mkfile(path: []const u8, host_file: std.fs.File) !void {
8181

8282
fn disk_getStatus(intf: *fatfs.Disk) fatfs.Disk.Status {
8383
_ = intf;
84-
return fatfs.Disk.Status{
84+
return .{
8585
.initialized = true,
8686
.disk_present = true,
8787
.write_protected = false,

src/shared.zig

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const std = @import("std");
88
// <ops...> is a list of operations that should be performed on the file system:
99
// - format Formats the disk image.
1010
// - mount Mounts the file system, must be before all following:
11-
// - mkdir:<dst> Creates directory <dst> and all necessary parents.
12-
// - file:<src>:<dst> Copy <src> to path <dst>. If <dst> exists, it will be overwritten.
13-
// - dir:<src>:<dst> Copy <src> recursively into <dst>. If <dst> exists, they will be merged.
11+
// - mkdir;<dst> Creates directory <dst> and all necessary parents.
12+
// - file;<src>;<dst> Copy <src> to path <dst>. If <dst> exists, it will be overwritten.
13+
// - dir;<src>;<dst> Copy <src> recursively into <dst>. If <dst> exists, they will be merged.
1414
//
1515
// <dst> paths are always rooted, even if they don't start with a /, and always use / as a path separator.
1616
//
@@ -56,7 +56,7 @@ pub fn App(comptime Context: type) type {
5656
if (byte_base + byte_len > stat.size)
5757
return mistake("invalid offsets.", .{});
5858

59-
device = BlockDevice{
59+
device = .{
6060
.file = &image_file,
6161
.base = byte_base,
6262
.count = byte_len / BlockDevice.block_size,
@@ -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.splitScalar(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

@@ -84,15 +84,15 @@ pub fn App(comptime Context: type) type {
8484
try Context.mount();
8585
},
8686
.mkdir => {
87-
const dir = try normalize(cmd_iter.next() orelse return mistake("mkdir:<dst> is missing it's <dst> path!", .{}));
87+
const dir = try normalize(cmd_iter.next() orelse return mistake("mkdir;<dst> is missing it's <dst> path!", .{}));
8888

8989
// std.log.info("mkdir(\"{}\")", .{std.zig.fmtEscapes(dir)});
9090

9191
try recursiveMkDir(dir);
9292
},
9393
.file => {
94-
const src = cmd_iter.next() orelse return mistake("file:<src>:<dst> is missing it's <src> path!", .{});
95-
const dst = try normalize(cmd_iter.next() orelse return mistake("file:<src>:<dst> is missing it's <dst> path!", .{}));
94+
const src = cmd_iter.next() orelse return mistake("file;<src>;<dst> is missing it's <src> path!", .{});
95+
const dst = try normalize(cmd_iter.next() orelse return mistake("file;<src>;<dst> is missing it's <dst> path!", .{}));
9696

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

@@ -102,10 +102,8 @@ pub fn App(comptime Context: type) type {
102102
try addFile(file, dst);
103103
},
104104
.dir => {
105-
const src = cmd_iter.next() orelse return mistake("dir:<src>:<dst> is missing it's <src> path!", .{});
106-
const dst = try normalize(cmd_iter.next() orelse return mistake("dir:<src>:<dst> is missing it's <dst> path!", .{}));
107-
108-
// std.log.info("dir(\"{}\", \"{}\")", .{ std.zig.fmtEscapes(src), std.zig.fmtEscapes(dst) });
105+
const src = cmd_iter.next() orelse return mistake("dir;<src>;<dst> is missing it's <src> path!", .{});
106+
const dst = try normalize(cmd_iter.next() orelse return mistake("dir;<src>;<dst> is missing it's <dst> path!", .{}));
109107

110108
var iter_dir = try std.fs.cwd().openDir(src, .{ .iterate = true });
111109
defer iter_dir.close();

0 commit comments

Comments
 (0)