Documentation ¶
Overview ¶
raa is a file container, similar to tar or zip, focused on allowing constant-time random file access with linear memory consumption increase.
The library implements a very similar API to the go os package, allowing full control over,and low level acces to the contained files. raa is based on boltdb, a low-level key/value database for Go.
Index ¶
- Constants
- Variables
- func AddDirectory(a *Archive, from, to string, recursive bool) (int, error)
- func AddFile(a *Archive, from, to string) (int64, error)
- func AddGlob(a *Archive, pattern, to string, recursive bool) (int, error)
- func AddTarContent(a *Archive, file io.Reader, to string) (int, error)
- type Archive
- func (a *Archive) Chdir(dir string) error
- func (a *Archive) Chmod(name string, mode os.FileMode) error
- func (a *Archive) Chown(name string, uid, gid int) error
- func (a *Archive) Close() error
- func (a *Archive) Create(name string) (file *File, err error)
- func (a *Archive) Find(matcher func(string) bool) []string
- func (a *Archive) Getwd() (dir string, err error)
- func (a *Archive) Open(name string) (file *File, err error)
- func (a *Archive) OpenFile(name string, flag int, perm os.FileMode) (file *File, err error)
- func (a *Archive) Path() string
- func (a *Archive) Remove(name string) error
- func (a *Archive) RemoveAll(path string) error
- func (a *Archive) Rename(oldpath, newpath string) error
- func (a *Archive) Stat(name string) (os.FileInfo, error)
- func (a *Archive) Truncate(name string, size int64) error
- type File
- func (f *File) Bytes() []byte
- func (f *File) Chdir() error
- func (f *File) Chmod(mode os.FileMode) error
- func (f *File) Chown(uid, gid int) error
- func (f *File) Close() error
- func (f *File) Name() string
- func (f *File) Read(b []byte) (int, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) String() string
- func (f *File) Sync() error
- func (f *File) Truncate(size int64) error
- func (f *File) Write(b []byte) (int, error)
- func (f *File) WriteString(s string) (int, error)
- type FileInfo
- type Inode
Constants ¶
const ( InodeVersion int32 = 1 InodeLength int32 = 64 )
const BlockPattern = "block.%d"
const DefaultBlockSize int32 = 10485760
Variables ¶
var ( NotDirectoryErr = errors.New("not a directory") ClosedFileErr = errors.New("cannot read/write on a closed file") NonReadableErr = errors.New("cannot read from a O_WRONLY file") NonWritableErr = errors.New("cannot write from on a not O_WRONLY or O_RDWR file") )
var ( InodeSignature = []byte{'R', 'A', 'A'} WrongInodeSignature = errors.New("Wrong Inode signature") )
var BlockInode = []byte("block.inode")
Functions ¶
func AddDirectory ¶
AddFile adds a OS directory to a Volume, returns the number of files written
Types ¶
type Archive ¶ added in v1.2.0
type Archive struct {
// contains filtered or unexported fields
}
func CreateArchive ¶ added in v1.2.0
CreateArchive create an archive raa file
func OpenArchive ¶ added in v1.2.0
OpenArchive open an archive raa file
func (*Archive) Chdir ¶ added in v1.2.0
Chdir changes the current working directory to the named directory.
func (*Archive) Chmod ¶ added in v1.2.0
Chmod changes the mode of the file to mode. If there is an error, it will be of type *PathError.
func (*Archive) Chown ¶ added in v1.2.0
Chown changes the numeric uid and gid of the named file. If there is an error, it will be of type *PathError.
func (*Archive) Create ¶ added in v1.2.0
Create creates the named file 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. If there is an error, it will be of type *PathError.
func (*Archive) Find ¶ added in v1.2.0
Find return the names of the files matching with the function matcher
func (*Archive) Getwd ¶ added in v1.2.0
Getwd returns a rooted path name corresponding to the current directory.
func (*Archive) Open ¶ added in v1.2.0
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 (*Archive) OpenFile ¶ added in v1.2.0
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, (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.
func (*Archive) Remove ¶ added in v1.2.0
Remove removes the named file or directory. If there is an error, it will be of type *PathError.
func (*Archive) RemoveAll ¶ added in v1.2.0
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 File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) Chdir ¶
Chdir changes the current working directory to the file, which must be a directory. If there is an error, it will be of type *PathError.
func (*File) Close ¶
Close closes the File, rendering it unusable for I/O. It returns an error, if any.
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
type Inode ¶
type Inode struct { Id uint64 BlockSize int32 Mode os.FileMode UserId uint64 GroupId uint64 Size int64 ModifcatedAt time.Time CreatedAt time.Time }
func (*Inode) Read ¶
Read reads from a reader the byte representation of Inode and fills up the Inode
func (*Inode) Write ¶
Write writes the byte representation of Inode
Inode byte representation on LittleEndian have the following format: - 4-byte signature: The signature is: {'R', 'A', 'A'} - 4-byte lenght of the header, not includes the signature len - 4-byte version number - 8-byte inode id - 4-byte block size - 4-byte file mode - 8-byte user id - 8-byte group id - 8-byte file size - 8-byte modification timestamp - 8-byte creation timestamp