-
Notifications
You must be signed in to change notification settings - Fork 12.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
glob.h bindings #5832
glob.h bindings #5832
Conversation
I'm not sure if this should be in the standard library, but instead in a third party crate. What does everyone else think? |
@erickt I don't know about systems languages, but globbing facilities are certainly present in the standard libraries of scripting languages. I'm ever-so-slightly concerned that, in the absence of this, people will resort to shelling-out to |
I think it's fine to adopt something like this. I'm uncomfortable about this as-presented for the following reasons:
|
|
Ok. Can you move the code to the |
Updated. I'll file a bug for the todo items once it gets merged. |
sadly now this needs a rebase :( |
only tested on linux/x86_64, but i got the values for other platforms from their system header files. no bindings for win32, because win32 doesn't include glob.h. also, glob() takes a callback for error handling, but i'm just making this a *c_void for now, since i don't know how to represent c calling back into rust (if that's even currently possible).
this could probably use expansion - it just uses all of the default options, which is usually what we want, but not always. maybe add a separate function that takes more options?
Okay, this is updated. I'm seeing a failure in the test suite in src/test/run-pass/too-much-recursion.rs: "rust: task 7f00c02041b0 ran out of stack", but I don't think it's related to my changes. |
Oops, forgot to add |
…earth Update Usage section of README.md Fixes rust-lang#5826 changelog: none
This adds low level bindings for
glob()
andglobfree()
inlibc
, and adds a staticglob()
function toPath
which uses those. It has only been tested on Linux/x86_64, but I looked up header file definitions for other platforms, so they should hopefully work in theory. Windows doesn't have these functions, so that is currently unimplemented, although ideallyPath::glob()
could be reimplemented in terms of Windows primitives instead, at some point in the future.I'm not sure what a good way to test this would be - it requires looking at the actual filesystem, so I'm not sure where a safe place to do that would be. I'd be willing to add some if people have recommendations.