You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bash fails to show info for that dir but still lists other files.
$ mkdir foo bar
$ ./deny foo
$ ls -al
ls: cannot access foo: Permission denied
total 20
drwxrwxr-x 4 luka luka 4096 Jun 16 17:28 .
drwxrwxr-x 233 luka luka 12288 Jun 16 16:26 ..
drwxrwxr-x 2 luka luka 4096 Jun 16 17:28 bar
d????????? ? ? ? ? ? foo
This is working as designed and documented: "In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error."
I think you already found the answer: use Readdirnames.
If directory contains file that cannot be accessed (if lstat fails), f.Readdir fails with an error.
Error can be reproduced using custom FUSE driver.
https://gist.github.com/bancek/4adadd65597a2da44a49
Bash fails to show info for that dir but still lists other files.
Readdir fails with lstat permission denied (http://play.golang.org/p/G_yZ94rkRs).
Readdirnames works fine (http://play.golang.org/p/WY-uBxCjpd).
The text was updated successfully, but these errors were encountered: