Clarification on the codes of the errors thrown by listDirectory?
Gershom B
gershomb at gmail.com
Sun Mar 11 03:46:36 UTC 2018
The mappings of windows to c errors are enumerated in theĀ errtable in the cbits of base like so:
https://hackage.haskell.org/package/base-4.10.1.0/src/cbits/Win32Utils.c
It is invoked from maperrno_func in the same file, which sends all other errors to EACCES, ENOEXEC or EINVAL.
Since it never sends anything to ENOTDIR, it seems clear that from the windows side, we will never get an `InappropriateType` error. Meanwhile, on the posix side, we of course may: http://hackage.haskell.org/package/base-4.10.1.0/docs/src/Foreign.C.Error.html#errnoToIOError
I think a PR to the docs that clarified which codes are not returned on windows, and what would be returned instead would be welcomed.
Cheers,
G
On March 10, 2018 at 2:26:34 PM, sonne (kindaro at gmail.com) wrote:
Hello!
In `directory` package, there is a function
`System.Directory.listDirectory`. It says on the box that it throws
error messages that can be branched on. (`isDoesNotExistError`,
`InappropriateType` and so on.) I dug into it a little, and it appears
to me that, in actuality, on Windows (unlike on a Posix compliant
operating system) there is no reliable way to sort the errors in some
pre-defined categories like "no such file", "not a directory", et
cetera.
Therefore I must presume that either the documentation is incomplete
and misleading, or it is I who is somehow misled. The information I
have is summarized in a Stack Overflow question linked below. I would
like to receive a clarification. Perhaps an amendment to the
documentation should be considered?
The point that initially aroused my suspicion is that `NoSuchThing` is
associated with both `eNoEnt` and `eNotDir`. Is there a rationale
behind this? From the `man 3 opendir`, I do not see the need for this
ambiguity.
This is the S.O. question I mentioned: stackoverflow.com/q/49212400
There is also a linked question that elaborates on the motivation
behind my inquiry.
Thank you!
_______________________________________________
Libraries mailing list
Libraries at haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180310/00414cb7/attachment.html>
More information about the Libraries
mailing list