Documentation
¶
Index ¶
- Constants
- Variables
- type Header
- type Reader
- func (reader *Reader) Files() (files map[string]*Header, err error)
- func (reader *Reader) IsEncrypted() bool
- func (reader *Reader) Open(id int, transaction bool) error
- func (reader *Reader) Read(p []byte) (int, error)
- func (reader *Reader) ReadToFile(id int, filepath string) (err error)
- func (reader *Reader) SetPassword(password []byte) error
- type Writer
Constants ¶
View Source
const DefaultBlocksize = 8 * (1 << 10) // 8 KiB
DefaultBlocksize is the default size, in bytes, of a file chunk within the container.
Variables ¶
View Source
var ( // ErrWriterClosed is returned when Writer is used after closed. ErrWriterClosed = errors.New("writer closed") // ErrEmptyPassword is returned when a file have encryption enabled, but // no password was provided. ErrEmptyPassword = errors.New("encrypted marked file with no password provided") // ErrNotEncrypted is returned when a file isn't marked for encryption, but // a password was provided. ErrNotEncrypted = errors.New("password provided for unencrypted container") // ErrNoFilename is returned when is tried to create a file with no name. ErrNoFilename = errors.New("attempt to create file with no name") // ErrnoFileSelected is returned when reading a [Reader] with no file // selected previously. ErrNoFileSelected = errors.New("no file selected for reading") // ErrWrongPassword is returned when providing the wrong password to an // container with encrypted files. ErrWrongPassword = errors.New("wrong password") ErrPadding = errors.New("corrupted filename pad") )
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
// Id of the file in the container.
//
// The Id is only relevent for the [Reader],
// and thereby ignored by the [Writer].
Id int
// Name of the file.
Name string
// Size, in bytes, of the file, outside the container.
//
// As the [Header.Id] field, this field is too ignored
// by the [Writer].
Size int
// ModTime is the last time the file was modified,
// in UTC location.
ModTime time.Time
// Compression indicates what level of compression
// is applied to the file.
//
// The default value (0) indicates that no compression
// is applied.
//
// When reading the file this field must only be checked
// against the zero value (0).
Compression zstd.EncoderLevel
// Encryption indicates if file is encrypted or not.
Encryption bool
}
Header represents a file in the arc file.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) IsEncrypted ¶
func (*Reader) SetPassword ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements a arc container writer. Writer.WriteHeader initiates a new file with the providaded Header, and then the Writer can be used as an io.Writer.
func (*Writer) Close ¶
Close closes the container and flushes any remaining data of the current file to the container. Subsequently calls to Close or any other method will yield ErrWriterClosed
func (*Writer) Write ¶
Write writes the current file in the container, implementing the io.Writer interface.
Click to show internal directories.
Click to hide internal directories.