afero: github.com/spf13/afero Index | Files | Directories

package afero

import "github.com/spf13/afero"

Index

Package Files

afero.go basepath.go cacheOnReadFs.go const_win_unix.go copyOnWriteFs.go httpFs.go ioutil.go lstater.go match.go memmap.go os.go path.go readonlyfs.go regexpfs.go unionFile.go util.go

Constants

const BADFD = syscall.EBADFD
const FilePathSeparator = string(filepath.Separator)

Filepath separator defined by os.Separator.

Variables

var (
    ErrFileClosed        = errors.New("File is closed")
    ErrOutOfRange        = errors.New("Out of range")
    ErrTooLarge          = errors.New("Too large")
    ErrFileNotFound      = os.ErrNotExist
    ErrFileExists        = os.ErrExist
    ErrDestinationExists = os.ErrExist
)

func DirExists Uses

func DirExists(fs Fs, path string) (bool, error)

DirExists checks if a path exists and is a directory.

func Exists Uses

func Exists(fs Fs, path string) (bool, error)

Check if a file or directory exists.

func FileContainsAnyBytes Uses

func FileContainsAnyBytes(fs Fs, filename string, subslices [][]byte) (bool, error)

Check if a file contains any of the specified byte slices.

func FileContainsBytes Uses

func FileContainsBytes(fs Fs, filename string, subslice []byte) (bool, error)

Check if a file contains a specified byte slice.

func FullBaseFsPath Uses

func FullBaseFsPath(basePathFs *BasePathFs, relativePath string) string

func GetTempDir Uses

func GetTempDir(fs Fs, subPath string) string

GetTempDir returns the default temp directory with trailing slash if subPath is not empty then it will be created recursively with mode 777 rwx rwx rwx

func Glob Uses

func Glob(fs Fs, pattern string) (matches []string, err error)

Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').

Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.

