@@ -53,7 +53,7 @@ fn clean_download_store(ctx: *context.CliContext, emit_human: bool) !StoreCleanu
5353 defer store_buffer .reset ();
5454
5555 const store_path = try util_data .get_zvm_store (store_buffer );
56- var store_dir = std .fs . openDirAbsolute (store_path , .{ .iterate = true }) catch | err | {
56+ var store_dir = std .Io . Dir . openDirAbsolute (ctx . io , store_path , .{ .iterate = true }) catch | err | {
5757 if (err == error .FileNotFound ) {
5858 if (emit_human ) {
5959 util_output .info ("No old download artifacts found to clean." , .{});
@@ -63,9 +63,9 @@ fn clean_download_store(ctx: *context.CliContext, emit_human: bool) !StoreCleanu
6363
6464 return err ;
6565 };
66- defer store_dir .close ();
66+ defer store_dir .close (ctx . io );
6767
68- const cleanup = try remove_download_artifacts (& store_dir );
68+ const cleanup = try remove_download_artifacts (ctx . io , & store_dir );
6969 if (! emit_human ) return cleanup ;
7070
7171 if (cleanup .files_removed == 0 ) {
@@ -81,18 +81,18 @@ fn clean_download_store(ctx: *context.CliContext, emit_human: bool) !StoreCleanu
8181 return cleanup ;
8282}
8383
84- fn remove_download_artifacts (store_dir : * std.fs .Dir ) ! StoreCleanup {
84+ fn remove_download_artifacts (io : std.Io , store_dir : * std.Io .Dir ) ! StoreCleanup {
8585 var iterator = store_dir .iterate ();
8686 var cleanup = StoreCleanup {};
8787
88- while (try iterator .next ()) | entry | {
88+ while (try iterator .next (io )) | entry | {
8989 if (entry .kind != .file ) continue ;
9090
91- const file = try store_dir .openFile (entry .name , .{});
92- const file_info = try file .stat ();
93- file .close ();
91+ const file = try store_dir .openFile (io , entry .name , .{});
92+ const file_info = try file .stat (io );
93+ file .close (io );
9494
95- try store_dir .deleteFile (entry .name );
95+ try store_dir .deleteFile (io , entry .name );
9696 cleanup .files_removed += 1 ;
9797 cleanup .bytes_freed += file_info .size ;
9898 }
@@ -147,7 +147,7 @@ fn read_current_version(
147147 .zig = > try util_data .get_zvm_current_zig (current_path_buffer ),
148148 .zls = > try util_data .get_zvm_current_zls (current_path_buffer ),
149149 };
150- if (! util_tool .does_path_exist (current_path )) return null ;
150+ if (! util_tool .does_path_exist (ctx . io , current_path )) return null ;
151151
152152 var output_buffer : [limits .limits .temp_buffer_size ]u8 = undefined ;
153153 const version_output = util_data .get_current_version (
@@ -180,16 +180,16 @@ fn clean_versions_for_tool(
180180 .zig = > try util_data .get_zvm_zig_version (versions_path_buffer ),
181181 .zls = > try util_data .get_zvm_zls_version (versions_path_buffer ),
182182 };
183- var versions_dir = std .fs . openDirAbsolute (versions_path , .{ .iterate = true }) catch | err | {
183+ var versions_dir = std .Io . Dir . openDirAbsolute (ctx . io , versions_path , .{ .iterate = true }) catch | err | {
184184 if (err == error .FileNotFound ) return 0 ;
185185 return err ;
186186 };
187- defer versions_dir .close ();
187+ defer versions_dir .close (ctx . io );
188188
189189 var iterator = versions_dir .iterate ();
190190 var versions_removed : usize = 0 ;
191191
192- while (try iterator .next ()) | entry | {
192+ while (try iterator .next (ctx . io )) | entry | {
193193 if (entry .kind != .directory ) continue ;
194194
195195 if (current_version ) | current | {
@@ -208,7 +208,7 @@ fn clean_versions_for_tool(
208208 util_output .info (" Removing {s} {s}" , .{ tool .to_string (), entry .name });
209209 }
210210
211- try versions_dir .deleteTree (entry .name );
211+ try versions_dir .deleteTree (ctx . io , entry .name );
212212 versions_removed += 1 ;
213213 }
214214
@@ -218,18 +218,19 @@ fn clean_versions_for_tool(
218218test "remove_download_artifacts deletes only files" {
219219 var tmp_dir = std .testing .tmpDir (.{});
220220 defer tmp_dir .cleanup ();
221+ const io = std .testing .io ;
221222
222- const artifact = try tmp_dir .dir .createFile ("artifact.tar.xz" , .{});
223- try artifact .writeAll ( "artifact" );
224- artifact .close ();
223+ const artifact = try tmp_dir .dir .createFile (io , "artifact.tar.xz" , .{});
224+ try artifact .writeStreamingAll ( io , "artifact" );
225+ artifact .close (io );
225226
226- try tmp_dir .dir .makeDir ( "versions" );
227+ try tmp_dir .dir .createDir ( io , "versions" , .default_dir );
227228
228229 var dir = tmp_dir .dir ;
229- const cleanup = try remove_download_artifacts (& dir );
230+ const cleanup = try remove_download_artifacts (io , & dir );
230231
231232 try std .testing .expectEqual (@as (usize , 1 ), cleanup .files_removed );
232233 try std .testing .expectEqual (@as (u64 , 8 ), cleanup .bytes_freed );
233- try std .testing .expectError (error .FileNotFound , dir .access ("artifact.tar.xz" , .{}));
234- try dir .access ("versions" , .{});
234+ try std .testing .expectError (error .FileNotFound , dir .access (io , "artifact.tar.xz" , .{}));
235+ try dir .access (io , "versions" , .{});
235236}
0 commit comments