windows: fix hang while reading from directory

This commit is contained in:
Michael Eischer
2026-05-10 01:07:34 +02:00
parent 7b46aa1b9e
commit 9ffe021962
+4
View File
@@ -71,6 +71,10 @@ func ResetPermissions(path string) error {
// Readdirnames returns a list of file in a directory. Flags are passed to fs.OpenFile.
// O_RDONLY and O_DIRECTORY are implied.
func Readdirnames(filesystem FS, dir string, flags int) ([]string, error) {
// cleanup internal flag that conflicts with actual windows API flags
if runtime.GOOS == "windows" {
flags &^= O_NOFOLLOW
}
f, err := filesystem.OpenFile(dir, O_RDONLY|O_DIRECTORY|flags, false)
if err != nil {
return nil, fmt.Errorf("openfile for readdirnames failed: %w", err)