pkger/pkger.go

20 lines
578 B
Go
Raw Normal View History

2019-07-31 00:21:26 +03:00
package pkger
2019-07-31 23:29:49 +03:00
// Open opens the named file for reading.
func Open(p string) (*File, error) {
pt, err := Parse(p)
2019-07-31 00:21:26 +03:00
if err != nil {
2019-07-31 23:29:49 +03:00
return nil, err
2019-07-31 00:21:26 +03:00
}
2019-07-31 23:29:49 +03:00
return rootIndex.Open(pt)
2019-07-31 00:21:26 +03:00
}
2019-07-31 23:29:49 +03:00
// Create creates the named file with mode 0666 (before umask), truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.
func Create(p string) (*File, error) {
2019-07-31 00:21:26 +03:00
pt, err := Parse(p)
if err != nil {
return nil, err
}
2019-07-31 23:29:49 +03:00
return rootIndex.Create(pt)
2019-07-31 00:21:26 +03:00
}