@@ -49,7 +49,7 @@ fn Executor(comptime T: type) type {
4949 },
5050
5151 .copy_file = > | data | {
52- var handle = data .source .open () catch | err | switch (err ) {
52+ var handle = data .source .open (io ) catch | err | switch (err ) {
5353 error .FileNotFound = > return , // open() already reported the error
5454 else = > | e | return e ,
5555 };
@@ -61,11 +61,11 @@ fn Executor(comptime T: type) type {
6161 try exec .add_file (data .path , & adapter .interface );
6262 },
6363 .copy_dir = > | data | {
64- var iter_dir = data .source .open_dir () catch | err | switch (err ) {
64+ var iter_dir = data .source .open_dir (io ) catch | err | switch (err ) {
6565 error .FileNotFound = > return , // open() already reported the error
6666 else = > | e | return e ,
6767 };
68- defer iter_dir .close ();
68+ defer iter_dir .close (io );
6969
7070 var walker_memory : [16384 ]u8 = undefined ;
7171 var temp_allocator : std.heap.FixedBufferAllocator = .init (& walker_memory );
@@ -75,7 +75,7 @@ fn Executor(comptime T: type) type {
7575 var walker = try iter_dir .walk (temp_allocator .allocator ());
7676 defer walker .deinit ();
7777
78- while (walker .next () catch | err | return walk_err (err )) | entry | {
78+ while (walker .next (io ) catch | err | return walk_err (err )) | entry | {
7979 const path = std .fmt .bufPrintZ (& path_memory , "{s}/{s}" , .{
8080 data .path ,
8181 entry .path ,
@@ -91,7 +91,7 @@ fn Executor(comptime T: type) type {
9191 .rel_path = entry .basename ,
9292 };
9393
94- var file = try fname .open ();
94+ var file = try fname .open (io );
9595 defer file .close (io );
9696
9797 var buffer : [1024 ]u8 = undefined ;
@@ -106,8 +106,8 @@ fn Executor(comptime T: type) type {
106106
107107 else = > {
108108 var realpath_buffer : [std .fs .max_path_bytes ]u8 = undefined ;
109- std .log .warn ("cannot copy file {! s}: {s} is not a supported file type!" , .{
110- entry .dir .realpath ( entry .path , & realpath_buffer ),
109+ std .log .warn ("cannot copy file {s}: {s} is not a supported file type!" , .{
110+ if ( entry .dir .realPathFile ( io , entry .path , & realpath_buffer )) | l | realpath_buffer [0 .. l ] else | e | @errorName ( e ),
111111 @tagName (entry .kind ),
112112 });
113113 },
@@ -157,10 +157,9 @@ fn Executor(comptime T: type) type {
157157 try exec .inner .mkdir (path );
158158 }
159159
160- fn walk_err (err : (std .fs .Dir .OpenError || std.mem.Allocator.Error )) dim.Content.RenderError {
160+ fn walk_err (err : (std .Io .Dir .OpenError || std.mem.Allocator.Error )) dim.Content.RenderError {
161161 return switch (err ) {
162- error .BadPathName ,
163- error .NameTooLong = > error .InvalidPath ,
162+ error .BadPathName , error .NameTooLong = > error .InvalidPath ,
164163
165164 error .OutOfMemory = > error .OutOfMemory ,
166165 error .FileNotFound = > error .FileNotFound ,
@@ -177,14 +176,15 @@ fn Executor(comptime T: type) type {
177176 error .ProcessFdQuotaExceeded ,
178177 error .SystemFdQuotaExceeded ,
179178 error .NotDir ,
180- error .PermissionDenied , = > error .IoError ,
179+ error .PermissionDenied ,
180+ = > error .IoError ,
181181 };
182182 }
183183 };
184184}
185185
186- fn parse_path (ctx : dim.Context ) ! [:0 ]const u8 {
187- const path = try ctx .parse_string ();
186+ fn parse_path (ctx : dim.Context , stdio : std.Io ) ! [:0 ]const u8 {
187+ const path = try ctx .parse_string (stdio );
188188
189189 if (path .len == 0 ) {
190190 try ctx .report_nonfatal_error ("Path cannot be empty!" , .{});
@@ -216,41 +216,41 @@ fn parse_path(ctx: dim.Context) ![:0]const u8 {
216216 return try normalize (ctx .get_arena (), path );
217217}
218218
219- pub fn parse_ops (ctx : dim.Context , end_seq : []const u8 , handler : anytype ) ! void {
219+ pub fn parse_ops (ctx : dim.Context , stdio : std.Io , end_seq : []const u8 , handler : anytype ) ! void {
220220 while (true ) {
221- const opsel = try ctx .parse_string ();
221+ const opsel = try ctx .parse_string (stdio );
222222 if (std .mem .eql (u8 , opsel , end_seq ))
223223 return ;
224224
225225 if (std .mem .eql (u8 , opsel , "mkdir" )) {
226- const path = try parse_path (ctx );
226+ const path = try parse_path (ctx , stdio );
227227 try handler .append_common_op (FsOperation {
228228 .make_dir = .{ .path = path },
229229 });
230230 } else if (std .mem .eql (u8 , opsel , "copy-dir" )) {
231- const path = try parse_path (ctx );
232- const src = try ctx .parse_file_name ();
231+ const path = try parse_path (ctx , stdio );
232+ const src = try ctx .parse_file_name (stdio );
233233
234234 try handler .append_common_op (FsOperation {
235235 .copy_dir = .{ .path = path , .source = src },
236236 });
237237 } else if (std .mem .eql (u8 , opsel , "copy-file" )) {
238- const path = try parse_path (ctx );
239- const src = try ctx .parse_file_name ();
238+ const path = try parse_path (ctx , stdio );
239+ const src = try ctx .parse_file_name (stdio );
240240
241241 try handler .append_common_op (FsOperation {
242242 .copy_file = .{ .path = path , .source = src },
243243 });
244244 } else if (std .mem .eql (u8 , opsel , "create-file" )) {
245- const path = try parse_path (ctx );
246- const size = try ctx .parse_mem_size ();
247- const contents = try ctx .parse_content ();
245+ const path = try parse_path (ctx , stdio );
246+ const size = try ctx .parse_mem_size (stdio );
247+ const contents = try ctx .parse_content (stdio );
248248
249249 try handler .append_common_op (FsOperation {
250250 .create_file = .{ .path = path , .size = size , .contents = contents },
251251 });
252252 } else {
253- try handler .parse_custom_op (ctx , opsel );
253+ try handler .parse_custom_op (stdio , ctx , opsel );
254254 }
255255 }
256256}
0 commit comments