mirror of https://github.com/markbates/pkger.git
56 lines
810 B
Go
56 lines
810 B
Go
package pkger
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
)
|
|
|
|
func MkdirAll(p string, perm os.FileMode) error {
|
|
path, err := Parse(p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
root := path.Name
|
|
|
|
cur, err := Stat()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for root != "" && root != "/" && root != "\\" {
|
|
pt := Path{
|
|
Pkg: path.Pkg,
|
|
Name: root,
|
|
}
|
|
if _, ok := filesCache.Load(pt); ok {
|
|
root = filepath.Dir(root)
|
|
continue
|
|
}
|
|
f := &File{
|
|
path: pt,
|
|
her: cur,
|
|
info: &FileInfo{
|
|
name: pt.Name,
|
|
mode: 0666,
|
|
modTime: time.Now(),
|
|
virtual: true,
|
|
},
|
|
}
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
f.info.isDir = true
|
|
f.info.mode = perm
|
|
f.info.virtual = true
|
|
if err := f.Close(); err != nil {
|
|
return err
|
|
}
|
|
filesCache.Store(pt, f)
|
|
root = filepath.Dir(root)
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|