aferox

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2021 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aferox

type Aferox struct {
	*afero.Afero

	// Fs is the working directory aware filesystem.
	Fs *Fsx
}

Aferox adjusts all relative paths based on the stored working directory, instead of relying on the default behavior for relative paths defined by the implementing Fs.

func NewAferox

func NewAferox(dir string, fs afero.Fs) Aferox

NewAferox creates a wrapper around a filesystem representation with an independent working directory.

func (Aferox) Abs

func (a Aferox) Abs(path string) string

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. Use in place of filepath.Abs.

func (Aferox) Chdir

func (a Aferox) Chdir(dir string)

Chdir changes the current working directory to the named directory. Use in place of os.Chdir.

func (Aferox) Chown added in v0.3.0

func (a Aferox) Chown(name string, uid int, gid int) error

func (Aferox) Getwd

func (a Aferox) Getwd() string

Getwd returns a rooted path name corresponding to the current directory. Use in place of os.Getwd.

func (Aferox) LookPath

func (a Aferox) LookPath(cmd string, path string, pathExt string) (string, bool)

This is a simplified exec.LookPath that checks if command is accessible given a PATH string. Use in place of exec.LookPath when you need need an independent check that a file exists in a path list, for example you do not want to use the current process's environment variables.

func (Aferox) TempDir added in v0.2.1

func (a Aferox) TempDir(dir string, prefix string) (string, error)

TempDir creates a new temporary directory in the directory dir with a name beginning with prefix and returns the path of the new directory. If dir is the empty string, TempDir uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempDir simultaneously will not choose the same directory. It is the caller's responsibility to remove the directory when no longer needed.

func (Aferox) TempFile added in v0.2.1

func (a Aferox) TempFile(dir string, pattern string) (afero.File, error)

TempFile creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting *os.File. The filename is generated by taking pattern and adding a random string to the end. If pattern includes a "*", the random string replaces the last "*". If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

type Fsx

type Fsx struct {
	// contains filtered or unexported fields
}

Fsx adjusts all relative paths based on the stored working directory, instead of relying on the default behavior for relative paths defined by the implementing Fs.

func NewFsx

func NewFsx(dir string, fs afero.Fs) *Fsx

func (*Fsx) Abs

func (f *Fsx) Abs(path string) string

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.

func (*Fsx) Chdir

func (f *Fsx) Chdir(dir string)

Chdir changes the current working directory to the named directory.

func (*Fsx) Chmod

func (f *Fsx) Chmod(name string, mode os.FileMode) error

Chmod changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target. If there is an error, it will be of type *PathError.

A different subset of the mode bits are used, depending on the operating system.

func (*Fsx) Chown added in v0.3.0

func (f *Fsx) Chown(name string, uid, gid int) error

Chown changes the uid and gid of the named file.

func (*Fsx) Chtimes

func (f *Fsx) Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions.

func (*Fsx) Create

func (f *Fsx) Create(name string) (afero.File, error)

Create creates or truncates the named file. If the file already exists, it is truncated. If the file does not exist, it is created with mode 0666 (before umask). If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR.

func (*Fsx) Getwd

func (f *Fsx) Getwd() string

Getwd returns a rooted path name corresponding to the current directory.

func (*Fsx) Mkdir

func (f *Fsx) Mkdir(name string, perm os.FileMode) error

Mkdir creates a new directory with the specified name and permission bits (before umask).

func (*Fsx) MkdirAll

func (f *Fsx) MkdirAll(path string, perm os.FileMode) 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.

func (*Fsx) Name

func (f *Fsx) Name() string

The name of this FileSystem.

func (*Fsx) Open

func (f *Fsx) Open(name string) (afero.File, error)

OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode perm (before umask). If successful, methods on the returned File can be used for I/O.

func (*Fsx) OpenFile

func (f *Fsx) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

OpenFile opens a file using the given flags and the given mode.

func (*Fsx) Remove

func (f *Fsx) Remove(name string) error

Remove removes the named file or (empty) directory.

func (*Fsx) RemoveAll

func (f *Fsx) RemoveAll(path 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).

func (*Fsx) Rename

func (f *Fsx) Rename(oldname, newname string) error

Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

func (*Fsx) Stat

func (f *Fsx) Stat(name string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL