-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Add get_contents method to Directory class #40547
Conversation
+1 for |
Would you be considering adding |
I started implementing it, but the code feels like it would be simpler in GDScript. The additional complexity is not worth it IMO. |
There might be a redesign for 4.0 which may affect whether or not this is merged. As for recursion, how would that even work? Are directories included in the list or only the files within them? |
Recursive option is probably not worth it because you'll likely also want to add some filtering on top of that, which is better done via script then... given the development philosophy of Lean & Clean™. 🙂 |
PR meeting: the bool args should be properties (this should be refactored in core binds for all directory stuff), and it should likely be added as seperate methods to list files/directory |
7c4791e
to
dd67119
Compare
Rebased and done requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #55776 - the listing is not deterministic, but it could be sort
ed here in get_contents()
. And you could add a mention about list_dir_begin
not guaranteeing order in the docs to close that issue.
dd67119
to
2a2ccf3
Compare
2a2ccf3
to
d04c2a5
Compare
Thanks! |
Closes godotengine/godot-proposals#1225
Resolves #55776
Thing to consider:
list_dir_begin()
and related methods unnecessary, as they are less convenientTheoretically
list_dir_begin()
is more optimal to use when you want to cancel iteration midway, but this happens very rarely and the difference is minimal.