Documentation ¶
Index ¶
- Constants
- Variables
- type File
- type FileSystem
- func (fs *FileSystem) Mkdir(p P, perm os.FileMode) (err error)
- func (fs *FileSystem) Open(p P) (*File, error)
- func (fs *FileSystem) OpenFile(p P, flag int, perm os.FileMode) (f *File, err error)
- func (fs *FileSystem) Remove(p P) (err error)
- func (fs *FileSystem) RemoveAll(p P) (err error)
- func (fs *FileSystem) Stat(p P) (fi os.FileInfo, err error)
- type K
- type P
Constants ¶
const ( //PathSeparator is used to join path into database keys. Bolt stores values in a bucket in byte-order, choosing a unicode code point all the way at the end allows us to make assumptions when we use a cursor to iterate over directory entries PathSeparator = "\uFFFF" //PathPrintSeparator is used instead of the character above to print a path PathPrintSeparator = "/" //RootBasename is returned when the root is asked for its basename RootBasename = PathSeparator )
Variables ¶
var ( //ErrNotDirectory is returned when a directory was expected ErrNotDirectory = errors.New("not a directory") //ErrNotEmptyDirectory tells us the directory was not empty ErrNotEmptyDirectory = errors.New("directory is not empty") )
var ( // ErrInvalidPath is returned when no valid filename can be created from path components ErrInvalidPath = errors.New("invalid path components") )
var ( //Root is a path with zero components: len(Root) = 0 Root = P{} )
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File provides an handler for IO, it is not safe for concurrent writing. It works with an internal cursor that can be written to and read from Dakony: - ReadFile(ctx context.Context, fi *FileInfo, bs []byte, offset int64) (int, error) - WriteFile(ctx context.Context, fi *FileInfo, bs []byte, offset int64) (int, error) - FlushFileBuffers(ctx context.Context, fi *FileInfo) error FUSE: - fs.HandleReader:
type ReadRequest struct { Header `json:"-"` Dir bool // is this Readdir? Handle HandleID Offset int64 Size int Flags ReadFlags LockOwner uint64 FileFlags OpenFlags }
- fs.HandleWriter - fs.HandleFlusher
func NewFile ¶
func NewFile(fs *FileSystem, p P) *File
NewFile sets up a file on filesystem 'fs' at path 'p'
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.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem holds file information
func NewFileSystem ¶
func NewFileSystem(id string, db *bolt.DB) (fs *FileSystem, err error)
NewFileSystem sets up a new file system in a bolt database with an unique id that allows multiple filesystems per database
func (*FileSystem) Mkdir ¶
func (fs *FileSystem) Mkdir(p P, perm os.FileMode) (err error)
Mkdir creates a new directory with the specified name and permission bits. If there is an error, it will be of type *PathError.
func (*FileSystem) Open ¶
func (fs *FileSystem) Open(p P) (*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 (*FileSystem) OpenFile ¶
OpenFile is the generalized open call. It opens the named file with specified flag (O_RDONLY etc.) and perm, (0666 etc.) 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 *PathError. Behaviour can be customized with the following flags:
O_RDONLY int = syscall.O_RDONLY // open the file read-only. O_WRONLY int = syscall.O_WRONLY // open the file write-only. O_RDWR int = syscall.O_RDWR // open the file read-write. O_APPEND int = syscall.O_APPEND // append data to the file when writing. O_SYNC int = syscall.O_SYNC // open for synchronous I/O. O_TRUNC int = syscall.O_TRUNC // if possible, truncate file when opened. O_CREATE int = syscall.O_CREATE // create a new file if none exists. O_EXCL int = syscall.O_EXCL // used with O_CREATE, file must not exist
func (*FileSystem) Remove ¶
func (fs *FileSystem) Remove(p P) (err error)
Remove removes the named file or directory. If there is an error, it will be of type *PathError.
func (*FileSystem) RemoveAll ¶
func (fs *FileSystem) RemoveAll(p P) (err 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).
type P ¶
type P []string
P describes a platform agnostic path on the file system and is stored as a slice of path components
func PathFromKey ¶
PathFromKey turns a database key into its Path representation
func (P) Parent ¶
Parent returns a path that refers to a parent, if the current path is the root the root is still returned