Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io/ioutil: ReadDir fails on empty root directories on windows #4601

Closed
ncw opened this issue Dec 31, 2012 · 3 comments
Closed

io/ioutil: ReadDir fails on empty root directories on windows #4601

ncw opened this issue Dec 31, 2012 · 3 comments
Milestone

Comments

@ncw
Copy link
Contributor

ncw commented Dec 31, 2012

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g (i386 version)

Which operating system are you using?

Windows 7 Professional SP1

Which version are you using?  (run 'go version')

go version go1.0.3

How to reproduce the problem

Compile this test program: http://play.golang.org/p/rBGf11wDo7 (dir.exe in transcript
below)

Insert a usb stick, format it and make sure it has no files on it (F: below)

------------------------------------------------------------
C:\>dir f:
 Volume in drive F is EOS_DIGITAL
 Volume Serial Number is xxxx-xxxx

 Directory of F:\

File Not Found
------------------------------------------------------------

Now try the test program which produces these errors rather than an empty directory
listing

------------------------------------------------------------
C:\>dir.exe f:
entries []
err open f:: Access is denied.
Couldn't read directory "f:": open f:: Access is denied.

C:\>dir.exe f:\
entries []
err open f:\: The system cannot find the path specified.
Couldn't read directory "f:\\": open f:\: The system cannot find the path
specified.
------------------------------------------------------------

Creating a file allows the test program to work, showing that this user does have
permission to write to F:

------------------------------------------------------------
C:\>echo hello > f:\test.txt

C:\>dir f:
 Volume in drive F is EOS_DIGITAL
 Volume Serial Number is xxxx-xxxx

 Directory of F:\

31/12/2012  11:25                 8 test.txt
               1 File(s)              8 bytes
               0 Dir(s)  15,995,928,576 bytes free

C:\>dir.exe f:
entries [0x115714b0]
err <nil>

C:\>dir.exe f:\
entries [0x11671510]
err <nil>
------------------------------------------------------------

And removing the file causes it to fail again

------------------------------------------------------------
C:\>del f:\test.txt

C:\>dir f:
 Volume in drive F is EOS_DIGITAL
 Volume Serial Number is xxxx-xxxx

 Directory of F:\

File Not Found

C:\>dir.exe f:
entries []
err open f:: Access is denied.
Couldn't read directory "f:": open f:: Access is denied.

C:\>dir.exe f:\
entries []
err open f:\: The system cannot find the path specified.
Couldn't read directory "f:\\": open f:\: The system cannot find the path
specif
ied.
------------------------------------------------------------

Compare with an empty local directory which doesn't produce any errors

------------------------------------------------------------
C:\>dir z
 Volume in drive C has no label.
 Volume Serial Number is xxxx-xxxx

 Directory of C:\z

31/12/2012  11:32    <DIR>          .
31/12/2012  11:32    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  222,535,602,176 bytes free

C:\>dir.exe z
entries []
err <nil>
------------------------------------------------------------

This behavior is inconsistent and looks wrong to me.  I would expect ReadDir to produce
an empty directory listing not an error.
@alexbrainman
Copy link
Member

Comment 1:

Looks wrong to me too. Thank you for the test case.
Alex

Labels changed: added os-windows, packagebug.

Status changed to Accepted.

@alexbrainman
Copy link
Member

Comment 2:

https://golang.org/cl/7033046/

Owner changed to @alexbrainman.

Status changed to Started.

@alexbrainman
Copy link
Member

Comment 3:

This issue was closed by revision 20e9760.

Status changed to Fixed.

@ncw ncw added fixed labels Jan 7, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants