@@ -151,7 +151,7 @@ test "Dir.Iterator" {
151
151
defer tmp_dir .cleanup ();
152
152
153
153
// First, create a couple of entries to iterate over.
154
- const file = try tmp_dir .dir .createFile ("some_file" , .{});
154
+ var file = try tmp_dir .dir .createFile ("some_file" , .{});
155
155
file .close ();
156
156
157
157
try tmp_dir .dir .makeDir ("some_dir" );
@@ -523,7 +523,7 @@ test "renameAbsolute" {
523
523
test "openSelfExe" {
524
524
if (builtin .os .tag == .wasi ) return error .SkipZigTest ;
525
525
526
- const self_exe_file = try std .fs .openSelfExe (.{});
526
+ var self_exe_file = try std .fs .openSelfExe (.{});
527
527
self_exe_file .close ();
528
528
}
529
529
@@ -803,10 +803,10 @@ test "open file with exclusive nonblocking lock twice" {
803
803
var tmp = tmpDir (.{});
804
804
defer tmp .cleanup ();
805
805
806
- const file1 = try tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
806
+ var file1 = try tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
807
807
defer file1 .close ();
808
808
809
- const file2 = tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
809
+ var file2 = tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
810
810
try testing .expectError (error .WouldBlock , file2 );
811
811
}
812
812
@@ -818,10 +818,10 @@ test "open file with shared and exclusive nonblocking lock" {
818
818
var tmp = tmpDir (.{});
819
819
defer tmp .cleanup ();
820
820
821
- const file1 = try tmp .dir .createFile (filename , .{ .lock = .Shared , .lock_nonblocking = true });
821
+ var file1 = try tmp .dir .createFile (filename , .{ .lock = .Shared , .lock_nonblocking = true });
822
822
defer file1 .close ();
823
823
824
- const file2 = tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
824
+ var file2 = tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
825
825
try testing .expectError (error .WouldBlock , file2 );
826
826
}
827
827
@@ -833,10 +833,10 @@ test "open file with exclusive and shared nonblocking lock" {
833
833
var tmp = tmpDir (.{});
834
834
defer tmp .cleanup ();
835
835
836
- const file1 = try tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
836
+ var file1 = try tmp .dir .createFile (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
837
837
defer file1 .close ();
838
838
839
- const file2 = tmp .dir .createFile (filename , .{ .lock = .Shared , .lock_nonblocking = true });
839
+ var file2 = tmp .dir .createFile (filename , .{ .lock = .Shared , .lock_nonblocking = true });
840
840
try testing .expectError (error .WouldBlock , file2 );
841
841
}
842
842
@@ -853,12 +853,12 @@ test "open file with exclusive lock twice, make sure it waits" {
853
853
var tmp = tmpDir (.{});
854
854
defer tmp .cleanup ();
855
855
856
- const file = try tmp .dir .createFile (filename , .{ .lock = .Exclusive });
856
+ var file = try tmp .dir .createFile (filename , .{ .lock = .Exclusive });
857
857
errdefer file .close ();
858
858
859
859
const S = struct {
860
860
fn checkFn (dir : * fs.Dir , evt : * std.Thread.ResetEvent ) ! void {
861
- const file1 = try dir .createFile (filename , .{ .lock = .Exclusive });
861
+ var file1 = try dir .createFile (filename , .{ .lock = .Exclusive });
862
862
defer file1 .close ();
863
863
evt .set ();
864
864
}
@@ -892,9 +892,9 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" {
892
892
const filename = try fs .path .resolve (allocator , & file_paths );
893
893
defer allocator .free (filename );
894
894
895
- const file1 = try fs .createFileAbsolute (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
895
+ var file1 = try fs .createFileAbsolute (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
896
896
897
- const file2 = fs .createFileAbsolute (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
897
+ var file2 = fs .createFileAbsolute (filename , .{ .lock = .Exclusive , .lock_nonblocking = true });
898
898
file1 .close ();
899
899
try testing .expectError (error .WouldBlock , file2 );
900
900
@@ -962,13 +962,13 @@ test ". and .. in fs.Dir functions" {
962
962
var created_subdir = try tmp .dir .openDir ("./subdir" , .{});
963
963
created_subdir .close ();
964
964
965
- const created_file = try tmp .dir .createFile ("./subdir/../file" , .{});
965
+ var created_file = try tmp .dir .createFile ("./subdir/../file" , .{});
966
966
created_file .close ();
967
967
try tmp .dir .access ("./subdir/../file" , .{});
968
968
969
969
try tmp .dir .copyFile ("./subdir/../file" , tmp .dir , "./subdir/../copy" , .{});
970
970
try tmp .dir .rename ("./subdir/../copy" , "./subdir/../rename" );
971
- const renamed_file = try tmp .dir .openFile ("./subdir/../rename" , .{});
971
+ var renamed_file = try tmp .dir .openFile ("./subdir/../rename" , .{});
972
972
renamed_file .close ();
973
973
try tmp .dir .deleteFile ("./subdir/../rename" );
974
974
@@ -1001,20 +1001,20 @@ test ". and .. in absolute functions" {
1001
1001
created_subdir .close ();
1002
1002
1003
1003
const created_file_path = try fs .path .join (allocator , &[_ ][]const u8 { subdir_path , "../file" });
1004
- const created_file = try fs .createFileAbsolute (created_file_path , .{});
1004
+ var created_file = try fs .createFileAbsolute (created_file_path , .{});
1005
1005
created_file .close ();
1006
1006
try fs .accessAbsolute (created_file_path , .{});
1007
1007
1008
1008
const copied_file_path = try fs .path .join (allocator , &[_ ][]const u8 { subdir_path , "../copy" });
1009
1009
try fs .copyFileAbsolute (created_file_path , copied_file_path , .{});
1010
1010
const renamed_file_path = try fs .path .join (allocator , &[_ ][]const u8 { subdir_path , "../rename" });
1011
1011
try fs .renameAbsolute (copied_file_path , renamed_file_path );
1012
- const renamed_file = try fs .openFileAbsolute (renamed_file_path , .{});
1012
+ var renamed_file = try fs .openFileAbsolute (renamed_file_path , .{});
1013
1013
renamed_file .close ();
1014
1014
try fs .deleteFileAbsolute (renamed_file_path );
1015
1015
1016
1016
const update_file_path = try fs .path .join (allocator , &[_ ][]const u8 { subdir_path , "../update" });
1017
- const update_file = try fs .createFileAbsolute (update_file_path , .{});
1017
+ var update_file = try fs .createFileAbsolute (update_file_path , .{});
1018
1018
try update_file .writeAll ("something" );
1019
1019
update_file .close ();
1020
1020
const prev_status = try fs .updateFileAbsolute (created_file_path , update_file_path , .{});
@@ -1030,7 +1030,7 @@ test "chmod" {
1030
1030
var tmp = tmpDir (.{});
1031
1031
defer tmp .cleanup ();
1032
1032
1033
- const file = try tmp .dir .createFile ("test_file" , .{ .mode = 0o600 });
1033
+ var file = try tmp .dir .createFile ("test_file" , .{ .mode = 0o600 });
1034
1034
defer file .close ();
1035
1035
try testing .expect ((try file .stat ()).mode & 0o7777 == 0o600 );
1036
1036
@@ -1052,7 +1052,7 @@ test "chown" {
1052
1052
var tmp = tmpDir (.{});
1053
1053
defer tmp .cleanup ();
1054
1054
1055
- const file = try tmp .dir .createFile ("test_file" , .{});
1055
+ var file = try tmp .dir .createFile ("test_file" , .{});
1056
1056
defer file .close ();
1057
1057
try file .chown (null , null );
1058
1058
0 commit comments