diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-06-20 23:06:04 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-06-20 23:06:04 -0400 |
| commit | edea7a46e5484e30c338699207c8f4b4d8370c97 (patch) | |
| tree | af5d6b5650fe48c56d22a38e54db74e3871c98a8 /lib/std/fs.zig | |
| parent | 5229f6ec68708c3e66393a50ad9f9032ee7f4257 (diff) | |
| parent | faf783e5959a09fb2a1680f8bb7558db96dcbed9 (diff) | |
| download | zig-edea7a46e5484e30c338699207c8f4b4d8370c97.tar.gz zig-edea7a46e5484e30c338699207c8f4b4d8370c97.zip | |
Merge branch 'DrDeano-master'
closes #5648
Diffstat (limited to 'lib/std/fs.zig')
| -rw-r--r-- | lib/std/fs.zig | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 3ff4819ac5..10422b9d54 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -261,17 +261,7 @@ pub const Dir = struct { name: []const u8, kind: Kind, - pub const Kind = enum { - BlockDevice, - CharacterDevice, - Directory, - NamedPipe, - SymLink, - File, - UnixDomainSocket, - Whiteout, - Unknown, - }; + pub const Kind = File.Kind; }; const IteratorError = error{AccessDenied} || os.UnexpectedError; @@ -1527,9 +1517,9 @@ pub const Dir = struct { var size: ?u64 = null; const mode = options.override_mode orelse blk: { - const stat = try in_file.stat(); - size = stat.size; - break :blk stat.mode; + const st = try in_file.stat(); + size = st.size; + break :blk st.mode; }; var atomic_file = try dest_dir.atomicFile(dest_path, .{ .mode = mode }); @@ -1555,6 +1545,17 @@ pub const Dir = struct { return AtomicFile.init(dest_path, options.mode, self, false); } } + + pub const Stat = File.Stat; + pub const StatError = File.StatError; + + pub fn stat(self: Dir) StatError!Stat { + const file: File = .{ + .handle = self.fd, + .capable_io_mode = .blocking, + }; + return file.stat(); + } }; /// Returns an handle to the current working directory. It is not opened with iteration capability. |
