-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Issue by pornel
Friday Jan 23, 2015 at 22:38 GMT
For earlier discussion, see rust-lang/rust#21569
This issue was labelled with: A-io, A-libs, A-mac-osx in the Rust repository
In OS X you're not supposed to display POSIX paths to users. User-facing file names are supposed to use "display name" ([NSFilemanager displayNameAtPath:] and friends).
Rust's path.display() and Display guidelines sound like they're exactly for this purpose, but unfortunately path.display() falls short on OS X and probably can't be fixed without breaking at least some Cargo build scripts.
However, in OS X "display path" is seriously only for display and it's a one-way function:
[fm displayNameAtPath:@"/Applications"] == @"アプリケーション"; // If Japanese locale is set
[fm displayNameAtPath:@"foo:bar"] == @"foo/bar"; // Yes, Finder allows slashes in file namesI'd be lovely if Rust had built-in support for this and encouraged doing the right thing on OS X and other OSes that have localized paths.
Suggestions:
- Add
path.filename_localized()andpath.components_localized() - Drop
path.filename_display() - Rename
path.display()topath.to_string_lossy(), to make it clear that a code likeprintln!("cargo:root={}", path.display());is slightly buggy. - Add
format_bytes!()to make it easier to correctly format commandline arguments with paths.