aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Io
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/Io')
-rw-r--r--lib/std/Io/Dir.zig16
-rw-r--r--lib/std/Io/Threaded.zig13
-rw-r--r--lib/std/Io/test.zig2
3 files changed, 18 insertions, 13 deletions
diff --git a/lib/std/Io/Dir.zig b/lib/std/Io/Dir.zig
index 58f81cbb90..755ce924ad 100644
--- a/lib/std/Io/Dir.zig
+++ b/lib/std/Io/Dir.zig
@@ -191,7 +191,7 @@ pub const SelectiveWalker = struct {
while (self.stack.items.len > 0) {
const top = &self.stack.items[self.stack.items.len - 1];
var dirname_len = top.dirname_len;
- if (top.iter.next() catch |err| {
+ if (top.iter.next(io) catch |err| {
// If we get an error, then we want the user to be able to continue
// walking if they want, which means that we need to pop the directory
// that errored from the stack. Otherwise, all future `next` calls would
@@ -302,7 +302,7 @@ pub const Walker = struct {
dir: Dir,
basename: [:0]const u8,
path: [:0]const u8,
- kind: Dir.Entry.Kind,
+ kind: File.Kind,
/// Returns the depth of the entry relative to the initial directory.
/// Returns 1 for a direct child of the initial directory, 2 for an entry
@@ -320,10 +320,10 @@ pub const Walker = struct {
/// After each call to this function, and on deinit(), the memory returned
/// from this function becomes invalid. A copy must be made in order to keep
/// a reference to the path.
- pub fn next(self: *Walker) !?Walker.Entry {
- const entry = try self.inner.next();
+ pub fn next(self: *Walker, io: Io) !?Walker.Entry {
+ const entry = try self.inner.next(io);
if (entry != null and entry.?.kind == .directory) {
- try self.inner.enter(entry.?);
+ try self.inner.enter(io, entry.?);
}
return entry;
}
@@ -495,7 +495,7 @@ pub const WriteFileOptions = struct {
flags: File.CreateFlags = .{},
};
-pub const WriteFileError = File.WriteError || File.OpenError;
+pub const WriteFileError = File.Writer.Error || File.OpenError;
/// Writes content to the file system, using the file creation flags provided.
pub fn writeFile(dir: Dir, io: Io, options: WriteFileOptions) WriteFileError!void {
@@ -556,11 +556,11 @@ pub fn updateFile(
}
if (path.dirname(dest_path)) |dirname| {
- try dest_dir.makePath(io, dirname, .default_dir);
+ try dest_dir.makePath(io, dirname);
}
var buffer: [1000]u8 = undefined; // Used only when direct fd-to-fd is not available.
- var atomic_file = try Dir.atomicFile(dest_dir, dest_path, .{
+ var atomic_file = try dest_dir.atomicFile(io, dest_path, .{
.permissions = actual_permissions,
.write_buffer = &buffer,
});
diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig
index 4ee1d5db53..16e8930267 100644
--- a/lib/std/Io/Threaded.zig
+++ b/lib/std/Io/Threaded.zig
@@ -12,7 +12,7 @@ const std = @import("../std.zig");
const Io = std.Io;
const net = std.Io.net;
const File = std.Io.File;
-const Dir = std.Dir;
+const Dir = std.Io.Dir;
const HostName = std.Io.net.HostName;
const IpAddress = std.Io.net.IpAddress;
const Allocator = std.mem.Allocator;
@@ -1614,13 +1614,14 @@ fn dirMakeOpenPathPosix(
userdata: ?*anyopaque,
dir: Dir,
sub_path: []const u8,
+ permissions: Dir.Permissions,
options: Dir.OpenOptions,
) Dir.MakeOpenPathError!Dir {
const t: *Threaded = @ptrCast(@alignCast(userdata));
const t_io = ioBasic(t);
- return dirOpenDirPosix(t, dir, sub_path, options) catch |err| switch (err) {
+ return dirOpenDirPosix(t, dir, sub_path, permissions, options) catch |err| switch (err) {
error.FileNotFound => {
- try dir.makePath(t_io, sub_path);
+ _ = try dir.makePathStatus(t_io, sub_path, permissions);
return dirOpenDirPosix(t, dir, sub_path, options);
},
else => |e| return e,
@@ -1631,12 +1632,15 @@ fn dirMakeOpenPathWindows(
userdata: ?*anyopaque,
dir: Dir,
sub_path: []const u8,
+ permissions: Dir.Permissions,
options: Dir.OpenOptions,
) Dir.MakeOpenPathError!Dir {
const t: *Threaded = @ptrCast(@alignCast(userdata));
const current_thread = Thread.getCurrent(t);
const w = windows;
+ _ = permissions; // TODO apply these permissions
+
var it = std.fs.path.componentIterator(sub_path);
// If there are no components in the path, then create a dummy component with the full path.
var component: std.fs.path.NativeComponentIterator.Component = it.last() orelse .{
@@ -1746,13 +1750,14 @@ fn dirMakeOpenPathWasi(
userdata: ?*anyopaque,
dir: Dir,
sub_path: []const u8,
+ permissions: Dir.Permissions,
options: Dir.OpenOptions,
) Dir.MakeOpenPathError!Dir {
const t: *Threaded = @ptrCast(@alignCast(userdata));
const t_io = ioBasic(t);
return dirOpenDirWasi(t, dir, sub_path, options) catch |err| switch (err) {
error.FileNotFound => {
- try dir.makePath(t_io, sub_path);
+ _ = try dir.makePathStatus(t_io, sub_path, permissions);
return dirOpenDirWasi(t, dir, sub_path, options);
},
else => |e| return e,
diff --git a/lib/std/Io/test.zig b/lib/std/Io/test.zig
index e911031c7f..9763fb2397 100644
--- a/lib/std/Io/test.zig
+++ b/lib/std/Io/test.zig
@@ -30,7 +30,7 @@ test "write a file, read it, then delete it" {
var file = try tmp.dir.createFile(io, tmp_file_name, .{});
defer file.close(io);
- var file_writer = file.writer(&.{});
+ var file_writer = file.writer(io, &.{});
const st = &file_writer.interface;
try st.print("begin", .{});
try st.writeAll(&data);