This was adapted from (http://golang.org/pkg/path/filepath) and uses several built-ins from that package.

func IsDir Uses

func IsDir(fs Fs, path string) (bool, error)

IsDir checks if a given path is a directory.

func IsEmpty Uses

func IsEmpty(fs Fs, path string) (bool, error)

IsEmpty checks if a given file or directory is empty.

func NeuterAccents Uses

func NeuterAccents(s string) string

Transform characters with accents into plain forms.

func ReadAll Uses

func ReadAll(r io.Reader) ([]byte, error)

ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.

func ReadDir Uses

func ReadDir(fs Fs, dirname string) ([]os.FileInfo, error)

func ReadFile Uses

func ReadFile(fs Fs, filename string) ([]byte, error)

func SafeWriteReader Uses

func SafeWriteReader(fs Fs, path string, r io.Reader) (err error)

func TempDir Uses

func TempDir(fs Fs, dir, prefix string) (name string, err error)

func UnicodeSanitize Uses

func UnicodeSanitize(s string) string

Rewrite string to remove non-standard path characters

func Walk Uses

func Walk(fs Fs, root string, walkFn filepath.WalkFunc) error

func WriteFile Uses

func WriteFile(fs Fs, filename string, data []byte, perm os.FileMode) error

func WriteReader Uses

func WriteReader(fs Fs, path string, r io.Reader) (err error)

type Afero Uses

type Afero struct {
    Fs
}

func (Afero) DirExists Uses

func (a Afero) DirExists(path string) (bool, error)

func (Afero) Exists Uses

func (a Afero) Exists(path string) (bool, error)

func (Afero) FileContainsAnyBytes Uses

func (a Afero) FileContainsAnyBytes(filename string, subslices [][]byte) (bool, error)

func (Afero) FileContainsBytes Uses

func (a Afero) FileContainsBytes(filename string, subslice []byte) (bool, error)

func (Afero) GetTempDir Uses

func (a Afero) GetTempDir(subPath string) string

func (Afero) IsDir Uses

func (a Afero) IsDir(path string) (bool, error)

func (Afero) IsEmpty Uses

func (a Afero) IsEmpty(path string) (bool, error)

func (Afero) ReadDir Uses

func (a Afero) ReadDir(dirname string) ([]os.FileInfo, error)

ReadDir reads the directory named by dirname and returns a list of sorted directory entries.

func (Afero) ReadFile Uses

func (a Afero) ReadFile(filename string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.

func (Afero) SafeWriteReader Uses

func (a Afero) SafeWriteReader(path string, r io.Reader) (err error)

Same as WriteReader but checks to see if file/directory already exists.

func (Afero) TempDir Uses

func (a Afero) TempDir(dir, prefix string) (name string, err 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 (Afero) TempFile Uses

func (a Afero) TempFile(dir, prefix string) (f File, err error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *File. 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.

func (Afero) Walk Uses

func (a Afero) Walk(root string, walkFn filepath.WalkFunc) error

func (Afero) WriteFile Uses

func (a Afero) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm; otherwise WriteFile truncates it before writing.

func (Afero) WriteReader Uses

func (a Afero) WriteReader(path string, r io.Reader) (err error)

Takes a reader and a path and writes the content

type BasePathFile Uses

type BasePathFile struct {
    File
    // contains filtered or unexported fields
}

func (*BasePathFile) Name Uses

func (f *BasePathFile) Name() string

type BasePathFs Uses

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

The BasePathFs restricts all operations to a given path within an Fs. The given file name to the operations on this Fs will be prepended with the base path before calling the base Fs. Any file name (after filepath.Clean()) outside this base path will be treated as non existing file.

Note that it does not clean the error messages on return, so you may reveal the real path on errors.

func (*BasePathFs) Chmod Uses

func (b *BasePathFs) Chmod(name string, mode os.FileMode) (err error)

func (*BasePathFs) Chtimes Uses

func (b *BasePathFs) Chtimes(name string, atime, mtime time.Time) (err error)

func (*BasePathFs) Create Uses

func (b *BasePathFs) Create(name string) (f File, err error)

func (*BasePathFs) LstatIfPossible Uses

func (b *BasePathFs) LstatIfPossible(name string) (os.FileInfo, bool, error)

func (*BasePathFs) Mkdir Uses

func (b *BasePathFs) Mkdir(name string, mode os.FileMode) (err error)

func (*BasePathFs) MkdirAll Uses

func (b *BasePathFs) MkdirAll(name string, mode os.FileMode) (err error)

func (*BasePathFs) Name Uses

func (b *BasePathFs) Name() string

func (*BasePathFs) Open Uses

func (b *BasePathFs) Open(name string) (f File, err error)

func (*BasePathFs) OpenFile Uses

func (b *BasePathFs) OpenFile(name string, flag int, mode os.FileMode) (f File, err error)

func (*BasePathFs) RealPath Uses

func (b *BasePathFs) RealPath(name string) (path string, err error)

on a file outside the base path it returns the given file name and an error, else the given file with the base path prepended

func (*BasePathFs) Remove Uses

func (b *BasePathFs) Remove(name string) (err error)

func (*BasePathFs) RemoveAll Uses

func (b *BasePathFs) RemoveAll(name string) (err error)

func (*BasePathFs) Rename Uses

func (b *BasePathFs) Rename(oldname, newname string) (err error)

func (*BasePathFs) Stat Uses

func (b *BasePathFs) Stat(name string) (fi os.FileInfo, err error)

type CacheOnReadFs Uses

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

If the cache duration is 0, cache time will be unlimited, i.e. once a file is in the layer, the base will never be read again for this file.

For cache times greater than 0, the modification time of a file is checked. Note that a lot of file system implementations only allow a resolution of a second for timestamps... or as the godoc for os.Chtimes() states: "The underlying filesystem may truncate or round the values to a less precise time unit."

This caching union will forward all write calls also to the base file system first. To prevent writing to the base Fs, wrap it in a read-only filter - Note: this will also make the overlay read-only, for writing files in the overlay, use the overlay Fs directly, not via the union Fs.

func (*CacheOnReadFs) Chmod Uses

func (u *CacheOnReadFs) Chmod(name string, mode os.FileMode) error

func (*CacheOnReadFs) Chtimes Uses

func (u *CacheOnReadFs) Chtimes(name string, atime, mtime time.Time) error

func (*CacheOnReadFs) Create Uses

func (u *CacheOnReadFs) Create(name string) (File, error)

func (*CacheOnReadFs) Mkdir Uses

func (u *CacheOnReadFs) Mkdir(name string, perm os.FileMode) error

func (*CacheOnReadFs) MkdirAll Uses

func (u *CacheOnReadFs) MkdirAll(name string, perm os.FileMode) error

func (*CacheOnReadFs) Name Uses

func (u *CacheOnReadFs) Name() string

func (*CacheOnReadFs) Open Uses

func (u *CacheOnReadFs) Open(name string) (File, error)

func (*CacheOnReadFs) OpenFile Uses

func (u *CacheOnReadFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*CacheOnReadFs) Remove Uses

func (u *CacheOnReadFs) Remove(name string) error

func (*CacheOnReadFs) RemoveAll Uses

func (u *CacheOnReadFs) RemoveAll(name string) error

func (*CacheOnReadFs) Rename Uses

func (u *CacheOnReadFs) Rename(oldname, newname string) error

func (*CacheOnReadFs) Stat Uses

func (u *CacheOnReadFs) Stat(name string) (os.FileInfo, error)

type CopyOnWriteFs Uses

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

The CopyOnWriteFs is a union filesystem: a read only base file system with a possibly writeable layer on top. Changes to the file system will only be made in the overlay: Changing an existing file in the base layer which is not present in the overlay will copy the file to the overlay ("changing" includes also calls to e.g. Chtimes() and Chmod()).

Reading directories is currently only supported via Open(), not OpenFile().

func (*CopyOnWriteFs) Chmod Uses

func (u *CopyOnWriteFs) Chmod(name string, mode os.FileMode) error

func (*CopyOnWriteFs) Chtimes Uses

func (u *CopyOnWriteFs) Chtimes(name string, atime, mtime time.Time) error

func (*CopyOnWriteFs) Create Uses

func (u *CopyOnWriteFs) Create(name string) (File, error)

func (*CopyOnWriteFs) LstatIfPossible Uses

func (u *CopyOnWriteFs) LstatIfPossible(name string) (os.FileInfo, bool, error)

func (*CopyOnWriteFs) Mkdir Uses

func (u *CopyOnWriteFs) Mkdir(name string, perm os.FileMode) error

func (*CopyOnWriteFs) MkdirAll Uses

func (u *CopyOnWriteFs) MkdirAll(name string, perm os.FileMode) error

func (*CopyOnWriteFs) Name Uses

func (u *CopyOnWriteFs) Name() string

func (*CopyOnWriteFs) Open Uses

func (u *CopyOnWriteFs) Open(name string) (File, error)

This function handles the 9 different possibilities caused by the union which are the intersection of the following...

layer: doesn't exist, exists as a file, and exists as a directory
base:  doesn't exist, exists as a file, and exists as a directory

func (*CopyOnWriteFs) OpenFile Uses

func (u *CopyOnWriteFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*CopyOnWriteFs) Remove Uses

func (u *CopyOnWriteFs) Remove(name string) error

Removing files present only in the base layer is not permitted. If a file is present in the base layer and the overlay, only the overlay will be removed.

func (*CopyOnWriteFs) RemoveAll Uses

func (u *CopyOnWriteFs) RemoveAll(name string) error

func (*CopyOnWriteFs) Rename Uses

func (u *CopyOnWriteFs) Rename(oldname, newname string) error

Renaming files present only in the base layer is not permitted

func (*CopyOnWriteFs) Stat Uses

func (u *CopyOnWriteFs) Stat(name string) (os.FileInfo, error)

type DirsMerger Uses

type DirsMerger func(lofi, bofi []os.FileInfo) ([]os.FileInfo, error)

DirsMerger is how UnionFile weaves two directories together. It takes the FileInfo slices from the layer and the base and returns a single view.

type File Uses

type File interface {
    io.Closer
    io.Reader
    io.ReaderAt
    io.Seeker
    io.Writer
    io.WriterAt

    Name() string
    Readdir(count int) ([]os.FileInfo, error)
    Readdirnames(n int) ([]string, error)
    Stat() (os.FileInfo, error)
    Sync() error
    Truncate(size int64) error
    WriteString(s string) (ret int, err error)
}

File represents a file in the filesystem.

func TempFile Uses

func TempFile(fs Fs, dir, prefix string) (f File, err error)

type Fs Uses

type Fs interface {
    // Create creates a file in the filesystem, returning the file and an
    // error, if any happens.
    Create(name string) (File, error)

    // Mkdir creates a directory in the filesystem, return an error if any
    // happens.
    Mkdir(name string, perm os.FileMode) error

    // MkdirAll creates a directory path and all parents that does not exist
    // yet.
    MkdirAll(path string, perm os.FileMode) error

    // Open opens a file, returning it or an error, if any happens.
    Open(name string) (File, error)

    // OpenFile opens a file using the given flags and the given mode.
    OpenFile(name string, flag int, perm os.FileMode) (File, error)

    // Remove removes a file identified by name, returning an error, if any
    // happens.
    Remove(name string) error

    // RemoveAll removes a directory path and any children it contains. It
    // does not fail if the path does not exist (return nil).
    RemoveAll(path string) error

    // Rename renames a file.
    Rename(oldname, newname string) error

    // Stat returns a FileInfo describing the named file, or an error, if any
    // happens.
    Stat(name string) (os.FileInfo, error)

    // The name of this FileSystem
    Name() string

    //Chmod changes the mode of the named file to mode.
    Chmod(name string, mode os.FileMode) error

    //Chtimes changes the access and modification times of the named file
    Chtimes(name string, atime time.Time, mtime time.Time) error
}

Fs is the filesystem interface.

Any simulated or real filesystem should implement this interface.

func NewBasePathFs Uses

func NewBasePathFs(source Fs, path string) Fs

func NewCacheOnReadFs Uses

func NewCacheOnReadFs(base Fs, layer Fs, cacheTime time.Duration) Fs

func NewCopyOnWriteFs Uses

func NewCopyOnWriteFs(base Fs, layer Fs) Fs

func NewMemMapFs Uses

func NewMemMapFs() Fs

func NewOsFs Uses

func NewOsFs() Fs

func NewReadOnlyFs Uses

func NewReadOnlyFs(source Fs) Fs

func NewRegexpFs Uses

func NewRegexpFs(source Fs, re *regexp.Regexp) Fs

type HttpFs Uses

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

func NewHttpFs Uses

func NewHttpFs(source Fs) *HttpFs

func (HttpFs) Chmod Uses

func (h HttpFs) Chmod(name string, mode os.FileMode) error

func (HttpFs) Chtimes Uses

func (h HttpFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (HttpFs) Create Uses

func (h HttpFs) Create(name string) (File, error)

func (HttpFs) Dir Uses

func (h HttpFs) Dir(s string) *httpDir

func (HttpFs) Mkdir Uses

func (h HttpFs) Mkdir(name string, perm os.FileMode) error

func (HttpFs) MkdirAll Uses

func (h HttpFs) MkdirAll(path string, perm os.FileMode) error

func (HttpFs) Name Uses

func (h HttpFs) Name() string

func (HttpFs) Open Uses

func (h HttpFs) Open(name string) (http.File, error)

func (HttpFs) OpenFile Uses

func (h HttpFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (HttpFs) Remove Uses

func (h HttpFs) Remove(name string) error

func (HttpFs) RemoveAll Uses

func (h HttpFs) RemoveAll(path string) error

func (HttpFs) Rename Uses

func (h HttpFs) Rename(oldname, newname string) error

func (HttpFs) Stat Uses

func (h HttpFs) Stat(name string) (os.FileInfo, error)

type Lstater Uses

type Lstater interface {
    LstatIfPossible(name string) (os.FileInfo, bool, error)
}

Lstater is an optional interface in Afero. It is only implemented by the filesystems saying so. It will call Lstat if the filesystem iself is, or it delegates to, the os filesystem. Else it will call Stat. In addtion to the FileInfo, it will return a boolean telling whether Lstat was called or not.

type MemMapFs Uses

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

func (*MemMapFs) Chmod Uses

func (m *MemMapFs) Chmod(name string, mode os.FileMode) error

func (*MemMapFs) Chtimes Uses

func (m *MemMapFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*MemMapFs) Create Uses

func (m *MemMapFs) Create(name string) (File, error)

func (*MemMapFs) List Uses

func (m *MemMapFs) List()

func (*MemMapFs) Mkdir Uses

func (m *MemMapFs) Mkdir(name string, perm os.FileMode) error

func (*MemMapFs) MkdirAll Uses

func (m *MemMapFs) MkdirAll(path string, perm os.FileMode) error

func (*MemMapFs) Name Uses

func (*MemMapFs) Name() string

func (*MemMapFs) Open Uses

func (m *MemMapFs) Open(name string) (File, error)

func (*MemMapFs) OpenFile Uses

func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*MemMapFs) Remove Uses

func (m *MemMapFs) Remove(name string) error

func (*MemMapFs) RemoveAll Uses

func (m *MemMapFs) RemoveAll(path string) error

func (*MemMapFs) Rename Uses

func (m *MemMapFs) Rename(oldname, newname string) error

func (*MemMapFs) Stat Uses

func (m *MemMapFs) Stat(name string) (os.FileInfo, error)

type OsFs Uses

type OsFs struct{}

OsFs is a Fs implementation that uses functions provided by the os package.

For details in any method, check the documentation of the os package (http://golang.org/pkg/os/).

func (OsFs) Chmod Uses

func (OsFs) Chmod(name string, mode os.FileMode) error

func (OsFs) Chtimes Uses

func (OsFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (OsFs) Create Uses

func (OsFs) Create(name string) (File, error)

func (OsFs) LstatIfPossible Uses

func (OsFs) LstatIfPossible(name string) (os.FileInfo, bool, error)

func (OsFs) Mkdir Uses

func (OsFs) Mkdir(name string, perm os.FileMode) error

func (OsFs) MkdirAll Uses

func (OsFs) MkdirAll(path string, perm os.FileMode) error

func (OsFs) Name Uses

func (OsFs) Name() string

func (OsFs) Open Uses

func (OsFs) Open(name string) (File, error)

func (OsFs) OpenFile Uses

func (OsFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (OsFs) Remove Uses

func (OsFs) Remove(name string) error

func (OsFs) RemoveAll Uses

func (OsFs) RemoveAll(path string) error

func (OsFs) Rename Uses

func (OsFs) Rename(oldname, newname string) error

func (OsFs) Stat Uses

func (OsFs) Stat(name string) (os.FileInfo, error)

type ReadOnlyFs Uses

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

func (*ReadOnlyFs) Chmod Uses

func (r *ReadOnlyFs) Chmod(n string, m os.FileMode) error

func (*ReadOnlyFs) Chtimes Uses

func (r *ReadOnlyFs) Chtimes(n string, a, m time.Time) error

func (*ReadOnlyFs) Create Uses

func (r *ReadOnlyFs) Create(n string) (File, error)

func (*ReadOnlyFs) LstatIfPossible Uses

func (r *ReadOnlyFs) LstatIfPossible(name string) (os.FileInfo, bool, error)

func (*ReadOnlyFs) Mkdir Uses

func (r *ReadOnlyFs) Mkdir(n string, p os.FileMode) error

func (*ReadOnlyFs) MkdirAll Uses

func (r *ReadOnlyFs) MkdirAll(n string, p os.FileMode) error

func (*ReadOnlyFs) Name Uses

func (r *ReadOnlyFs) Name() string

func (*ReadOnlyFs) Open Uses

func (r *ReadOnlyFs) Open(n string) (File, error)

func (*ReadOnlyFs) OpenFile Uses

func (r *ReadOnlyFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*ReadOnlyFs) ReadDir Uses

func (r *ReadOnlyFs) ReadDir(name string) ([]os.FileInfo, error)

func (*ReadOnlyFs) Remove Uses

func (r *ReadOnlyFs) Remove(n string) error

func (*ReadOnlyFs) RemoveAll Uses

func (r *ReadOnlyFs) RemoveAll(p string) error

func (*ReadOnlyFs) Rename Uses

func (r *ReadOnlyFs) Rename(o, n string) error

func (*ReadOnlyFs) Stat Uses

func (r *ReadOnlyFs) Stat(name string) (os.FileInfo, error)

type RegexpFile Uses

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

func (*RegexpFile) Close Uses

func (f *RegexpFile) Close() error

func (*RegexpFile) Name Uses

func (f *RegexpFile) Name() string

func (*RegexpFile) Read Uses

func (f *RegexpFile) Read(s []byte) (int, error)

func (*RegexpFile) ReadAt Uses

func (f *RegexpFile) ReadAt(s []byte, o int64) (int, error)

func (*RegexpFile) Readdir Uses

func (f *RegexpFile) Readdir(c int) (fi []os.FileInfo, err error)

func (*RegexpFile) Readdirnames Uses

func (f *RegexpFile) Readdirnames(c int) (n []string, err error)

func (*RegexpFile) Seek Uses

func (f *RegexpFile) Seek(o int64, w int) (int64, error)

func (*RegexpFile) Stat Uses

func (f *RegexpFile) Stat() (os.FileInfo, error)

func (*RegexpFile) Sync Uses

func (f *RegexpFile) Sync() error

func (*RegexpFile) Truncate Uses

func (f *RegexpFile) Truncate(s int64) error

func (*RegexpFile) Write Uses

func (f *RegexpFile) Write(s []byte) (int, error)

func (*RegexpFile) WriteAt Uses

func (f *RegexpFile) WriteAt(s []byte, o int64) (int, error)

func (*RegexpFile) WriteString Uses

func (f *RegexpFile) WriteString(s string) (int, error)

type RegexpFs Uses

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

The RegexpFs filters files (not directories) by regular expression. Only files matching the given regexp will be allowed, all others get a ENOENT error ( "No such file or directory").

func (*RegexpFs) Chmod Uses

func (r *RegexpFs) Chmod(name string, mode os.FileMode) error

func (*RegexpFs) Chtimes Uses

func (r *RegexpFs) Chtimes(name string, a, m time.Time) error

func (*RegexpFs) Create Uses

func (r *RegexpFs) Create(name string) (File, error)

func (*RegexpFs) Mkdir Uses

func (r *RegexpFs) Mkdir(n string, p os.FileMode) error

func (*RegexpFs) MkdirAll Uses

func (r *RegexpFs) MkdirAll(n string, p os.FileMode) error

func (*RegexpFs) Name Uses

func (r *RegexpFs) Name() string

func (*RegexpFs) Open Uses

func (r *RegexpFs) Open(name string) (File, error)

func (*RegexpFs) OpenFile Uses

func (r *RegexpFs) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*RegexpFs) Remove Uses

func (r *RegexpFs) Remove(name string) error

func (*RegexpFs) RemoveAll Uses

func (r *RegexpFs) RemoveAll(p string) error

func (*RegexpFs) Rename Uses

func (r *RegexpFs) Rename(oldname, newname string) error

func (*RegexpFs) Stat Uses

func (r *RegexpFs) Stat(name string) (os.FileInfo, error)

type UnionFile Uses

type UnionFile struct {
    Base   File
    Layer  File
    Merger DirsMerger
    // contains filtered or unexported fields
}

The UnionFile implements the afero.File interface and will be returned when reading a directory present at least in the overlay or opening a file for writing.

The calls to Readdir() and Readdirnames() merge the file os.FileInfo / names from the base and the overlay - for files present in both layers, only those from the overlay will be used.

When opening files for writing (Create() / OpenFile() with the right flags) the operations will be done in both layers, starting with the overlay. A successful read in the overlay will move the cursor position in the base layer by the number of bytes read.

func (*UnionFile) Close Uses

func (f *UnionFile) Close() error

func (*UnionFile) Name Uses

func (f *UnionFile) Name() string

func (*UnionFile) Read Uses

func (f *UnionFile) Read(s []byte) (int, error)

func (*UnionFile) ReadAt Uses

func (f *UnionFile) ReadAt(s []byte, o int64) (int, error)

func (*UnionFile) Readdir Uses

func (f *UnionFile) Readdir(c int) (ofi []os.FileInfo, err error)

Readdir will weave the two directories together and return a single view of the overlayed directories. At the end of the directory view, the error is io.EOF if c > 0.

func (*UnionFile) Readdirnames Uses

func (f *UnionFile) Readdirnames(c int) ([]string, error)

func (*UnionFile) Seek Uses

func (f *UnionFile) Seek(o int64, w int) (pos int64, err error)

func (*UnionFile) Stat Uses

func (f *UnionFile) Stat() (os.FileInfo, error)

func (*UnionFile) Sync Uses

func (f *UnionFile) Sync() (err error)

func (*UnionFile) Truncate Uses

func (f *UnionFile) Truncate(s int64) (err error)

func (*UnionFile) Write Uses

func (f *UnionFile) Write(s []byte) (n int, err error)

func (*UnionFile) WriteAt Uses

func (f *UnionFile) WriteAt(s []byte, o int64) (n int, err error)

func (*UnionFile) WriteString Uses

func (f *UnionFile) WriteString(s string) (n int, err error)

Directories

PathSynopsis
mem
sftpfs

Package afero imports 21 packages (graph) and is imported by 2079 packages. Updated 2019-05-23. Refresh now. Tools for package owners.