-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: File.Fd returns search handle, not directory handle, on Windows #13738
Comments
/cc @alexbrainman |
Yes, we should try and implement windows (*os.File).Chdir, and see what happens. Not for go1.6. Alex |
I know. What I want to clarify here is: Otherwise, there are no easy way to handle this. (because of the compatibility) Thank you. hiro |
Please, explain what you mean here. Are you saying that File.Fd is not documented well? If so, what should File.Fd documentation say? Thank you. Alex |
I think File.Fd returns wrong value, from beginning. (maybe 1.0?)
|
Maybe.
Documentation says:
There is no such thing as "Unix file descriptor" on Windows. So I am not sure, if what you want is in the spec or not. What exactly do you propose we do here? Alex |
I think File.Fd should return uintptr(syscall.InvalidHandle), if the file is a directory. Because current code always return That's what I want to propose. Thank you. hiro |
Why your proposal is better than what we currently have? Alex |
@alexbrainman @hirochachacha 's opinion make sense for me. However, we can implement (*os.File).Chdir without using Fd(). For example, take dirname field on File structure. I wonder what is use-case of Fd() for the directory on windows. |
I know. |
And why returning syscall.InvalidHandle for directories is more "consistent" than returning "search handle"? Alex |
Actually, I'm not a windows expert, so I'm not confident. First, analogy to unix systems, if I open a directory file, I expect fd is a "directory file descriptor". Whole my suggestions are related to the question: And my answer is: Secondly, syscall package seems to support my point of view. Anyway, I don't need to argue any more. Thank you Alex for clarifying my point. hiro |
Currently,
Fd()
returnsearch handle
if the file is a directory.But,
search handle
anddirectory handle
are not the same.https://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365258(v=vs.85).aspx
It's OK now, because
(*os.File).Chdir
,syscall.Fchdir
,syscall.Fchmod
are just stub.Once someone implements
syscall.Fchdir
, the problem is unveiled.https://gist.github.com/hirochachacha/bba426b5defff3d8f5fe
I think
Fd()
should returnuintptr(syscall.InvalidHandle)
, if failed to obtaindirectory handle
.The text was updated successfully, but these errors were encountered: