pkger/dir.go

37 lines
523 B
Go
Raw Normal View History

2019-08-09 04:51:58 +03:00
package pkger
import (
"os"
"path/filepath"
)
2019-08-09 05:35:01 +03:00
func MkdirAll(p string, perm os.FileMode) error {
path, err := Parse(p)
2019-08-09 04:51:58 +03:00
if err != nil {
return err
}
root := path.Name
for root != "" && root != "/" {
pt := Path{
Pkg: path.Pkg,
Name: root,
}
2019-08-09 05:35:01 +03:00
f, err := Create(pt.String())
2019-08-09 04:51:58 +03:00
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
}
2019-08-09 05:35:01 +03:00
filesCache.Store(pt, f)
2019-08-09 04:51:58 +03:00
root = filepath.Dir(root)
}
return nil
}