I’m working on a piece of code that checks if stdin
represents a directory and, if it does, performs some operations on it
Currently, I have code that works on Unix systems:
let fd = stdin().as_fd().try_clone_to_owned().unwrap();
let file = File::from(fd);
let meta = file.metadata().unwrap();
if meta.is_dir() {
let mut stdin_path = fs::canonicalize("/dev/stdin").unwrap();
println!({:?}", stdin_path);
// do something
}
I’m trying to ensure it works on Windows as well. Since Windows doesn’t have std::os::fd::AsFd
, as_fd
methods, plus there’s no /dev/stdin
, I’m not sure about the appropriate APIs to use to achieve the same functionality on Windows. Any guidance to make it work on Windows?