pkger/pkging/pkger.go

47 lines
2.7 KiB
Go
Raw Normal View History

2019-09-02 01:02:45 +03:00
package pkging
2019-09-01 00:00:24 +03:00
import (
"os"
"path/filepath"
"github.com/markbates/pkger/here"
)
2019-09-03 18:29:28 +03:00
type Pkger interface {
2019-10-16 18:07:57 +03:00
// Parse the string in here.Path format.
2019-10-09 20:21:54 +03:00
Parse(p string) (here.Path, error)
2019-10-16 18:07:57 +03:00
// Abs returns an absolute representation of path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result.
2019-09-21 19:51:29 +03:00
Abs(p string) (string, error)
2019-10-16 18:07:57 +03:00
// AbsPath returns an absolute representation of here.Path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. AbsPath calls Clean on the result.
2019-10-09 20:21:54 +03:00
AbsPath(here.Path) (string, error)
2019-09-01 23:18:39 +03:00
2019-10-16 18:07:57 +03:00
// Current returns the here.Info representing the current Pkger implementation.
2019-09-01 00:00:24 +03:00
Current() (here.Info, error)
2019-10-16 18:07:57 +03:00
// Info returns the here.Info of the here.Path
2019-09-01 00:00:24 +03:00
Info(p string) (here.Info, error)
2019-09-01 05:45:22 +03:00
// Create creates the named file with mode 0666 (before umask) - It's actually 0644, 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.
Create(name string) (File, error)
// MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
2019-09-01 00:00:24 +03:00
MkdirAll(p string, perm os.FileMode) error
2019-09-01 05:45:22 +03:00
// Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY.
2019-09-01 00:00:24 +03:00
Open(name string) (File, error)
2019-09-01 05:45:22 +03:00
// Stat returns a FileInfo describing the named file.
2019-09-01 00:00:24 +03:00
Stat(name string) (os.FileInfo, error)
2019-09-01 05:45:22 +03:00
// Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. - That is from the standard library. I know. Their grammar teachers can not be happy with them right now.
2019-09-01 00:00:24 +03:00
Walk(p string, wf filepath.WalkFunc) error
2019-09-01 05:45:22 +03:00
// Remove removes the named file or (empty) directory.
Remove(name string) error
// RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).
RemoveAll(path string) error
2019-09-01 00:00:24 +03:00
}