From 47d23fd6f8016d728045b18d66abfb0a8bd3a1ba Mon Sep 17 00:00:00 2001 From: John Behm <113515064+john-behm-bertelsmann@users.noreply.github.com> Date: Fri, 19 Sep 2025 16:40:26 +0200 Subject: [PATCH] feat: make prefix path helper function public. --- prefixfs.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/prefixfs.go b/prefixfs.go index 326cedb..1c119ba 100644 --- a/prefixfs.go +++ b/prefixfs.go @@ -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 +}