Documentation ¶
Index ¶
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 ( //ErrNotImplemented is returned when a piece of functionality is not yet implemented ErrNotImplemented = errors.New("not implemented") // ErrInvalidPath is returned when no valid filename can be created from path components ErrInvalidPath = errors.New("invalid path components") )
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 ( //ErrSerialize is returned when we couldnt serialize ErrSerialize = errors.New("failed to serialize") //ErrDeserialize is returned when we couldnt deserialize ErrDeserialize = errors.New("failed to deserialize") )
var ( //ChunkPtrSeparator separates a node key from a chunk offset ChunkPtrSeparator = []byte(":") //ChildPtrSeparator separates a node key from a child name ChildPtrSeparator = []byte("/") )
var ( //NodeBucketName is the name of the bucket that will hold all nodes NodeBucketName = []byte("nodes") )
var ( //Root is a path with zero components: len(Root) = 0 Root = P{} )
var ( //ZeroKey is an content key with only 0x00 bytes ZeroKey = K{} )
Functions ¶
This section is empty.
Types ¶
type ChunkBuf ¶
type ChunkBuf struct {
// contains filtered or unexported fields
}
A ChunkBuf provides a malleable in-memory slice of chunks
func NewChunkBuf ¶
NewChunkBuf creates a chunked file interface
func (*ChunkBuf) Seek ¶
Seek will moves the current position to absolute position 'pos', in doing so it flushes currently buffered data from the chunker into a new chunk by closing the underlying writer. A new writer is started and the chunker is reset.
func (*ChunkBuf) Write ¶
Write will push bytes into the chunker, the chunker may buffer bytes util it has reached it maxed size, this buffer if flushed or the writer is closed. Writing takes place at the current file offset, and the file offset is incremented by the number of bytes actually written.
type File ¶
type File struct { Pw io.WriteCloser // contains filtered or unexported fields }
File represents a handle for writing and reading
func NewFile ¶
func NewFile(fs *FileSystem, nodeID uint64) *File
NewFile creates an interface for writing and reading byte chunks through a traditional file interface
func (*File) Read ¶
Read reads up to len(b) bytes from the File. It returns the number of bytes read and an error, if any. EOF is signaled by a zero count with err set to io.EOF.
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.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem provides a filesystem abstraction on top of Bolt db
func New ¶
func New(db *bolt.DB) (fs *FileSystem, err error)
New creates a simple filesystem on the provided 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) 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
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 (P) Parent ¶
Parent returns a path that refers to a parent, if the current path is the root the root is still returned