normpath 1.5.0

More reliable path manipulation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::ffi::OsString;
use std::path::Path;

#[cfg(any(target_os = "ios", target_os = "macos"))]
mod macos;

#[cfg_attr(
    not(any(target_os = "ios", target_os = "macos")),
    expect(unused_variables)
)]
pub(crate) fn name(path: &Path) -> Option<OsString> {
    // Only UTF-8 paths can be localized on MacOS.
    #[cfg(any(target_os = "ios", target_os = "macos"))]
    if let Some(path) = path.to_str() {
        return Some(macos::name(path).into());
    }
    None
}