Documentation ¶
Overview ¶
Package file implements the file tree interface (tree.Entry) for local filesystems.
Index ¶
- Constants
- func Lchtimes(path string, atime time.Time, mtime time.Time) error
- type Entry
- func (e *Entry) FullInfo() (tree.FileInfo, 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) RelativePath() []string
- func (e *Entry) Size() int64
- func (e *Entry) String() string
- func (e *Entry) Tree() tree.Tree
- func (e *Entry) Type() tree.Type
- type Tree
- func (r *Tree) Chmod(target, source tree.FileInfo) (tree.FileInfo, error)
- func (r *Tree) Close() error
- func (r *Tree) CopySource(source tree.FileInfo) (io.ReadCloser, error)
- func (r *Tree) CreateDir(name string, parent, source tree.FileInfo) (tree.FileInfo, error)
- func (r *Tree) CreateFile(name string, parent, source tree.FileInfo) (tree.Copier, error)
- func (r *Tree) CreateSymlink(name string, parentInfo, sourceInfo tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)
- func (r *Tree) GetFile(name string) (io.ReadCloser, error)
- func (r *Tree) PutFile(name string) (tree.Copier, error)
- func (r *Tree) PutFileTest(path []string, contents []byte) (tree.FileInfo, error)
- func (r *Tree) ReadInfo(path []string) (tree.FileInfo, error)
- func (r *Tree) ReadSymlink(file tree.FileInfo) (string, error)
- func (r *Tree) Remove(file tree.FileInfo) (tree.FileInfo, error)
- func (r *Tree) Root() tree.Entry
- func (r *Tree) String() string
- func (r *Tree) UpdateFile(file, source tree.FileInfo) (tree.Copier, error)
- func (r *Tree) UpdateRsync(file, source tree.FileInfo) (tree.RsyncBasis, tree.Copier, error)
- func (r *Tree) UpdateSymlink(file, source tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)
Constants ¶
const ( TEMPPREFIX = ".dtsync-" TEMPSUFFIX = ".tmp" )
A prefix and suffix for files that are being copied.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is one file or directory in the filesystem. It additionally contains it's name, parent, root, and stat() result.
func (*Entry) FullInfo ¶
FullInfo returns a tree.FileInfo with hash, or an error if the hash couldn't be calculated.
func (*Entry) HasMode ¶
HasMode returns the permission bits this filesystem supports (at least 0777 for Unix-like filesystems).
func (*Entry) Id ¶
func (e *Entry) Id() (uint64, *tree.LocalFilesystem)
Id returns the inode and local filesystem information, if the underlying filesystem supports it.
func (*Entry) Info ¶
Info returns a tree.FileInfo of the stat() result in this Entry (thus, without a hash).
func (*Entry) Mode ¶
Mode returns the mode bits for this file, as far as the filesystem supports them.
func (*Entry) RelativePath ¶
func (*Entry) Size ¶
Size returns the filesize for regular files. For other file types, the result is undefined.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree encapsulates the root path, so every Entry can know the root path.
func NewTestRoot ¶
NewTestRoot returns a new root in a temporary directory. It should be removed after use using root.Remove()
func (*Tree) Chmod ¶
Chmod applies the given mode bits and returns the stat() result. Not all bits may be applied (subject to HasMode()).
func (*Tree) CopySource ¶
func (*Tree) CreateFile ¶
CreateFile creates the child, implementing tree.FileEntry. This function is useful for Copy.
func (*Tree) CreateSymlink ¶
func (*Tree) GetFile ¶
func (r *Tree) GetFile(name string) (io.ReadCloser, error)
GetFile returns an io.ReadCloser with the named file. The file must be closed after use.
func (*Tree) PutFileTest ¶
PutFileTest implements tree.TestTree by writing a single file with the given name and contents.
func (*Tree) Remove ¶
Remove removes this entry, recursively. It returns the FileInfo of the parent, or an error.
func (*Tree) UpdateFile ¶
UpdateFile replaces itself, to implement tree.FileEntry. This function is useful for Update.
func (*Tree) 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.