Documentation
¶
Overview ¶
Package pathutil provides cross-platform path utilities. All paths returned by this package use forward slashes, matching the normalized format stored in snapshots and indexes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize ensures a path uses forward slashes and is cleaned of . and .. components, matching the internal storage format. Use this for user-provided paths before comparing with stored paths.
On Unix, filepath.ToSlash only converts the OS separator (/) and leaves backslashes intact. Since drift stores paths with forward slashes on all platforms, we explicitly replace backslashes first so Windows-style paths are normalized correctly on every OS.
func Rel ¶
Rel returns a normalized relative path (with / separators) from basepath to targpath. It combines filepath.Rel with filepath.ToSlash to ensure cross-platform consistency.
func RelToWorkDir ¶
RelToWorkDir converts a user-provided path to a normalized relative path from workDir. If the path is absolute, it is made relative to workDir. If relative, it is normalized. Returns an error if the resulting path would escape workDir (contains ".."). This is the standard entry point for user-facing file paths in CLI commands.
Types ¶
This section is empty.