| ... | ... | @@ -633,7 +633,11 @@ pub const ReadFileError = File.OpenError || File.Reader.Error; |
| 633 | 633 | /// * On WASI, `file_path` should be encoded as valid UTF-8. |
| 634 | 634 | /// * On other platforms, `file_path` is an opaque sequence of bytes with no particular encoding. |
| 635 | 635 | pub fn readFile(dir: Dir, io: Io, file_path: []const u8, buffer: []u8) ReadFileError![]u8 { |
| 636 | | var file = try dir.openFile(io, file_path, .{}); |
| 636 | var file = try dir.openFile(io, file_path, .{ |
| 637 | // We can take advantage of this on Windows since it doesn't involve any extra syscalls, |
| 638 | // so we can get error.IsDir during open rather than during the read. |
| 639 | .allow_directory = if (native_os == .windows) false else true, |
| 640 | }); |
| 637 | 641 | defer file.close(io); |
| 638 | 642 | |
| 639 | 643 | var reader = file.reader(io, &.{}); |
| ... | ... | @@ -1217,7 +1221,11 @@ pub fn readFileAllocOptions( |
| 1217 | 1221 | comptime alignment: std.mem.Alignment, |
| 1218 | 1222 | comptime sentinel: ?u8, |
| 1219 | 1223 | ) ReadFileAllocError!(if (sentinel) |s| [:s]align(alignment.toByteUnits()) u8 else []align(alignment.toByteUnits()) u8) { |
| 1220 | | var file = try dir.openFile(io, sub_path, .{}); |
| 1224 | var file = try dir.openFile(io, sub_path, .{ |
| 1225 | // We can take advantage of this on Windows since it doesn't involve any extra syscalls, |
| 1226 | // so we can get error.IsDir during open rather than during the read. |
| 1227 | .allow_directory = if (native_os == .windows) false else true, |
| 1228 | }); |
| 1221 | 1229 | defer file.close(io); |
| 1222 | 1230 | var file_reader = file.reader(io, &.{}); |
| 1223 | 1231 | return file_reader.interface.allocRemainingAlignedSentinel(gpa, limit, alignment, sentinel) catch |err| switch (err) { |