canonicalize method

String canonicalize (
  1. String path
)

Canonicalizes path.

This is guaranteed to return the same path for two different input paths if and only if both input paths point to the same location. Unlike normalize, it returns absolute paths when possible and canonicalizes ASCII case on Windows.

Note that this does not resolve symlinks.

If you want a map that uses path keys, it's probably more efficient to pass equals and hash to new HashMap than it is to canonicalize every key.

Implementation

String canonicalize(String path) {
  path = absolute(path);
  if (style != Style.windows && !_needsNormalization(path)) return path;

  var parsed = _parse(path);
  parsed.normalize(canonicalize: true);
  return parsed.toString();
}