2020//! verbatim prefix `\\?\` that `canonicalize` gives, and turns `\\?\UNC\` into `\\`, unless only
2121//! the verbatim path names the object, as for a name that ends in a period or a space.
2222//! - [`is_named`] compares a file name with the name that the CLI expects, as the host's file
23- //! systems compare names: in any ASCII case on Windows, whose file names ignore case, and
24- //! exactly elsewhere.
23+ //! systems compare names: on Windows, whose file names ignore case, in any case, of letters
24+ //! beyond ASCII too, and exactly elsewhere.
2525//!
2626//! Host paths that are not valid Unicode are refused, as [`text`] refuses them, since the CLI
2727//! records them as JSON strings and messages name them.
@@ -32,6 +32,9 @@ use std::ffi::OsString;
3232use std:: io;
3333use std:: path:: { Component , MAIN_SEPARATOR_STR , Path , PathBuf , Prefix } ;
3434
35+ #[ cfg( all( feature = "cli" , windows) ) ]
36+ use crate :: host:: platform;
37+
3538/// Returns the error for an operating-system string, which messages call `what`, that is not
3639/// valid Unicode.
3740fn not_unicode ( what : & str ) -> io:: Error {
@@ -217,12 +220,16 @@ fn without_verbatim_prefix(path: PathBuf) -> PathBuf {
217220}
218221
219222/// Returns whether the file name `name` is `expected`, as the host's file systems compare names:
220- /// in any ASCII case on Windows, whose file names ignore case, and exactly elsewhere.
223+ /// on Windows, whose file names ignore case, in any case, of letters beyond ASCII too, through
224+ /// the operating system's uppercase table, and exactly elsewhere.
221225#[ cfg( feature = "cli" ) ]
222226pub ( crate ) fn is_named ( name : & OsStr , expected : & str ) -> bool {
223- if cfg ! ( windows) {
224- name. eq_ignore_ascii_case ( expected)
225- } else {
227+ #[ cfg( windows) ]
228+ {
229+ platform:: is_same_file_name ( name, expected)
230+ }
231+ #[ cfg( not( windows) ) ]
232+ {
226233 name == expected
227234 }
228235}
0 commit comments