os: fix Windows (*os.File).Seek on directory handle #36019
Comments
Change https://golang.org/cl/210283 mentions this issue: |
This test was recently added in CL 209961. Apparently Windows can't seek a directory filehandle? And move the test from test/fixedbugs (which is mostly for compiler bugs) to an os package test. Updates #36019 Change-Id: I626b69b0294471014901d0ccfeefe5e2c7651788 Reviewed-on: https://go-review.googlesource.com/c/go/+/210283 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Go use FindFirstFile, FindNextFile and FindClose Windows API to implement directory reading. The API does not provide functionality to seek to random position of the directory. I don't know what the alternatives are, if any. Alex |
Change https://golang.org/cl/213439 mentions this issue: |
Updates #36019 Change-Id: I9fea2c3c5138e2233290979e4724f6e7b91da652 Reviewed-on: https://go-review.googlesource.com/c/go/+/213439 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Could File.Seek(0, os.SeekStart) be mapped to FindFirstFile() ? |
https://linux.die.net/man/3/opendir As far as I can see the doc, Go should not support Seek for directory. |
NtQueryDirectoryFile may be of use. |
Yes. But people will still complain that File.Seel(1, os.SeekStart) fails. So, lets not pretend.
Yes, it might work. But is all extra new code worth ability to File.Seek? Alex |
Well you could FindNextFile() in a loop for i < seek_pos? |
I don't understand what you are proposing. Please, send a CL with the change, if you know what to do. Thank you. Alex |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Punting to Go1.17 as we didn’t get much action for the Go1.16 development cycle. |
Half of our Windows builders (windows-386-2008, windows-amd64-2016, windows-amd64-longtest) fail to seek an *os.File opened on a directory.
But windows-amd64-2008 and windows-amd64-2012 work.
Figure this out and re-enable the test on Windows. (The test was added late in the Go 1.14 cycle, just before beta)
The text was updated successfully, but these errors were encountered: