I am coming from Python. It has a very convenient method in its standard library pathlib
to search for a file by pattern for a given Path
. e.g.,
>>> from pathlib import Path
>>> p = Path("C:\ProgramData")
>>> list(p.glob("**/mpc*.exe"))
[WindowsPath('C:/ProgramData/Microsoft/Windows Defender/Platform/4.18.2110.6-0/MpCmdRun.exe'), WindowsPath('C:/ProgramData/Microsoft/Windows Defender/Platform/4.18.2110.6-0/MpCopyAccelerator.exe'), WindowsPath('C:/ProgramData/Microsoft/Windows Defender/Platform/4.18.2110.6-0/X86/MpCmdRun.exe'), WindowsPath('C:/ProgramData/Microsoft/Windows Defender/Platform/4.18.2111.5-0/MpCmdRun.exe'), WindowsPath('C:/ProgramData/Microsoft/Windows Defender/Platform/4.18.2111.5-0/MpCopyAccelerator.exe'), WindowsPath('C:/ProgramData/Microsoft/Windows Defender/Platform/4.18.2111.5-0/X86/MpCmdRun.exe')]
>>>
In rust, I have (writing from memory)
let p = PathBuf::from("C:\ProgramData");
/// p.glob("**/mpc*.exe") // some magical crate?
There is crate glob
(glob - Rust) which I can use if nothing exists that work directly on PathBuf
. glob::glob
takes &str
as argument.