Replace std::os::glob with extra::glob, which is written in rust

This is #8201 with a bunch of amendments to address the comments (and re-based).