Fix Dir.glob when readdir doesn't report file type#9877
Fix Dir.glob when readdir doesn't report file type#9877straight-shoota merged 1 commit intocrystal-lang:masterfrom
Conversation
bcardiff
left a comment
There was a problem hiding this comment.
It works as a charm! 🎉
Thanks! ⚡
It usually itches me to use Bool?, because there are two falsey values in that type.
|
I would use an |
|
This is just an internal ivar for optimizing Dir. glob, not anything near a public API. I'd prefer to keep it that simple. At least for now. We can revisit when considering to use more info from readdir for other purposes. |
In my mind, an enum is simpler than |
|
Alternatively, |
|
Since the entry type is internal i'm fine with the current state. But having an enum with all the values of https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html, or at least the one we use today sounds like a path that can evolve smoothly. All unmapped d_type can default to the enum equivalent to unknown. That way there is no need to do the full mapping today if not wanted. I would not assign directly the d_type value to abstraction leak. |
|
Given the discussion after the approval, should this PR expect more work or is good to go since the discussion is about non public design? |
asterite
left a comment
There was a problem hiding this comment.
Looks good to me, the internal implementation details can be changed later on 👍
Dir.next_entrywas missing a validation ford_typevalue. In case it isDT_UNKNOWN, we can't determine wether it's a directory or not.Entry#diris an internal API currently only used byDir.globso changing its type toBool | Nilto signal unknown is fine.Fixes #9876