Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions prefixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,17 @@ func reconstructVolume(absOldPath, prefix string) string {
return filepath.Clean(parts[0] + ":" + separator + parts[1])
}
}

// PrefixPath joins two paths together, making sure the resulting path is absolute
// and normalized (volume names are converted to root relative paths).
// On Windows the volume name is preserved, but the colon is removed.
func PrefixPath(prefix, name string) (string, error) {
name = filepath.FromSlash(name)
absolute, err := filepath.Abs(filepath.FromSlash(name))
if err != nil {
return "", fmt.Errorf("failed to make path absolute %s: %w", name, err)
}
absolute = normalizeVolumePath(absolute)
absolute = filepath.Join(prefix, absolute)
return absolute, nil
}
Loading