authorgravatar for gereeter+code@gmail.comJonathan S <gereeter+code@gmail.com> 2019-11-25 01:46:35-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 23:46:48-05:00
logec569ff26a325f359649bc1cc3515799ceccb62f
tree9d7c3d78805cd1f207ba85a28a66c2d4199fdbc2
parent8baf226d693a8c522be8d66ecd4edb11fa99a749

Or in O_DIRECTORY in openDirFlagsC to capture the fact that it is intended for opening directories


1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/fs.zig+3-3
...@@ -822,7 +822,7 @@ pub const Dir = struct {...@@ -822,7 +822,7 @@ pub const Dir = struct {
822 return self.openDirTraverseW(&sub_path_w);822 return self.openDirTraverseW(&sub_path_w);
823 } else {823 } else {
824 const O_PATH = if (@hasDecl(os, "O_PATH")) os.O_PATH else 0;824 const O_PATH = if (@hasDecl(os, "O_PATH")) os.O_PATH else 0;
825 return self.openDirFlagsC(sub_path_c, os.O_RDONLY | os.O_DIRECTORY | os.O_CLOEXEC | O_PATH);825 return self.openDirFlagsC(sub_path_c, os.O_RDONLY | os.O_CLOEXEC | O_PATH);
826 }826 }
827 }827 }
828828
...@@ -832,12 +832,12 @@ pub const Dir = struct {...@@ -832,12 +832,12 @@ pub const Dir = struct {
832 const sub_path_w = try os.windows.cStrToPrefixedFileW(sub_path_c);832 const sub_path_w = try os.windows.cStrToPrefixedFileW(sub_path_c);
833 return self.openDirListW(&sub_path_w);833 return self.openDirListW(&sub_path_w);
834 } else {834 } else {
835 return self.openDirFlagsC(sub_path_c, os.O_RDONLY | os.O_DIRECTORY | os.O_CLOEXEC);835 return self.openDirFlagsC(sub_path_c, os.O_RDONLY | os.O_CLOEXEC);
836 }836 }
837 }837 }
838838
839 fn openDirFlagsC(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {839 fn openDirFlagsC(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {
840 const fd = os.openatC(self.fd, sub_path_c, flags, 0) catch |err| switch (err) {840 const fd = os.openatC(self.fd, sub_path_c, flags | os.O_DIRECTORY, 0) catch |err| switch (err) {
841 error.FileTooBig => unreachable, // can't happen for directories841 error.FileTooBig => unreachable, // can't happen for directories
842 error.IsDir => unreachable, // we're providing O_DIRECTORY842 error.IsDir => unreachable, // we're providing O_DIRECTORY
843 error.NoSpaceLeft => unreachable, // not providing O_CREAT843 error.NoSpaceLeft => unreachable, // not providing O_CREAT