authorgravatar for gereeter+code@gmail.comJonathan S <gereeter+code@gmail.com> 2019-11-22 16:25:43-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 23:46:48-05:00
log001334266a0f6d0d7da4e0eba5b5e317456a39ff
treeae80e306bb7ed28a28d2a88bda558d496f3db274
parent51c57408794ae4411a0059d7f9d30b47d83a534e

Don't pass `FILE_LIST_DIRECTORY` in `openDirTraverseW`.


1 files changed, 7 insertions(+), 4 deletions(-)

lib/std/fs.zig+7-4
...@@ -836,7 +836,7 @@ pub const Dir = struct {...@@ -836,7 +836,7 @@ pub const Dir = struct {
836 }836 }
837 }837 }
838838
839 fn openDirFlagsC(self: Dir, sub_path_c: [*]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, 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
...@@ -850,13 +850,16 @@ pub const Dir = struct {...@@ -850,13 +850,16 @@ pub const Dir = struct {
850 /// Same as `openDirTraverse` except the path parameter is UTF16LE, NT-prefixed.850 /// Same as `openDirTraverse` except the path parameter is UTF16LE, NT-prefixed.
851 /// This function is Windows-only.851 /// This function is Windows-only.
852 pub fn openDirTraverseW(self: Dir, sub_path_w: [*:0]const u16) OpenError!Dir {852 pub fn openDirTraverseW(self: Dir, sub_path_w: [*:0]const u16) OpenError!Dir {
853 // TODO: open without FILE_LIST_DIRECTORY853 return self.openDirAccessMaskW(sub_path_w, w.STANDARD_RIGHTS_READ | w.FILE_READ_ATTRIBUTES | w.FILE_READ_EA | w.SYNCHRONIZE | w.FILE_TRAVERSE);
854 return self.openDirListW(sub_path_w);
855 }854 }
856855
857 /// Same as `openDirList` except the path parameter is UTF16LE, NT-prefixed.856 /// Same as `openDirList` except the path parameter is UTF16LE, NT-prefixed.
858 /// This function is Windows-only.857 /// This function is Windows-only.
859 pub fn openDirListW(self: Dir, sub_path_w: [*:0]const u16) OpenError!Dir {858 pub fn openDirListW(self: Dir, sub_path_w: [*:0]const u16) OpenError!Dir {
859 return self.openDirAccessMaskW(sub_path_w, w.STANDARD_RIGHTS_READ | w.FILE_READ_ATTRIBUTES | w.FILE_READ_EA | w.SYNCHRONIZE | w.FILE_TRAVERSE | w.FILE_LIST_DIRECTORY);
860 }
861
862 fn openDirAccessMaskW(self: Dir, sub_path_w: [*:0]const u16, access_mask: u32) OpenError!Dir {
860 const w = os.windows;863 const w = os.windows;
861864
862 var result = Dir{865 var result = Dir{
...@@ -889,7 +892,7 @@ pub const Dir = struct {...@@ -889,7 +892,7 @@ pub const Dir = struct {
889 var io: w.IO_STATUS_BLOCK = undefined;892 var io: w.IO_STATUS_BLOCK = undefined;
890 const rc = w.ntdll.NtCreateFile(893 const rc = w.ntdll.NtCreateFile(
891 &result.fd,894 &result.fd,
892 w.STANDARD_RIGHTS_READ | w.FILE_READ_ATTRIBUTES | w.FILE_READ_EA | w.SYNCHRONIZE | w.FILE_TRAVERSE | w.FILE_LIST_DIRECTORY,895 access_mask,
893 &attr,896 &attr,
894 &io,897 &io,
895 null,898 null,