Documentation ¶
Overview ¶
Package boltfs provides a complete file system implementation for boltdb. This implementation includes support for sybmolic links and includes a file system walker that works just like `filepath.Walk`.
Index ¶
- type File
- func (f *File) Close() error
- func (f *File) Name() string
- func (f *File) Read(p []byte) (int, error)
- func (f *File) ReadAt(b []byte, off int64) (n int, err error)
- func (f *File) Readdir(n int) ([]os.FileInfo, error)
- func (f *File) Readdirnames(n int) ([]string, error)
- func (f *File) Seek(offset int64, whence int) (ret int64, err error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Truncate(size int64) error
- func (f *File) Write(p []byte) (int, error)
- func (f *File) WriteAt(b []byte, off int64) (n int, err error)
- func (f *File) WriteString(s string) (n int, err error)
- type FileSystem
- func (fs *FileSystem) Chdir(name string) error
- func (fs *FileSystem) Chmod(name string, mode os.FileMode) error
- func (fs *FileSystem) Chown(name string, uid, gid int) error
- func (fs *FileSystem) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (fs *FileSystem) Close() error
- func (fs *FileSystem) Copy(source, destination string) error
- func (fs *FileSystem) Create(name string) (absfs.File, error)
- func (fs *FileSystem) Getwd() (dir string, err error)
- func (fs *FileSystem) Lchown(name string, uid, gid int) error
- func (fs *FileSystem) ListSeparator() uint8
- func (fs *FileSystem) Lstat(name string) (os.FileInfo, error)
- func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error
- func (fs *FileSystem) MkdirAll(name string, perm os.FileMode) error
- func (fs *FileSystem) Open(name string) (absfs.File, error)
- func (fs *FileSystem) OpenFile(name string, flag int, perm os.FileMode) (absfs.File, error)
- func (fs *FileSystem) Readlink(name string) (string, error)
- func (fs *FileSystem) Remove(name string) error
- func (fs *FileSystem) RemoveAll(name string) error
- func (fs *FileSystem) Rename(oldpath, newpath string) error
- func (fs *FileSystem) Separator() uint8
- func (fs *FileSystem) SetTempdir(tempdir string)
- func (fs *FileSystem) SetUmask(umask os.FileMode)
- func (fs *FileSystem) Stat(name string) (os.FileInfo, error)
- func (fs *FileSystem) Symlink(source, destination string) error
- func (fs *FileSystem) TempDir() string
- func (fs *FileSystem) Truncate(name string, size int64) error
- func (fs *FileSystem) Umask() os.FileMode
- func (fs *FileSystem) Walk(root string, fn func(string, os.FileInfo, error) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File implements the absfs.File interface, providing a file interace for boltdb
func (*File) Close ¶
Close closes the File, rendering it unusable for I/O. On files that support SetDeadline, any pending I/O operations will be canceled and return immediately with an error.
func (*File) Read ¶
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 ¶
ReadAt reads len(b) bytes from the File starting at byte offset off. It returns the number of bytes read and the error, if any. ReadAt always returns a non-nil error when n < len(b). At end of file, that error is io.EOF.
func (*File) 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 (*File) 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 (*File) Seek ¶
Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any. The behavior of Seek on a file opened with O_APPEND is not specified.
func (*File) Stat ¶
Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError.
func (*File) Truncate ¶
Truncate changes the size of the named file. If the file is a symbolic link, it changes the size of the link's target. If there is an error, it will be of type *PathError.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem implements absfs.FileSystem for the boltdb packages `github.com/coreos/bbolt`.
func NewFS ¶
func NewFS(db *bolt.DB, bucketpath string) (*FileSystem, error)
NewFS creates a new FileSystem pointer in the convention of other `absfs`, implementations. It takes a bolt.DB pointer, and a bucket name to use as the storage location for the file system buckets. If `bucket` is an empty string file system buckets are created as top level buckets.
func Open ¶
func Open(path, bucketpath string) (*FileSystem, error)
Open takes an absolute or relative path to a `boltdb` file and an optionl bucket name to store boltfs buckets. If `bucket` is an empty string file system buckets are created as top level buckets. If the bolt database already exists it will be loaded, otherwise a new database is created with with default configuration.
func (*FileSystem) Chdir ¶
func (fs *FileSystem) Chdir(name string) error
Chdir - changes the current directory to the absolute or relative path provided by `Chdir`
func (*FileSystem) Chmod ¶
func (fs *FileSystem) Chmod(name string, mode os.FileMode) error
Chmod changes the mode of the named file to mode.
func (*FileSystem) Chown ¶
func (fs *FileSystem) Chown(name string, uid, gid int) error
Chown changes the owner and group ids of the named file
func (*FileSystem) Close ¶
func (fs *FileSystem) Close() error
Close waits for pending writes, then closes the database file.
func (*FileSystem) Copy ¶
func (fs *FileSystem) Copy(source, destination string) error
Copy is a convenience funciton that duplicates the `source` path to the `newpath`
func (*FileSystem) Create ¶
func (fs *FileSystem) Create(name string) (absfs.File, error)
Create is a convenance function that opens a file for reading and writting. If the file does not exist it is created, if it does then it is truncated.
func (*FileSystem) Getwd ¶
func (fs *FileSystem) Getwd() (dir string, err error)
Getwd returns the current working directory, the error value is always `nil`.
func (*FileSystem) Lchown ¶
func (fs *FileSystem) Lchown(name string, uid, gid int) error
Lchown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link itself. If there is an error, it will be of type *PathError.
On Windows, it always returns the syscall.EWINDOWS error, wrapped in *PathError.
func (*FileSystem) ListSeparator ¶
func (fs *FileSystem) ListSeparator() uint8
ListSeparator returns ":" as the seperator for this fileSystem
func (*FileSystem) Lstat ¶
func (fs *FileSystem) Lstat(name string) (os.FileInfo, error)
Lstat returns a FileInfo describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type *PathError.
func (*FileSystem) Mkdir ¶
func (fs *FileSystem) Mkdir(name string, perm os.FileMode) error
Mkdir creates a new directory with the specified name and permission bits (before umask). If there is an error, it will be of type *PathError.
func (*FileSystem) MkdirAll ¶
func (fs *FileSystem) MkdirAll(name string, perm os.FileMode) error
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
func (*FileSystem) Open ¶
func (fs *FileSystem) Open(name string) (absfs.File, error)
Open is a convenance function that opens a file in read only mode.
func (*FileSystem) OpenFile ¶
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.) and perm (before umask), if applicable. If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *os.PathError.
func (*FileSystem) Readlink ¶
func (fs *FileSystem) Readlink(name string) (string, error)
Readlink returns the destination of the named symbolic link. If there is an error, it will be of type *PathError.
func (*FileSystem) Remove ¶
func (fs *FileSystem) Remove(name string) error
Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func (*FileSystem) RemoveAll ¶
func (fs *FileSystem) RemoveAll(name string) error
RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).
func (*FileSystem) Rename ¶
func (fs *FileSystem) Rename(oldpath, newpath string) error
Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. If there is an error, it will be of type *LinkError.
func (*FileSystem) Separator ¶
func (fs *FileSystem) Separator() uint8
Separator returns "/" as the seperator for this FileSystem
func (*FileSystem) SetTempdir ¶
func (fs *FileSystem) SetTempdir(tempdir string)
SetTempdir sets the path to a temporary directory, but does not create the actual directories.
func (*FileSystem) SetUmask ¶
func (fs *FileSystem) SetUmask(umask os.FileMode)
SetUmask sets the current `umaks` value
func (*FileSystem) Stat ¶
func (fs *FileSystem) Stat(name string) (os.FileInfo, error)
Stat returns the FileInfo structure describing file. If there is an error, it will be of type *os.PathError.
func (*FileSystem) Symlink ¶
func (fs *FileSystem) Symlink(source, destination string) error
Symlink creates newname as a symbolic link to oldname. If there is an error, it will be of type *LinkError.
func (*FileSystem) TempDir ¶
func (fs *FileSystem) TempDir() string
TempDir returns the path to a temporary directory
func (*FileSystem) Truncate ¶
func (fs *FileSystem) Truncate(name string, size int64) error
Truncate changes the size of the file. It does not change the I/O offset. If there is an error, it will be of type *os.PathError.
func (*FileSystem) Umask ¶
func (fs *FileSystem) Umask() os.FileMode
Umask returns the current `umaks` value. A non zero `umask` will be masked with file and directory creation permissions
func (*FileSystem) Walk ¶
Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links.