Path.resolve
Path resolve(bool strict = false) constResolves this path similarly to Python's Path.resolve(strict=False):
- Returns an absolute path with symlinks expanded where possible.
- Detects symlink loops and throws an exception.
- When
strictistrue, throws if any path component does not exist or a
symlink cannot be read (e.g., broken link).
- When
strictisfalse, performs best-effort resolution: existing
components and readable symlinks are resolved; missing components are appended without error.
Platform notes:
- POSIX: Fully resolves symlinks using
lstat/readlinkbehavior. - Windows: Currently does not dereference symlinks; returns
absolutePath result. Loop detection and strict semantics are not guaranteed on Windows yet.
Performance:
- Known limitation: Symlink chain resolution has O(n²) complexity in
pathological cases where symlinks point to paths containing additional symlinks. This is due to the worklist being rebuilt from scratch when a symlink is encountered. For typical filesystem structures with limited symlink depth (bounded by LINK_LIMIT = 64), this is acceptable. A true O(n) fix would require significant restructuring.
Parameters
strict | When true, fail on missing components and unreadable symlinks. |
Returns
A new Path representing the resolved path.
Path resolve() constConvenience overload: resolve() is equivalent to resolve(false)