Skip to content

Path canonicalization enhancements #12924

@Colengms

Description

@Colengms

The C/C++ extension 'canonicalizes' paths, in order to compare them for equality, use them in maps, hashes, etc..

Currently: On Windows, canonicalization avoids disk access, and (therefore) does not resolve symbolic links (which are uncommon on Windows) and does not require that the target currently exists on disk. On Linux and Mac, canonicalization leverages realpath, which hits to disk, resolves symbolic links and requires that the target exists.

The differences in behaviors of the same canonicalization API on different platforms is problematic. This issue tracks making this behavior consistent across platforms and more robust.

Proposed/example API:

  • canonicalize_full_path - does not hit to disk, resolve symbolic links, or require that the file exists. (Leaving the Windows behavior unchanged, there is one exception: If the path is relative, it's considered to be in the current working directory. This use should be avoided, as relying on the current working directory is discouraged for multiple reasons).
  • canonicalize_relative_path - applies canonicalization to a relative path.
  • canonicalize_path_leaf - applies canonicalization to a single leaf (file or directory. No "." or ".." expected, just upper-casing on Windows).
  • get_resolved_full_path - Resolves symbolic links (if any), returning a canonicalized path.

This will require being more explicit about where symbolic links should be resolved, which should help us address open issues related to symbolic links.

Metadata

Metadata

Assignees

Labels

Language ServiceinternalUsed to opt-out an issue from having GitHub actions applied to it

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions