fix: on windows use FindClose close handler (#17306)

This commit is contained in:
jiuker 2023-05-30 17:15:57 +08:00 committed by GitHub
parent 669acbb032
commit 043fd8b536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,7 @@ func readDirFn(dirPath string, filter func(name string, typ os.FileMode) error)
} }
return err return err
} }
defer syscall.CloseHandle(handle) defer syscall.FindClose(handle)
for ; ; err = syscall.FindNextFile(handle, data) { for ; ; err = syscall.FindNextFile(handle, data) {
if err != nil { if err != nil {
@ -128,7 +128,7 @@ func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err er
return nil, syscallErrToFileErr(dirPath, err) return nil, syscallErrToFileErr(dirPath, err)
} }
defer syscall.CloseHandle(handle) defer syscall.FindClose(handle)
count := opts.count count := opts.count
for ; count != 0; err = syscall.FindNextFile(handle, data) { for ; count != 0; err = syscall.FindNextFile(handle, data) {