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

Dir.entries() returns both "." and ".." in its results #4807

Closed
docelic opened this issue Aug 7, 2017 · 2 comments
Closed

Dir.entries() returns both "." and ".." in its results #4807

docelic opened this issue Aug 7, 2017 · 2 comments

Comments

@docelic
Copy link
Contributor

docelic commented Aug 7, 2017

Calling Dir.entries() returns both "." and ".." in the result set, and there is no sort order defined.

This essentially makes one have to call:

result= Dir.entries( "/some/dir")
result.delete "."
result.delete ".."

Before the results become usable.

Is this intended behavior and/or there's room for improvement?

@makenowjust
Copy link
Contributor

Dir.entries uses C's readdir function internally, and readdir yields both "." and ".." also, so Dir.entries result contains them. In addition, this behavior is same as Ruby's 'Dir.entries'. I think this is intended behavior.

@straight-shoota
Copy link
Member

Ruby has also Dir.children for exactly this purpose. It would make sense to have this in Crystal too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants