Documentation
¶
Index ¶
- Variables
- type File
- type Path
- func (p *Path) Chmod(mode os.FileMode) error
- func (p *Path) Chtimes(atime time.Time, mtime time.Time) error
- func (p *Path) Create() (afero.File, error)
- func (p *Path) DirExists() (bool, error)
- func (p *Path) Equals(other *Path) (bool, error)
- func (p *Path) Exists() (bool, error)
- func (p *Path) FileContainsAnyBytes(subslices [][]byte) (bool, error)
- func (p *Path) FileContainsBytes(subslice []byte) (bool, error)
- func (p *Path) Fs() afero.Fs
- func (p *Path) GetLatest() (*Path, error)
- func (p *Path) Glob(pattern string) ([]*Path, error)
- func (p *Path) IsAbsolute() bool
- func (p *Path) IsDir() (bool, error)
- func (p *Path) IsEmpty() (bool, error)
- func (p *Path) IsFile() (bool, error)
- func (p *Path) IsSymlink() (bool, error)
- func (p *Path) Join(elems ...string) *Path
- func (p *Path) JoinPath(path *Path) *Path
- func (p *Path) Mkdir(perm os.FileMode) error
- func (p *Path) MkdirAll(perm os.FileMode) error
- func (p *Path) Mtime() (time.Time, error)
- func (p *Path) Name() string
- func (p *Path) Open() (*File, error)
- func (p *Path) OpenFile(flag int, perm os.FileMode) (*File, error)
- func (p *Path) Parent() *Path
- func (p *Path) Parts() []string
- func (p *Path) Path() string
- func (p *Path) ReadDir() ([]*Path, error)
- func (p *Path) ReadFile() ([]byte, error)
- func (p *Path) RelativeTo(other *Path) (*Path, error)
- func (p *Path) Remove() error
- func (p *Path) RemoveAll() error
- func (p *Path) Rename(newname string) error
- func (p *Path) RenamePath(target *Path) error
- func (p *Path) Resolve() (*Path, error)
- func (p *Path) ResolveAll() (*Path, error)
- func (p *Path) SafeWriteReader(r io.Reader) error
- func (p *Path) Stat() (os.FileInfo, error)
- func (p *Path) String() string
- func (p *Path) Symlink(target *Path) error
- func (p *Path) Walk(walkFn filepath.WalkFunc) error
- func (p *Path) WriteFile(data []byte, perm os.FileMode) error
- func (p *Path) WriteReader(r io.Reader) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrDoesNotImplement = errors.Errorf("doesn't implement required interface")
)
Functions ¶
This section is empty.
Types ¶
type File ¶ added in v0.3.0
File represents a file in the filesystem. It inherits the afero.File interface but might also include additional functionality.
type Path ¶
type Path struct {
// DefaultFileMode is the mode that is used when creating new files in functions
// that do not accept os.FileMode as a parameter.
DefaultFileMode os.FileMode
// Sep is the seperator used in path calculations. By default this is set to
// os.PathSeparator.
Sep string
// contains filtered or unexported fields
}
Path is an object that represents a path
func Glob ¶
Glob returns all of the path objects matched by the given pattern inside of the afero filesystem.
func NewPathAfero ¶
NewPathAfero returns a Path object with the given Afero object
func (*Path) Create ¶ added in v0.2.0
Create creates a file if possible, returning the file and an error, if any happens.
func (*Path) DirExists ¶ added in v0.2.0
DirExists returns whether or not the path represents a directory that exists
func (*Path) Equals ¶
Equals returns whether or not the path pointed to by other has the same resolved filepath as self.
func (*Path) FileContainsAnyBytes ¶ added in v0.2.0
FileContainsAnyBytes returns whether or not the path contains any of the listed bytes.
func (*Path) FileContainsBytes ¶ added in v0.2.0
FileContainsBytes returns whether or not the given file contains the bytes
func (*Path) GetLatest ¶
GetLatest returns the file or directory that has the most recent mtime. Only works if this path is a directory and it exists. If the directory is empty, the returned Path object will be nil.
func (*Path) IsAbsolute ¶
IsAbsolute returns whether or not the path is an absolute path. This is determined by checking if the path starts with a slash.
func (*Path) IsSymlink ¶
IsSymlink returns true if the given path is a symlink. Fails if the filesystem doesn't implement afero.Lstater.
func (*Path) Join ¶
Join joins the current object's path with the given elements and returns the resulting Path object.
func (*Path) JoinPath ¶ added in v0.4.0
JoinPath is the same as Join() except it accepts a path object
func (*Path) Open ¶ added in v0.2.0
Open opens a file for read-only, returning it or an error, if any happens.
func (*Path) OpenFile ¶ added in v0.2.0
OpenFile opens a file using the given flags and the given mode. See the list of flags at: https://golang.org/pkg/os/#pkg-constants
func (*Path) ReadDir ¶
ReadDir reads the current path and returns a list of the corresponding Path objects.
func (*Path) ReadFile ¶
ReadFile reads the given path and returns the data. If the file doesn't exist or is a directory, an error is returned.
func (*Path) RelativeTo ¶
RelativeTo computes a relative version of path to the other path. For instance, if the object is /path/to/foo.txt and you provide /path/ as the argment, the returned Path object will represent to/foo.txt.
func (*Path) RenamePath ¶
RenamePath is the same as Rename except the argument is a Path object. The attributes of the path object is retained and does not inherit anything from target.
func (*Path) Resolve ¶
Resolve resolves the path to the location pointed to by the symlink, if any. Note that if your path is serviced by multiple symlinks, the result of Resolve() may not point to any real path. This will fail if the underlying afero filesystem does not implement afero.LinkReader.
func (*Path) ResolveAll ¶ added in v0.4.0
ResolveAll canonicalizes the path by following every symlink in every component of the given path recursively. The behavior should be identical to the `readlink -f` command from POSIX OSs. This will fail if the underlying afero filesystem does not implement afero.LinkReader. The path will be returned unchanged on errors. This function is not thread-safe.
func (*Path) SafeWriteReader ¶ added in v0.2.0
SafeWriteReader is the same as WriteReader but checks to see if file/directory already exists.
func (*Path) Symlink ¶
Symlink symlinks to the target location. This will fail if the underlying afero filesystem does not implement afero.Linker.
func (*Path) Walk ¶ added in v0.2.0
Walk walks path, using the given filepath.WalkFunc to handle each