Documentation ¶
Overview ¶
Package lzip implements reading and writing of lzip format compressed files. The package supports version 1 of the specification.
See the following for the specification:
- https://www.nongnu.org/lzip/manual/lzip_manual.html#File-format
- https://datatracker.ietf.org/doc/html/draft-diaz-lzip-09#section-2
Example ¶
const text = "The quick brown fox jumps over the lazy dog." opt := &lzip.WriterOptions{4 * 1024 * 1024} var buf bytes.Buffer writer, err := lzip.NewWriterOptions(&buf, opt) if err != nil { log.Fatal(err) } if _, err := io.WriteString(writer, text); err != nil { log.Fatal(err) } if err := writer.Close(); err != nil { log.Fatal(err) } reader, err := lzip.NewReader(&buf) if err != nil { log.Fatal(err) } if _, err := io.Copy(os.Stdout, reader); err != nil { log.Fatal(err) }
Output: The quick brown fox jumps over the lazy dog.
Index ¶
Examples ¶
Constants ¶
const ( // MinDictSize is the minimum dictionary size, which is 4 KiB. MinDictSize = lzma.MinDictCap // MaxDictSize is the maximum dictionary size, which is 512 MiB. MaxDictSize = 1 << 29 // DefaultDictSize is the default dictionary size, which is 8 MiB. DefaultDictSize = 1 << 23 )
const MaxMemberSize = 1 << 51
MaxMemberSize is the maximum member size, which is 2 PiB.
Variables ¶
var ErrInvalidMagic = errors.New("lzip: invalid magic number")
ErrInvalidMagic represents an error due to the magic number was invalid.
Functions ¶
This section is empty.
Types ¶
type DictSizeTooLargeError ¶
type DictSizeTooLargeError struct { // DictSize represents the obtained dictionary size. DictSize uint32 }
DictSizeTooLargeError represents an error due to the dictionary size was larger than 512 MiB.
func (*DictSizeTooLargeError) Error ¶
func (e *DictSizeTooLargeError) Error() string
Error returns a string representation of a DictSizeTooLargeError.
type DictSizeTooSmallError ¶
type DictSizeTooSmallError struct { // DictSize represents the obtained dictionary size. DictSize uint32 }
DictSizeTooSmallError represents an error due to the dictionary size was smaller than 4 KiB.
func (*DictSizeTooSmallError) Error ¶
func (e *DictSizeTooSmallError) Error() string
Error returns a string representation of a DictSizeTooSmallError.
type InvalidCRCError ¶
type InvalidCRCError struct { // CRC represents the obtained CRC. CRC uint32 }
InvalidCRCError represents an error due to a CRC of the original uncompressed data mismatched.
func (*InvalidCRCError) Error ¶
func (e *InvalidCRCError) Error() string
Error returns a string representation of an InvalidCRCError.
type InvalidDataSizeError ¶
type InvalidDataSizeError struct { // DataSize represents the obtained data size. DataSize uint64 }
InvalidDataSizeError represents an error due to the size of the original uncompressed data stored in the trailer and the actual size of it mismatched.
func (*InvalidDataSizeError) Error ¶
func (e *InvalidDataSizeError) Error() string
Error returns a string representation of an InvalidDataSizeError.
type InvalidMemberSizeError ¶
type InvalidMemberSizeError struct { // MemberSize represents the obtained member size. MemberSize uint64 }
InvalidMemberSizeError represents an error due to the total size of the member stored in the trailer and the actual total size of it mismatched.
func (*InvalidMemberSizeError) Error ¶
func (e *InvalidMemberSizeError) Error() string
Error returns a string representation of an InvalidMemberSizeError.
type MemberSizeTooLargeError ¶
type MemberSizeTooLargeError struct { // MemberSize represents the obtained member size. MemberSize uint64 }
MemberSizeTooLargeError represents an error due to the member size was larger than 2 PiB.
func (*MemberSizeTooLargeError) Error ¶
func (e *MemberSizeTooLargeError) Error() string
Error returns a string representation of a MemberSizeTooLargeError.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an io.Reader that can be read to retrieve uncompressed data from a lzip-format compressed file.
Example ¶
file, err := os.Open("testdata/fox.lz") if err != nil { log.Fatal(err) } defer file.Close() reader, err := lzip.NewReader(bufio.NewReader(file)) if err != nil { log.Print(err) return } if _, err := io.Copy(os.Stdout, reader); err != nil { log.Print(err) return }
Output: The quick brown fox jumps over the lazy dog.
type UnknownVersionError ¶
type UnknownVersionError struct { // Version represents the obtained version number. Version uint8 }
UnknownVersionError represents an error due to the version number stored in the header was not recognized by this package.
func (*UnknownVersionError) Error ¶
func (e *UnknownVersionError) Error() string
Error returns a string representation of an UnknownVersionError.
type UnsupportedVersionError ¶
type UnsupportedVersionError struct { // Version represents the obtained version number. Version uint8 }
UnsupportedVersionError represents an error due to the version number stored in the header indicated the lzip format which is not supported by this package.
func (*UnsupportedVersionError) Error ¶
func (e *UnsupportedVersionError) Error() string
Error returns a string representation of an UnsupportedVersionError.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an io.WriteCloser that can be written to retrieve a lzip-format compressed file from data.
Example ¶
const text = "The quick brown fox jumps over the lazy dog." var buf bytes.Buffer writer := lzip.NewWriter(&buf) if _, err := io.WriteString(writer, text); err != nil { log.Fatal(err) } if err := writer.Close(); err != nil { log.Fatal(err) }
Output:
func NewWriter ¶
NewWriter creates a new Writer writing the given writer.
This uses the default parameters.
func NewWriterOptions ¶
func NewWriterOptions(w io.Writer, opt *WriterOptions) (*Writer, error)
NewWriterOptions creates a new Writer writing the given writer.
This uses the given WriterOptions.
type WriterOptions ¶
type WriterOptions struct { // DictSize sets the dictionary size. DictSize uint32 }
WriterOptions configures Writer.
func (*WriterOptions) Verify ¶
func (o *WriterOptions) Verify() error
Verify checks if WriterOptions is valid.