1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Shared helpers for comparing filesystem paths across platforms.
use ;
/// Strip Windows's `\\?\` verbatim-path prefix before prefix/equality comparisons.
/// `Path::canonicalize()` adds it on Windows (e.g. `composer::find_composer_root_for_path`
/// canonicalizes the CLI's target path), while paths resolved from `<ignoreFiles>`/
/// `<projectFiles>` config entries never go through `canonicalize()` — leaving two paths
/// that denote the same directory but compare unequal component-for-component
/// (`Prefix(VerbatimDisk)` vs `Prefix(Disk)`), so `starts_with`/`==` never match. No-op on
/// non-Windows platforms, where `canonicalize()` never rewrites the path this way.
pub
pub
/// Best-effort `canonicalize()` (falling back to `p` unchanged if the path doesn't exist
/// yet or the call errors) followed by [`strip_verbatim_prefix`]. Two paths that denote the
/// same directory can still disagree byte-for-byte before this — one may have gone through
/// `canonicalize()` upstream (e.g. `composer::find_composer_root_for_path`) and picked up a
/// resolved symlink, 8.3-short-name expansion, or on-disk casing that the other path (built
/// by plain `PathBuf::join` from a config-relative entry) never went through. Applying the
/// same normalization to both sides before `starts_with`/`==` is the only way to make them
/// comparable.
pub