mirror of https://github.com/spf13/afero.git
Use filepath.Abs to interpret relative file paths
This commit is contained in:
parent
f85f3b3779
commit
77f1ec73f1
10
memmap.go
10
memmap.go
|
@ -88,6 +88,7 @@ func (MemMapFs) Name() string { return "MemMapFS" }
|
||||||
|
|
||||||
func (m *MemMapFs) Create(name string) (File, error) {
|
func (m *MemMapFs) Create(name string) (File, error) {
|
||||||
m.lock()
|
m.lock()
|
||||||
|
name, _ = filepath.Abs(name)
|
||||||
file := MemFileCreate(name)
|
file := MemFileCreate(name)
|
||||||
m.getData()[name] = file
|
m.getData()[name] = file
|
||||||
m.registerWithParent(file)
|
m.registerWithParent(file)
|
||||||
|
@ -141,15 +142,6 @@ func (m *MemMapFs) registerWithParent(f File) {
|
||||||
}
|
}
|
||||||
pmem := parent.(*InMemoryFile)
|
pmem := parent.(*InMemoryFile)
|
||||||
|
|
||||||
// TODO(mbertschler): memDir is only nil when it was not made with Mkdir
|
|
||||||
// or lockfreeMkdir. In this case the parent is also not a real directory.
|
|
||||||
// This currently only happens for the file ".".
|
|
||||||
// This is a quick hack to make the library usable with relative paths.
|
|
||||||
if pmem.memDir == nil {
|
|
||||||
pmem.dir = true
|
|
||||||
pmem.memDir = &MemDirMap{}
|
|
||||||
}
|
|
||||||
|
|
||||||
pmem.memDir.Add(f)
|
pmem.memDir.Add(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue