Documentation ¶
Overview ¶
Package memory implements the file tree interface (tree.Entry). All data is stored in memory. This implementation is mostly intended for testing purposes.
Index ¶
- Constants
- type Entry
- func (e *Entry) Chmod(target, source tree.FileInfo) (tree.FileInfo, error)
- func (e *Entry) Close() error
- func (e *Entry) CopySource(source tree.FileInfo) (io.ReadCloser, error)
- func (e *Entry) CreateDir(name string, parentInfo, sourceInfo tree.FileInfo) (tree.FileInfo, error)
- func (e *Entry) CreateFile(name string, parent, source tree.FileInfo) (tree.Copier, error)
- func (e *Entry) CreateSymlink(name string, parentInfo, sourceInfo tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)
- func (e *Entry) FullInfo() (tree.FileInfo, error)
- func (e *Entry) GetFile(name string) (io.ReadCloser, error)
- func (e *Entry) HasMode() tree.Mode
- func (e *Entry) Hash() (tree.Hash, error)
- func (e *Entry) Id() (uint64, *tree.LocalFilesystem)
- func (e *Entry) Info() tree.FileInfo
- func (e *Entry) List(options tree.ListOptions) ([]tree.Entry, error)
- func (e *Entry) ModTime() time.Time
- func (e *Entry) Mode() tree.Mode
- func (e *Entry) Name() string
- func (e *Entry) PutFile(name string) (tree.Copier, error)
- func (e *Entry) PutFileTest(path []string, contents []byte) (tree.FileInfo, error)
- func (e *Entry) ReadInfo(path []string) (tree.FileInfo, error)
- func (e *Entry) ReadSymlink(file tree.FileInfo) (string, error)
- func (e *Entry) RelativePath() []string
- func (e *Entry) Remove(info tree.FileInfo) (tree.FileInfo, error)
- func (e *Entry) Root() tree.Entry
- func (e *Entry) Size() int64
- func (e *Entry) String() string
- func (e *Entry) Tree() tree.Tree
- func (e *Entry) Type() tree.Type
- func (e *Entry) UpdateFile(file, source tree.FileInfo) (tree.Copier, error)
- func (e *Entry) UpdateRsync(file, source tree.FileInfo) (tree.RsyncBasis, tree.Copier, error)
- func (e *Entry) UpdateSymlink(file, source tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)
Constants ¶
const ( DEFAULT_MODE = 0644 DEFAULT_DIR_MODE = 0755 DEFAULT_HAS_MODE = 0777 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is one file or directory.
func (*Entry) Chmod ¶
Chmod applies the given mode bits, as far as this in-memory tree 'supports' them.
func (*Entry) Close ¶
Close does nothing: there are no resources allocated that won't be collected by the garbage collector.
func (*Entry) CopySource ¶
CopySource creates a bytes.Buffer reader to read the contents of this file.
func (*Entry) CreateFile ¶
CreateFile is part of tree.FileEntry. It returns the created entry, a WriteCloser to write the data to, and possibly an error. The file's contents is stored when the returned WriteCloser is closed.
func (*Entry) CreateSymlink ¶
func (e *Entry) CreateSymlink(name string, parentInfo, sourceInfo tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)
CreateSymlink creates an Entry with type link and the contents.
func (*Entry) FullInfo ¶
FullInfo returns a FileInfo object with hash. It won't return an error (there are no IO errors in an in-memory filesystem).
func (*Entry) GetFile ¶
func (e *Entry) GetFile(name string) (io.ReadCloser, error)
GetFile returns a file handle (io.ReadCloser) that can be used to read a status file.
func (*Entry) Id ¶
func (e *Entry) Id() (uint64, *tree.LocalFilesystem)
Id returns the inode and dummy filesystem information.
func (*Entry) List ¶
List returns a list of directory entries for directories. It returns an error when attempting to list something other than a directory.
func (*Entry) PutFile ¶
PutFile returns a file handle (tree.Copier) to a newly created/replaced child file that can be used to save the replica state.
func (*Entry) PutFileTest ¶
PutFileTest writes the contents to a new or existing file. This function only exists for testing purposes.
func (*Entry) ReadInfo ¶
ReadInfo returns the FileInfo for the specified file, with a hash, or a 'not found' error if the file doesn't exist.
func (*Entry) ReadSymlink ¶
ReadSymlink returns the contents of this entry if it is a symlink.
func (*Entry) RelativePath ¶
RelativePath returns the path relative to the root.
func (*Entry) Size ¶
Size returns the filesize for files, or the number of direct children for directories.
func (*Entry) UpdateFile ¶
UpdateFile is part of tree.FileEntry and implements replacing a file. When closing the returned WriteCloser, the file is actually replaced.
func (*Entry) UpdateRsync ¶
UpdateRsync opens the existing file to generate a signature for, and creates a new file where the new data is written, from the base file and from the patch data.