Skip to content

Localized file names and actual display names #845

@steveklabnik

Description

@steveklabnik

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 names

I'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() and path.components_localized()
  • Drop path.filename_display()
  • Rename path.display() to path.to_string_lossy(), to make it clear that a code like println!("cargo:root={}", path.display()); is slightly buggy.
  • Add format_bytes!() to make it easier to correctly format commandline arguments with paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions