-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Add DirEntry
-based readdir
methods
#55358
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
base: master
Are you sure you want to change the base?
Add DirEntry
-based readdir
methods
#55358
Conversation
Perhaps an alternative could be to implement this as |
So
That seems good, but as an additional method? I can see merit in both. |
This comment was marked as resolved.
This comment was marked as resolved.
Would that constructor involve a filesystem call? If so, Input type and output type are not necessarily coupled here: I might want the file names contained in a directiry pointed to by a DirEntry or I might want the DirEntries at a path which I only have a string representation of. Consequently, I do not like the proposed The API in this PR looked good to me as of e4d5be0. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@LilithHafner what do you think of the way I implemented it? Note the DirEntry constructor and docstring that specifies the unknown filetype when given a path. |
One option is to remove the for e1 in readdir(DirEntry, "some/dir")
isdir(e1) || continue
for e2 in readdir(e1)
... |
I think there should only be one way, not both I still prefer
|
Ok. I think that means you agree with #55358 (comment) ? |
readdir(DirEntry, path)
DirEntry
-based readdir
methods
Co-Authored-By: Ian Butterworth <i.r.butterworth@gmail.com> Co-Authored-By: Simeon David Schaub <simeon@schaub.rocks>
d61f7c1
to
88e2a62
Compare
I think this has reached a happy design? @LilithHafner would you mind a final review? |
I still like the PR as of e4d5be0 when it had the API that @oscardssmith approved. I don't like it as is for the reasons I stated in #55358 (comment). Open to reconsideration, but I don't think any of the points in that comment have been addressed. |
This currently allows for e1 in readdir(DirEntry, "some/dir")
isdir(e1) || continue
for e2 in readdir(e1)
... As of e4d5be0 it required extracting the path from the entry. for e1 in readdir(DirEntry, "some/dir")
isdir(e1) || continue
for e2 in readdir(DirEntry, e1.path)
... I see #55393 has been opened. (Note that this PR no longer has So this PR treats DirEntry as only machine generated, and introduces |
I opened #55393 to clarify the API I prefer because the "view reviewed chagnes" button on github seems to be reporting incorrect diffs in the presence of force pushes and plain git won't reveal that commit b.c. it's been force pushed over. |
The methods
are incomplete without
|
If we support it, I think I agree with @LilithHafner that it feels uncomfortable to constrain the abstraction/type to describe the input type to match the output type. It invites some awkward design questions:
Although it's more conservative now that Base doesn't provide the |
From chat with @IanButterworth: We should also think about some things before publicizing
|
Closes #55333
Renames and publicizes
Base.Filesystem._readdirx
asreaddir(DirEntry, path)
.Introducing the pattern of a type first arg allows further extension like
readdir(S3Entry, path::S3Path)
(wherereaddir(path::S3Path)::Vector{String}
already exists).