From 952281b34e78b3b62c0132d414fcef63b5fed31e Mon Sep 17 00:00:00 2001 From: Novan Allanadi 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 616ff8f..584320a 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 3682c3c..96f45ef 100644 --- a/composite_test.go +++ b/composite_test.go @@ -479,7 +479,7 @@ func TestUnionFileReaddirAskForTooMany(t *testing.T) { overlay := &MemMapFs{} for i := 0; i < 5; 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 b2dca4f..164ca5a 100644 --- a/memmap.go +++ b/memmap.go @@ -191,7 +191,7 @@ func normalizePath(path string) (string, error) { case FilePathSeparator: return rootAbs, nil default: - return path, nil + return filepath.Abs(path) } }