2019-09-03 18:29:28 +03:00
|
|
|
package mem
|
2019-09-01 00:00:24 +03:00
|
|
|
|
|
|
|
import (
|
2019-09-02 05:25:53 +03:00
|
|
|
"path/filepath"
|
2019-09-01 00:00:24 +03:00
|
|
|
"time"
|
|
|
|
|
2019-09-02 01:02:45 +03:00
|
|
|
"github.com/markbates/pkger/pkging"
|
2019-09-01 00:00:24 +03:00
|
|
|
)
|
|
|
|
|
2019-09-02 05:25:53 +03:00
|
|
|
// no such file or directory
|
2019-09-03 18:29:28 +03:00
|
|
|
func (fx *Pkger) Create(name string) (pkging.File, error) {
|
2019-09-01 00:00:24 +03:00
|
|
|
pt, err := fx.Parse(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
her, err := fx.Info(pt.Pkg)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-09-02 05:25:53 +03:00
|
|
|
|
|
|
|
if _, err := fx.Stat(filepath.Dir(pt.Name)); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-09-02 19:55:26 +03:00
|
|
|
|
2019-09-01 00:00:24 +03:00
|
|
|
f := &File{
|
|
|
|
path: pt,
|
|
|
|
her: her,
|
2019-09-02 01:02:45 +03:00
|
|
|
info: &pkging.FileInfo{
|
|
|
|
Details: pkging.Details{
|
2019-09-01 00:00:24 +03:00
|
|
|
Name: pt.Name,
|
2019-09-01 05:45:22 +03:00
|
|
|
Mode: 0644,
|
2019-09-02 01:02:45 +03:00
|
|
|
ModTime: pkging.ModTime(time.Now()),
|
2019-09-01 00:00:24 +03:00
|
|
|
},
|
|
|
|
},
|
2019-09-02 01:02:45 +03:00
|
|
|
pkging: fx,
|
2019-09-01 00:00:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fx.files.Store(pt, f)
|
|
|
|
|
|
|
|
return f, nil
|
|
|
|
}
|