afero

package
v0.0.0-...-5b6cbe3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const FilePathSeparator = string(filepath.Separator)

Variables

This section is empty.

Functions

func ChangeFileName

func ChangeFileName(f *FileData, newname string)

func New

func New(client *middleware.Client) afero.Fs

func SetModTime

func SetModTime(f *FileData, mtime time.Time)

func SetMode

func SetMode(f *FileData, mode os.FileMode)

Types

type Dir

type Dir interface {
	Find(name string) (*FileData, bool)
	Len() int
	Names() []string
	Files() []*FileData
	Add(*FileData)
	Remove(*FileData)
}

Interface of a Directory Manager

type DirMap

type DirMap map[string]*FileData

Implementation of a Directory Manager

func (DirMap) Add

func (m DirMap) Add(f *FileData)

func (DirMap) Files

func (m DirMap) Files() (files []*FileData)

func (DirMap) Find

func (m DirMap) Find(name string) (*FileData, bool)

func (DirMap) Len

func (m DirMap) Len() int

func (DirMap) Names

func (m DirMap) Names() (names []string)

func (DirMap) Remove

func (m DirMap) Remove(f *FileData)

type File

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

func (*File) Close

func (f *File) Close() error

func (File) Data

func (f File) Data() *FileData

func (*File) Info

func (f *File) Info() *FileInfo

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(b []byte) (n int, err error)

Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF.

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

func (*File) Readdir

func (f *File) Readdir(count int) (res []os.FileInfo, err error)

func (*File) Readdirnames

func (f *File) Readdirnames(n int) (names []string, err error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

func (*File) Stat

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

func (*File) Sync

func (f *File) Sync() error

Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.

func (*File) Truncate

func (f *File) Truncate(size int64) error

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

Write stores locally (in situ) the written data until they are explicitly flushed on the backend

func (*File) WriteAt

func (f *File) WriteAt(b []byte, off int64) (n int, err error)

func (*File) WriteString

func (f *File) WriteString(s string) (ret int, err error)

type FileData

type FileData struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*FileData) Name

func (d *FileData) Name() string

type FileInfo

type FileInfo struct {
	*FileData
}

func GetFileInfo

func GetFileInfo(f *FileData) *FileInfo

func (*FileInfo) IsDir

func (s *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (s *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (s *FileInfo) Mode() os.FileMode

func (*FileInfo) Name

func (s *FileInfo) Name() string

Implements os.FileInfo

func (*FileInfo) Size

func (s *FileInfo) Size() int64

func (*FileInfo) Sys

func (s *FileInfo) Sys() interface{}

type Fs

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

Fs is an afero.Fs implementation that abstracts Tromos as a filesystem service to the end-user. The filesystem maintains in memory only the cached files

func (Fs) Chmod

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

func (Fs) Chtimes

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

func (Fs) Create

func (s Fs) 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. If there is an error, it will be of type *PathError.

func (Fs) Lstat

func (s Fs) Lstat(p string) (os.FileInfo, error)

func (Fs) Mkdir

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

func (Fs) MkdirAll

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

func (Fs) Name

func (s Fs) Name() string

func (Fs) Open

func (s Fs) Open(name string) (afero.File, error)

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. If there is an error, it will be of type *PathError.

func (Fs) OpenFile

func (s Fs) OpenFile(name string, flag int, perm os.FileMode) (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. If there is an error, it will be of type *PathError.

func (Fs) Remove

func (s Fs) Remove(name string) error

func (Fs) RemoveAll

func (s Fs) RemoveAll(path string) error

func (Fs) Rename

func (s Fs) Rename(oldname, newname string) error

func (Fs) Stat

func (s Fs) Stat(name string) (os.FileInfo, error)

Jump to

Keyboard shortcuts

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