Add a Note to README When use posix path on Windows
System details
- OS/Platform name and version: Windows 10
- Rust version (if building from source):
rustc --version:rustc 1.54.0 (a178d0322 2021-07-26) - Notify version (or commit hash if building from git): 5.0.0-pre.13 and 4. 0.17
- If you're coming from a project that makes use of Notify, what it is, and a link to the downstream issue if there is one:
- Filesystem type and options:
- On Linux: Kernel version:
- On Windows: version and if you're running under Windows, Cygwin (unsupported), Linux Subsystem:
- If you're running as a privileged user (root, System):
- If you're running in a container, details on the runtime and overlay:
- If you're running in a VM, details on the hypervisor:
What you did (as detailed as you can)
When i use notify watch directory on Windows, the path is posix style like "G:/Feature/"
Return Event 's path will like "G:/Feature/\\22.mp4"
this is what i test on 5.0.0-pre.13
use std::path::Path;
let (tx, rx) = std::sync::mpsc::channel();
// Automatically select the best implementation for your platform.
// You can also access each implementation directly e.g. INotifyWatcher.
let mut watcher = RecommendedWatcher::new(tx).unwrap();
// let mut watcher = recommended_watcher(|res| {
// match res {
// Ok(event) => println!("event: {:?}", event),
// Err(e) => println!("watch error: {:?}", e),
// }
// }).unwrap();
watcher.watch(Path::new("G:/Feature film/"), RecursiveMode::Recursive).unwrap();
for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
}
a remove event will print
changed: Event { kind: Remove(Any), paths: ["G:/Feature/\\22.mp4"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
because posix path also work with notify on Windows,but OsString::from_wide(encoded_path) will return windows style path like Feature\\22.mp4
4.0.17 is same .
So Should add a Note to README When use posix path on Windows.
What you expected
What happened
I'm not entirely sure what you want to have on the readme. But I think I've seen a similar issue with windows when using posix-path libs on windows recently.
@0xpr03 if don't have note on readme , new beginner will fill this trap again
I think it's more of a behavior issue rather than a document's one, we could (even should?) normalize a path. By the way, such documentation should go to a doc comment, not README IMO.
@JohnTitor I'd leave that to you if you already know how you want to proceed.
So, the current behavior works correctly if a user specifies a Windows-like path (e.g. G:\Feature\ -> G:\Feature\22.mp4), right? Then, what we could do is to check if a user specifies a posix-like path then normalize a joined path to a posix-like one (another option would be normalizing a user specified path to a Windows-like and it's easier, but it'd be confusing IMO).
I'm, however, afraid that I cannot take a closer look at that in the near future (I'm inactive on FLOSS these days), so I can only put down my thoughts here for now.
+1