Documentation ¶
Overview ¶
Package vfs provides a virtual filing system layer over rclone's native objects.
It attempts to behave in a similar way to Go's filing system manipulation code in the os package. The same named function should behave in an identical fashion. The objects also obey Go's standard interfaces.
Note that paths don't start or end with /, so the root directory may be referred to as "". However Stat strips slashes so you can use paths with slashes in.
It also includes directory caching ¶
The vfs package returns Error values to signal precisely which error conditions have occurred. It may also return general errors it receives. It tries to use os Error values (e.g. os.ErrExist) where possible.
Index ¶
- Variables
- func Help() string
- type Dir
- func (d *Dir) AddVirtual(leaf string, size int64, isDir bool)
- func (d *Dir) Create(name string, flags int) (*File, error)
- func (d *Dir) DelVirtual(leaf string)
- func (d *Dir) DirEntry() (entry fs.DirEntry)
- func (d *Dir) ForgetAll() (hasVirtual bool)
- func (d *Dir) ForgetPath(relativePath string, entryType fs.EntryType)
- func (d *Dir) Fs() fs.Fs
- func (d *Dir) Inode() uint64
- func (d *Dir) IsDir() bool
- func (d *Dir) IsFile() bool
- func (d *Dir) Mkdir(name string) (*Dir, error)
- func (d *Dir) ModTime() time.Time
- func (d *Dir) Mode() (mode os.FileMode)
- func (d *Dir) Name() (name string)
- func (d *Dir) Node() Node
- func (d *Dir) Open(flags int) (fd Handle, err error)
- func (d *Dir) Path() (name string)
- func (d *Dir) ReadDirAll() (items Nodes, err error)
- func (d *Dir) Remove() error
- func (d *Dir) RemoveAll() error
- func (d *Dir) RemoveName(name string) error
- func (d *Dir) Rename(oldName, newName string, destDir *Dir) error
- func (d *Dir) SetModTime(modTime time.Time) error
- func (d *Dir) SetSys(x interface{})
- func (d *Dir) Size() int64
- func (d *Dir) Stat(name string) (node Node, err error)
- func (d *Dir) String() string
- func (d *Dir) Sync() error
- func (d *Dir) Sys() interface{}
- func (d *Dir) Truncate(size int64) error
- func (d *Dir) VFS() *VFS
- type DirHandle
- func (h DirHandle) Chdir() error
- func (h DirHandle) Chmod(mode os.FileMode) error
- func (h DirHandle) Chown(uid, gid int) error
- func (fh *DirHandle) Close() (err error)
- func (h DirHandle) Fd() uintptr
- func (h DirHandle) Flush() (err error)
- func (h DirHandle) Lock() error
- func (h DirHandle) Name() string
- func (fh *DirHandle) Node() Node
- func (h DirHandle) Read(b []byte) (n int, err error)
- func (h DirHandle) ReadAt(b []byte, off int64) (n int, err error)
- func (fh *DirHandle) Readdir(n int) (fis []os.FileInfo, err error)
- func (fh *DirHandle) Readdirnames(n int) (names []string, err error)
- func (h DirHandle) Release() (err error)
- func (h DirHandle) Seek(offset int64, whence int) (ret int64, err error)
- func (fh *DirHandle) Stat() (fi os.FileInfo, err error)
- func (fh *DirHandle) String() string
- func (h DirHandle) Sync() error
- func (h DirHandle) Truncate(size int64) error
- func (h DirHandle) Unlock() error
- func (h DirHandle) Write(b []byte) (n int, err error)
- func (h DirHandle) WriteAt(b []byte, off int64) (n int, err error)
- func (h DirHandle) WriteString(s string) (n int, err error)
- type Error
- type File
- func (f *File) Dir() *Dir
- func (f *File) DirEntry() (entry fs.DirEntry)
- func (f *File) Fs() fs.Fs
- func (f *File) Inode() uint64
- func (f *File) IsDir() bool
- func (f *File) IsFile() bool
- func (f *File) ModTime() (modTime time.Time)
- func (f *File) Mode() (mode os.FileMode)
- func (f *File) Name() (name string)
- func (f *File) Node() Node
- func (f *File) Open(flags int) (fd Handle, err error)
- func (f *File) Path() string
- func (f *File) Remove() (err error)
- func (f *File) RemoveAll() error
- func (f *File) SetModTime(modTime time.Time) error
- func (f *File) SetSys(x interface{})
- func (f *File) Size() int64
- func (f *File) String() string
- func (f *File) Sync() error
- func (f *File) Sys() interface{}
- func (f *File) Truncate(size int64) (err error)
- func (f *File) VFS() *VFS
- type Handle
- type Node
- type Noder
- type Nodes
- type OsFiler
- type RWFileHandle
- func (fh *RWFileHandle) Chdir() error
- func (fh *RWFileHandle) Chmod(mode os.FileMode) error
- func (fh *RWFileHandle) Chown(uid, gid int) error
- func (fh *RWFileHandle) Close() error
- func (fh *RWFileHandle) Fd() uintptr
- func (fh *RWFileHandle) Flush() error
- func (fh *RWFileHandle) Lock() error
- func (fh *RWFileHandle) Name() string
- func (fh *RWFileHandle) Node() Node
- func (fh *RWFileHandle) Read(b []byte) (n int, err error)
- func (fh *RWFileHandle) ReadAt(b []byte, off int64) (n int, err error)
- func (fh *RWFileHandle) Readdir(n int) ([]os.FileInfo, error)
- func (fh *RWFileHandle) Readdirnames(n int) (names []string, err error)
- func (fh *RWFileHandle) Release() error
- func (fh *RWFileHandle) Seek(offset int64, whence int) (ret int64, err error)
- func (fh *RWFileHandle) Size() int64
- func (fh *RWFileHandle) Stat() (os.FileInfo, error)
- func (fh *RWFileHandle) String() string
- func (fh *RWFileHandle) Sync() error
- func (fh *RWFileHandle) Truncate(size int64) (err error)
- func (fh *RWFileHandle) Unlock() error
- func (fh *RWFileHandle) Write(b []byte) (n int, err error)
- func (fh *RWFileHandle) WriteAt(b []byte, off int64) (n int, err error)
- func (fh *RWFileHandle) WriteString(s string) (n int, err error)
- type ReadFileHandle
- func (h ReadFileHandle) Chdir() error
- func (h ReadFileHandle) Chmod(mode os.FileMode) error
- func (h ReadFileHandle) Chown(uid, gid int) error
- func (fh *ReadFileHandle) Close() error
- func (h ReadFileHandle) Fd() uintptr
- func (fh *ReadFileHandle) Flush() error
- func (h ReadFileHandle) Lock() error
- func (fh *ReadFileHandle) Name() string
- func (fh *ReadFileHandle) Node() Node
- func (fh *ReadFileHandle) Read(p []byte) (n int, err error)
- func (fh *ReadFileHandle) ReadAt(p []byte, off int64) (n int, err error)
- func (h ReadFileHandle) Readdir(n int) ([]os.FileInfo, error)
- func (h ReadFileHandle) Readdirnames(n int) (names []string, err error)
- func (fh *ReadFileHandle) Release() error
- func (fh *ReadFileHandle) Seek(offset int64, whence int) (n int64, err error)
- func (fh *ReadFileHandle) Size() int64
- func (fh *ReadFileHandle) Stat() (os.FileInfo, error)
- func (fh *ReadFileHandle) String() string
- func (h ReadFileHandle) Sync() error
- func (h ReadFileHandle) Truncate(size int64) error
- func (h ReadFileHandle) Unlock() error
- func (h ReadFileHandle) Write(b []byte) (n int, err error)
- func (h ReadFileHandle) WriteAt(b []byte, off int64) (n int, err error)
- func (h ReadFileHandle) WriteString(s string) (n int, err error)
- type VFS
- func (vfs *VFS) AddVirtual(remote string, size int64, isDir bool) (err error)
- func (vfs *VFS) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (vfs *VFS) CleanUp() error
- func (vfs *VFS) Create(name string) (Handle, error)
- func (vfs *VFS) FlushDirCache()
- func (vfs *VFS) Fs() fs.Fs
- func (vfs *VFS) Mkdir(name string, perm os.FileMode) error
- func (vfs *VFS) MkdirAll(name string, perm os.FileMode) error
- func (vfs *VFS) Open(name string) (Handle, error)
- func (vfs *VFS) OpenFile(name string, flags int, perm os.FileMode) (fd Handle, err error)
- func (vfs *VFS) ReadDir(dirname string) ([]os.FileInfo, error)
- func (vfs *VFS) ReadFile(filename string) (b []byte, err error)
- func (vfs *VFS) Remove(name string) error
- func (vfs *VFS) Rename(oldName, newName string) error
- func (vfs *VFS) Root() (*Dir, error)
- func (vfs *VFS) SetCacheMode(cacheMode vfscommon.CacheMode)
- func (vfs *VFS) Shutdown()
- func (vfs *VFS) Stat(path string) (node Node, err error)
- func (vfs *VFS) StatParent(name string) (dir *Dir, leaf string, err error)
- func (vfs *VFS) Statfs() (total, used, free int64)
- func (vfs *VFS) Stats() (out rc.Params)
- func (vfs *VFS) WaitForWriters(timeout time.Duration)
- type WriteFileHandle
- func (h WriteFileHandle) Chdir() error
- func (h WriteFileHandle) Chmod(mode os.FileMode) error
- func (h WriteFileHandle) Chown(uid, gid int) error
- func (fh *WriteFileHandle) Close() error
- func (h WriteFileHandle) Fd() uintptr
- func (fh *WriteFileHandle) Flush() error
- func (h WriteFileHandle) Lock() error
- func (fh *WriteFileHandle) Name() string
- func (fh *WriteFileHandle) Node() Node
- func (fh *WriteFileHandle) Offset() (offset int64)
- func (fh *WriteFileHandle) Read(p []byte) (n int, err error)
- func (fh *WriteFileHandle) ReadAt(p []byte, off int64) (n int, err error)
- func (h WriteFileHandle) Readdir(n int) ([]os.FileInfo, error)
- func (h WriteFileHandle) Readdirnames(n int) (names []string, err error)
- func (fh *WriteFileHandle) Release() error
- func (h WriteFileHandle) Seek(offset int64, whence int) (ret int64, err error)
- func (fh *WriteFileHandle) Stat() (os.FileInfo, error)
- func (fh *WriteFileHandle) String() string
- func (fh *WriteFileHandle) Sync() error
- func (fh *WriteFileHandle) Truncate(size int64) (err error)
- func (h WriteFileHandle) Unlock() error
- func (fh *WriteFileHandle) Write(p []byte) (n int, err error)
- func (fh *WriteFileHandle) WriteAt(p []byte, off int64) (n int, err error)
- func (fh *WriteFileHandle) WriteString(s string) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
var ( ENOENT = os.ErrNotExist EEXIST = os.ErrExist EPERM = os.ErrPermission EINVAL = os.ErrInvalid ECLOSED = os.ErrClosed )
Errors which have exact counterparts in os
Functions ¶
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir represents a directory entry
func (*Dir) AddVirtual ¶
AddVirtual adds a virtual object of name and size to the directory
This will be replaced with a real object when it is read back from the remote.
This is used to add directory entries while things are uploading
func (*Dir) DelVirtual ¶
DelVirtual removes an object from the directory listing
It marks it as removed until it has confirmed the object is missing when the directory entries are re-read in.
This is used to remove directory entries after things have been deleted or renamed but before we've had confirmation from the backend.
func (*Dir) ForgetAll ¶
ForgetAll forgets directory entries for this directory and any children.
It does not invalidate or clear the cache of the parent directory.
It returns true if the directory or any of its children had virtual entries so could not be forgotten. Children which didn't have virtual entries and children with virtual entries will be forgotten even if true is returned.
func (*Dir) ForgetPath ¶
ForgetPath clears the cache for itself and all subdirectories if they match the given path. The path is specified relative from the directory it is called from. The cache of the parent directory is marked as stale, but not cleared otherwise. It is not possible to traverse the directory tree upwards, i.e. you cannot clear the cache for the Dir's ancestors or siblings.
func (*Dir) ReadDirAll ¶
ReadDirAll reads the contents of the directory sorted
func (*Dir) RemoveName ¶
RemoveName removes the entry with the given name from the receiver, which must be a directory. The entry to be removed may correspond to a file (unlink) or to a directory (rmdir).
func (*Dir) SetModTime ¶
SetModTime sets the modTime for this dir
func (*Dir) SetSys ¶
func (d *Dir) SetSys(x interface{})
SetSys sets the underlying data source (can be nil) - satisfies Node interface
func (*Dir) Stat ¶
Stat looks up a specific entry in the receiver.
Stat should return a Node corresponding to the entry. If the name does not exist in the directory, Stat should return ENOENT.
Stat need not to handle the names "." and "..".
func (*Dir) Sys ¶
func (d *Dir) Sys() interface{}
Sys returns underlying data source (can be nil) - satisfies Node interface
type DirHandle ¶
type DirHandle struct {
// contains filtered or unexported fields
}
DirHandle represents an open directory
func (*DirHandle) Readdir ¶
Readdir reads the contents of the directory associated with file and returns a slice of up to n FileInfo values, as would be returned by Lstat, in directory order. Subsequent calls on the same file will yield further FileInfos.
If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF.
If n <= 0, Readdir returns all the FileInfo from the directory in a single slice. In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error.
func (*DirHandle) Readdirnames ¶
Readdirnames reads and returns a slice of names from the directory f.
If n > 0, Readdirnames returns at most n names. In this case, if Readdirnames returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF.
If n <= 0, Readdirnames returns all the names from the directory in a single slice. In this case, if Readdirnames succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdirnames returns the names read until that point and a non-nil error.
func (DirHandle) WriteString ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a file
func (*File) ModTime ¶
ModTime returns the modified time of the file
if NoModTime is set then it returns the mod time of the directory
func (*File) Open ¶
Open a file according to the flags provided
O_RDONLY open the file read-only. O_WRONLY open the file write-only. O_RDWR open the file read-write. O_APPEND append data to the file when writing. O_CREATE create a new file if none exists. O_EXCL used with O_CREATE, file must not exist O_SYNC open for synchronous I/O. O_TRUNC if possible, truncate file when opened
We ignore O_SYNC and O_EXCL
func (*File) SetModTime ¶
SetModTime sets the modtime for the file
if NoModTime is set then it does nothing
func (*File) SetSys ¶
func (f *File) SetSys(x interface{})
SetSys sets the underlying data source (can be nil) - satisfies Node interface
func (*File) Sys ¶
func (f *File) Sys() interface{}
Sys returns underlying data source (can be nil) - satisfies Node interface
type Handle ¶
type Handle interface { OsFiler // Additional methods useful for FUSE filesystems Flush() error Release() error Node() Node // Size() int64 Lock() error Unlock() error }
Handle is the interface satisfied by open files or directories. It is the methods on *os.File, plus a few more useful for FUSE filingsystems. Not all of them are supported.
type Node ¶
type Node interface { os.FileInfo IsFile() bool Inode() uint64 SetModTime(modTime time.Time) error Sync() error Remove() error RemoveAll() error DirEntry() fs.DirEntry VFS() *VFS Open(flags int) (Handle, error) Truncate(size int64) error Path() string SetSys(interface{}) }
Node represents either a directory (*Dir) or a file (*File)
type OsFiler ¶
type OsFiler interface { Chdir() error Chmod(mode os.FileMode) error Chown(uid, gid int) error Close() error Fd() uintptr Name() string Read(b []byte) (n int, err error) ReadAt(b []byte, off int64) (n int, err error) Readdir(n int) ([]os.FileInfo, error) Readdirnames(n int) (names []string, err error) Seek(offset int64, whence int) (ret int64, err error) Stat() (os.FileInfo, error) Sync() error Truncate(size int64) error Write(b []byte) (n int, err error) WriteAt(b []byte, off int64) (n int, err error) WriteString(s string) (n int, err error) }
OsFiler is the methods on *os.File
type RWFileHandle ¶
type RWFileHandle struct {
// contains filtered or unexported fields
}
RWFileHandle is a handle that can be open for read and write.
It will be open to a temporary file which, when closed, will be transferred to the remote.
func (*RWFileHandle) Chdir ¶
func (fh *RWFileHandle) Chdir() error
Chdir changes the current working directory to the file, which must be a directory.
func (*RWFileHandle) Chmod ¶
func (fh *RWFileHandle) Chmod(mode os.FileMode) error
Chmod changes the mode of the file to mode.
func (*RWFileHandle) Chown ¶
func (fh *RWFileHandle) Chown(uid, gid int) error
Chown changes the numeric uid and gid of the named file.
func (*RWFileHandle) Fd ¶
func (fh *RWFileHandle) Fd() uintptr
Fd returns the integer Unix file descriptor referencing the open file.
func (*RWFileHandle) Flush ¶
func (fh *RWFileHandle) Flush() error
Flush is called each time the file or directory is closed. Because there can be multiple file descriptors referring to a single opened file, Flush can be called multiple times.
func (*RWFileHandle) Lock ¶
func (fh *RWFileHandle) Lock() error
Lock performs Unix locking, not supported
func (*RWFileHandle) Name ¶
func (fh *RWFileHandle) Name() string
Name returns the name of the file from the underlying Object.
func (*RWFileHandle) Node ¶
func (fh *RWFileHandle) Node() Node
Node returns the Node associated with this - satisfies Noder interface
func (*RWFileHandle) Read ¶
func (fh *RWFileHandle) Read(b []byte) (n int, err error)
Read bytes from the file
func (*RWFileHandle) ReadAt ¶
func (fh *RWFileHandle) ReadAt(b []byte, off int64) (n int, err error)
ReadAt bytes from the file at off
func (*RWFileHandle) Readdir ¶
func (fh *RWFileHandle) Readdir(n int) ([]os.FileInfo, error)
Readdir reads the contents of the directory associated with file.
func (*RWFileHandle) Readdirnames ¶
func (fh *RWFileHandle) Readdirnames(n int) (names []string, err error)
Readdirnames reads the contents of the directory associated with file.
func (*RWFileHandle) Release ¶
func (fh *RWFileHandle) Release() error
Release is called when we are finished with the file handle
It isn't called directly from userspace so the error is ignored by the kernel
func (*RWFileHandle) Seek ¶
func (fh *RWFileHandle) Seek(offset int64, whence int) (ret int64, err error)
Seek to new file position
func (*RWFileHandle) Size ¶
func (fh *RWFileHandle) Size() int64
Size returns the size of the underlying file
func (*RWFileHandle) Stat ¶
func (fh *RWFileHandle) Stat() (os.FileInfo, error)
Stat returns info about the file
func (*RWFileHandle) String ¶
func (fh *RWFileHandle) String() string
String converts it to printable
func (*RWFileHandle) Sync ¶
func (fh *RWFileHandle) 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 (*RWFileHandle) Truncate ¶
func (fh *RWFileHandle) Truncate(size int64) (err error)
Truncate file to given size
func (*RWFileHandle) Unlock ¶
func (fh *RWFileHandle) Unlock() error
Unlock performs Unix unlocking, not supported
func (*RWFileHandle) Write ¶
func (fh *RWFileHandle) Write(b []byte) (n int, err error)
Write bytes to the file
func (*RWFileHandle) WriteAt ¶
func (fh *RWFileHandle) WriteAt(b []byte, off int64) (n int, err error)
WriteAt bytes to the file at off
func (*RWFileHandle) WriteString ¶
func (fh *RWFileHandle) WriteString(s string) (n int, err error)
WriteString a string to the file
type ReadFileHandle ¶
type ReadFileHandle struct {
// contains filtered or unexported fields
}
ReadFileHandle is an open for read file handle on a File
func (*ReadFileHandle) Flush ¶
func (fh *ReadFileHandle) Flush() error
Flush is called each time the file or directory is closed. Because there can be multiple file descriptors referring to a single opened file, Flush can be called multiple times.
func (*ReadFileHandle) Name ¶
func (fh *ReadFileHandle) Name() string
Name returns the name of the file from the underlying Object.
func (*ReadFileHandle) Node ¶
func (fh *ReadFileHandle) Node() Node
Node returns the Node associated with this - satisfies Noder interface
func (*ReadFileHandle) Read ¶
func (fh *ReadFileHandle) Read(p []byte) (n int, err error)
Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more.
When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.
Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.
Implementations of Read are discouraged from returning a zero byte count with a nil error, except when len(p) == 0. Callers should treat a return of 0 and nil as indicating that nothing happened; in particular it does not indicate EOF.
Implementations must not retain p.
func (*ReadFileHandle) ReadAt ¶
func (fh *ReadFileHandle) ReadAt(p []byte, off int64) (n int, err error)
ReadAt reads len(p) bytes into p starting at offset off in the underlying input source. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
When ReadAt returns n < len(p), it returns a non-nil error explaining why more bytes were not returned. In this respect, ReadAt is stricter than Read.
Even if ReadAt returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, ReadAt blocks until either all the data is available or an error occurs. In this respect ReadAt is different from Read.
If the n = len(p) bytes returned by ReadAt are at the end of the input source, ReadAt may return either err == EOF or err == nil.
If ReadAt is reading from an input source with a seek offset, ReadAt should not affect nor be affected by the underlying seek offset.
Clients of ReadAt can execute parallel ReadAt calls on the same input source.
Implementations must not retain p.
func (ReadFileHandle) Readdirnames ¶
func (*ReadFileHandle) Release ¶
func (fh *ReadFileHandle) Release() error
Release is called when we are finished with the file handle
It isn't called directly from userspace so the error is ignored by the kernel
func (*ReadFileHandle) Seek ¶
func (fh *ReadFileHandle) Seek(offset int64, whence int) (n int64, err error)
Seek the file - returns ESPIPE if seeking isn't possible
func (*ReadFileHandle) Size ¶
func (fh *ReadFileHandle) Size() int64
Size returns the size of the underlying file
func (*ReadFileHandle) Stat ¶
func (fh *ReadFileHandle) Stat() (os.FileInfo, error)
Stat returns info about the file
func (*ReadFileHandle) String ¶
func (fh *ReadFileHandle) String() string
String converts it to printable
func (ReadFileHandle) WriteString ¶
type VFS ¶
VFS represents the top level filing system
func (*VFS) AddVirtual ¶
AddVirtual adds the object (file or dir) to the directory cache
func (*VFS) Chtimes ¶
Chtimes changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions.
The underlying filesystem may truncate or round the values to a less precise time unit.
func (*VFS) Create ¶
Create creates the named file with mode 0666 (before umask), truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR.
func (*VFS) FlushDirCache ¶
func (vfs *VFS) FlushDirCache()
FlushDirCache empties the directory cache
func (*VFS) Mkdir ¶
Mkdir creates a new directory with the specified name and permission bits (before umask).
func (*VFS) MkdirAll ¶
MkdirAll creates a new directory with the specified name and permission bits (before umask) and all of its parent directories up to the root.
func (*VFS) Open ¶
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.
func (*VFS) ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.
func (*VFS) ReadFile ¶
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 (*VFS) SetCacheMode ¶
SetCacheMode change the cache mode
func (*VFS) Shutdown ¶
func (vfs *VFS) Shutdown()
Shutdown stops any background go-routines and removes the VFS from the active ache.
func (*VFS) Stat ¶
Stat finds the Node by path starting from the root
It is the equivalent of os.Stat - Node contains the os.FileInfo interface.
func (*VFS) StatParent ¶
StatParent finds the parent directory and the leaf name of a path
func (*VFS) Statfs ¶
Statfs returns into about the filing system if known
The values will be -1 if they aren't known
This information is cached for the DirCacheTime interval
func (*VFS) WaitForWriters ¶
WaitForWriters sleeps until all writers have finished or time.Duration has elapsed
type WriteFileHandle ¶
type WriteFileHandle struct {
// contains filtered or unexported fields
}
WriteFileHandle is an open for write handle on a File
func (*WriteFileHandle) Flush ¶
func (fh *WriteFileHandle) Flush() error
Flush is called on each close() of a file descriptor. So if a filesystem wants to return write errors in close() and the file has cached dirty data, this is a good place to write back data and return any errors. Since many applications ignore close() errors this is not always useful.
NOTE: The flush() method may be called more than once for each open(). This happens if more than one file descriptor refers to an opened file due to dup(), dup2() or fork() calls. It is not possible to determine if a flush is final, so each flush should be treated equally. Multiple write-flush sequences are relatively rare, so this shouldn't be a problem.
Filesystems shouldn't assume that flush will always be called after some writes, or that if will be called at all.
func (*WriteFileHandle) Name ¶
func (fh *WriteFileHandle) Name() string
Name returns the name of the file from the underlying Object.
func (*WriteFileHandle) Node ¶
func (fh *WriteFileHandle) Node() Node
Node returns the Node associated with this - satisfies Noder interface
func (*WriteFileHandle) Offset ¶
func (fh *WriteFileHandle) Offset() (offset int64)
Offset returns the offset of the file pointer
func (*WriteFileHandle) Read ¶
func (fh *WriteFileHandle) Read(p []byte) (n int, err error)
Read reads up to len(p) bytes into p.
func (*WriteFileHandle) ReadAt ¶
func (fh *WriteFileHandle) ReadAt(p []byte, off int64) (n int, err error)
ReadAt reads len(p) bytes into p starting at offset off in the underlying input source. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
func (WriteFileHandle) Readdirnames ¶
func (*WriteFileHandle) Release ¶
func (fh *WriteFileHandle) Release() error
Release is called when we are finished with the file handle
It isn't called directly from userspace so the error is ignored by the kernel
func (*WriteFileHandle) Stat ¶
func (fh *WriteFileHandle) Stat() (os.FileInfo, error)
Stat returns info about the file
func (*WriteFileHandle) String ¶
func (fh *WriteFileHandle) String() string
String converts it to printable
func (*WriteFileHandle) Sync ¶
func (fh *WriteFileHandle) 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 (*WriteFileHandle) Truncate ¶
func (fh *WriteFileHandle) Truncate(size int64) (err error)
Truncate file to given size
func (*WriteFileHandle) Write ¶
func (fh *WriteFileHandle) Write(p []byte) (n int, err error)
Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. Write must return a non-nil error if it returns n < len(p). Write must not modify the slice data, even temporarily.
Implementations must not retain p.
func (*WriteFileHandle) WriteAt ¶
func (fh *WriteFileHandle) WriteAt(p []byte, off int64) (n int, err error)
WriteAt writes len(p) bytes from p to the underlying data stream at offset off. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. WriteAt must return a non-nil error if it returns n < len(p).
If WriteAt is writing to a destination with a seek offset, WriteAt should not affect nor be affected by the underlying seek offset.
Clients of WriteAt can execute parallel WriteAt calls on the same destination if the ranges do not overlap.
Implementations must not retain p.
func (*WriteFileHandle) WriteString ¶
func (fh *WriteFileHandle) WriteString(s string) (n int, err error)
WriteString a string to the file
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Test the VFS to exhaustion, specifically looking for deadlocks
|
Test the VFS to exhaustion, specifically looking for deadlocks |
Package vfscache deals with caching of files locally for the VFS layer
|
Package vfscache deals with caching of files locally for the VFS layer |
downloaders
Package downloaders provides utilities for the VFS layer
|
Package downloaders provides utilities for the VFS layer |
writeback
Package writeback keeps track of the files which need to be written back to storage
|
Package writeback keeps track of the files which need to be written back to storage |
Package vfscommon provides utilities for VFS.
|
Package vfscommon provides utilities for VFS. |
Package vfsflags implements command line flags to set up a vfs
|
Package vfsflags implements command line flags to set up a vfs |
Package vfstest provides tests for VFS.
|
Package vfstest provides tests for VFS. |