From 20b0b95e33485d2c057fe11dfa34b765995fda8f Mon Sep 17 00:00:00 2001 From: Novan Allanadi <25704935+nofun97@users.noreply.github.com> Date: Mon, 11 Nov 2019 15:31:23 +1100 Subject: [PATCH] normalizePath now always return absolute path, BasePathFs removes volume name from path --- basepath.go | 4 +++- composite_test.go | 2 +- memmap.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/basepath.go b/basepath.go index 3a14b833..013b1a7a 100644 --- a/basepath.go +++ b/basepath.go @@ -30,7 +30,9 @@ type BasePathFile struct { func (f *BasePathFile) Name() string { sourcename := f.File.Name() - return strings.TrimPrefix(sourcename, filepath.Clean(f.path)) + sourcename = strings.TrimPrefix(sourcename, filepath.VolumeName(sourcename)) + sourcename = strings.TrimPrefix(sourcename, filepath.Clean(f.path)) + return sourcename } func NewBasePathFs(source Fs, path string) Fs { diff --git a/composite_test.go b/composite_test.go index 9cfbed92..79c67afe 100644 --- a/composite_test.go +++ b/composite_test.go @@ -479,7 +479,7 @@ func TestUnionFileReaddirAskForTooMany(t *testing.T) { const testFiles = 5 for i := 0; i < testFiles; i++ { - WriteFile(base, fmt.Sprintf("file%d.txt", i), []byte("afero"), 0777) + WriteFile(base, fmt.Sprintf("/file%d.txt", i), []byte("afero"), 0777) } ufs := &CopyOnWriteFs{base: base, layer: overlay} diff --git a/memmap.go b/memmap.go index b3a31a06..01161840 100644 --- a/memmap.go +++ b/memmap.go @@ -197,7 +197,7 @@ func normalizePath(path string) (string, error) { case FilePathSeparator: return rootAbs, nil default: - return path, nil + return filepath.Abs(path) } }