3 ms·
> It should be possible do it all in native Rust code as far as I am concerned. Yeah, it would be, but Rust's standard library doesn't provide any way to invok
by burntsushi 7y ago
> It should be possible do it all in native Rust code as far as I am concerned.
Yeah, it would be, but Rust's standard library doesn't provide any way to invoke syscalls. You either need to go through libc's syscall wrapper, or write Assembly. I used the former to get access to faster directory traversal: https://github.com/BurntSushi/walkdir/blob/ec33af7f9b25afefc3f37764b93fff132c3d54a6/src/os/linux/mod.rs#L41-L62 https://github.com/BurntSushi/walkdir/blob/ec33af7f9b25afefc... (The rest of that code in that module may be interesting to you, since the API for getdents is pretty interesting and very C-like. Buttoning it up behind a safe API that can never be misused took a bit of thinking.)
Besides, Rust's standard library, on Linux at least, currently requires libc anyway. So you're already going to be linking to it.