Documentation ¶
Index ¶
- Constants
- Variables
- func ReadAttributeVector(r io.Reader, numFiles int) ([]uint32, error)
- func ReadBoolVector(r io.Reader, length int) ([]bool, int, error)
- func ReadByte(r io.Reader) (byte, error)
- func ReadByteExpect(r io.Reader, val byte) error
- func ReadDateTimeVector(r io.Reader, numFiles int) ([]time.Time, error)
- func ReadDigests(r io.Reader, length int) ([]uint32, error)
- func ReadNumber(r io.Reader) (uint64, error)
- func ReadNumberInt(r io.Reader) (int, error)
- func ReadNumberVector(r io.Reader, numFiles int) ([]*int64, error)
- func ReadOptionalBoolVector(r io.Reader, length int) ([]bool, int, error)
- func ReadPackedStreamsForHeaders(r *io.LimitedReader) (header *Header, encodedHeader *StreamsInfo, err error)
- func ReadUint32(r io.Reader) (uint32, error)
- func ReadUint64(r io.Reader) (uint64, error)
- type BindPairsInfo
- type CoderInfo
- type FileInfo
- type Folder
- type Header
- type PackInfo
- type SignatureHeader
- type StreamsInfo
- type SubStreamsInfo
- type UnpackInfo
Constants ¶
const ( // MaxInOutStreams is the maximum allowed stream inputs/outputs into/out // of a coder. MaxInOutStreams = 4 // MaxPropertyDataSize is the size in bytes supported for coder property data. MaxPropertyDataSize = 128 // MaxCodersInFolder is the maximum number of coders allowed to be // specified in a folder. MaxCodersInFolder = 4 // MaxPackedStreamsInFolder is the maximum number of packed streams allowed // to be in a folder. MaxPackedStreamsInFolder = 4 )
const ( // SignatureHeaderSize SignatureHeader size is the size of the signature header. SignatureHeaderSize = 32 // MaxHeaderSize is the maximum header size. MaxHeaderSize = int64(1 << 62) // 4 exbibyte )
const MaxFolderCount = 1 << 30
MaxFolderCount count
const MaxNumber = 0x7FFFFFFF
MaxNumber max
Variables ¶
var ( // ErrInvalidStreamCount is the error returned when the input/output stream // count for a coder is <= 0 || > MaxInOutStreams. ErrInvalidStreamCount = errors.New("invalid in/out stream count") // ErrInvalidPropertyDataSize is the error returned when the property data // size is <= 0 || > MaxInOutStreams. ErrInvalidPropertyDataSize = errors.New("invalid property data size") // ErrInvalidCoderInFolderCount is the error returned when the number of // coders in a folder is <= 0 || > MaxCodersInFolder. ErrInvalidCoderInFolderCount = errors.New("invalid coder in folder count") // ErrInvalidPackedStreamsCount is the error returned when the number of // packed streams exceeds MaxPackedStreamsInFolder ErrInvalidPackedStreamsCount = errors.New("invalid packed streams count") )
var ( // MagicBytes is the magic bytes used in the 7z signature. MagicBytes = [6]byte{0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C} // ErrInvalidSignatureHeader is returned when signature header is invalid. ErrInvalidSignatureHeader = errors.New("invalid signature header") )
var ( // ErrUnexpectedPropertyID is returned when we read a property id that was // either unexpected, or we don't support. ErrUnexpectedPropertyID = errors.New("unexpected property id") // ErrAdditionalStreamsNotImplemented is returned for archives using // additional streams. These were apparently used in older versions of 7zip. ErrAdditionalStreamsNotImplemented = errors.New("additional streams are not implemented") // ErrArchivePropertiesNotImplemented is returned if archive properties // structure is found. So far, this hasn't been used in any verison of 7zip. ErrArchivePropertiesNotImplemented = errors.New("archive properties are not implemented") // ErrChecksumMismatch is returned when a CRC check fails. ErrChecksumMismatch = errors.New("checksum mismatch") // ErrPackInfoCRCsNotImplemented is returned if a CRC property id is // encountered whilst reading packinfo. ErrPackInfoCRCsNotImplemented = errors.New("packinfo crcs are not implemented") // ErrInvalidNumber is returned when a number read exceeds 0x7FFFFFFF ErrInvalidNumber = errors.New("invalid number") )
var ErrInvalidCountExceeded = errors.New("invalid folder count")
ErrInvalidCountExceeded is returned when the folder count is < 0 || > MaxFolderCount
var ErrInvalidFileCount = errors.New("invalid file count")
ErrInvalidFileCount is returned when the file count read from the stream exceeds the caller supplied maxFileCount.
Functions ¶
func ReadAttributeVector ¶
ReadAttributeVector reads a vector of uint32s.
func ReadBoolVector ¶
ReadBoolVector reads a vector of boolean values.
func ReadByteExpect ¶
ReadByteExpect reads a byte to be expected, errors if unexpected.
func ReadDateTimeVector ¶
ReadDateTimeVector reads a vector of datetime values.
func ReadDigests ¶
ReadDigests reads an array of uint32 CRCs.
func ReadNumber ¶
ReadNumber reads a 7z encoded uint64.
func ReadNumberInt ¶
ReadNumberInt is the same as ReadNumber, but cast to int.
func ReadNumberVector ¶
ReadNumberVector returns a vector of 7z encoded int64s.
func ReadOptionalBoolVector ¶
ReadOptionalBoolVector reads a vector of boolean values if they're available, otherwise it returns an array of booleans all being true.
func ReadPackedStreamsForHeaders ¶
func ReadPackedStreamsForHeaders(r *io.LimitedReader) (header *Header, encodedHeader *StreamsInfo, err error)
ReadPackedStreamsForHeaders reads either a header or encoded header structure.
Types ¶
type BindPairsInfo ¶
BindPairsInfo is a structure that binds the in and out indexes of a codec.
func ReadBindPairsInfo ¶
func ReadBindPairsInfo(r io.Reader) (*BindPairsInfo, error)
ReadBindPairsInfo reads a bindpairs info structure.
type FileInfo ¶
type FileInfo struct { Name string Attrib uint32 IsEmptyStream bool IsEmptyFile bool // Flag indicating a file should be removed upon extraction. IsAntiFile bool CreatedAt time.Time AccessedAt time.Time ModifiedAt time.Time }
FileInfo is a structure containing the information of an archived file.
type Folder ¶
type Folder struct { CoderInfo []*CoderInfo BindPairsInfo []*BindPairsInfo PackedIndices []int UnpackSizes []uint64 UnpackCRC uint32 }
Folder is a structure containing information on how a solid block was constructed.
func ReadFolder ¶
ReadFolder reads a folder structure.
func (*Folder) FindBindPairForInStream ¶
FindBindPairForInStream returns the index of a bindpair by an in index.
func (*Folder) FindBindPairForOutStream ¶
FindBindPairForOutStream returns the index of a bindpair by an out index.
func (*Folder) NumInStreamsTotal ¶
NumInStreamsTotal is the sum of inputs required by all codecs.
func (*Folder) NumOutStreamsTotal ¶
NumOutStreamsTotal is the sum of outputs required by all codecs.
func (*Folder) UnpackSize ¶
UnpackSize returns the final unpacked size of the folder.
type Header ¶
type Header struct { MainStreamsInfo *StreamsInfo FilesInfo []*FileInfo }
Header is structure containing file and stream information.
func ReadHeader ¶
func ReadHeader(r *io.LimitedReader) (*Header, error)
ReadHeader reads a header structure.
type SignatureHeader ¶
type SignatureHeader struct { Signature [6]byte ArchiveVersion struct { Major byte Minor byte } StartHeaderCRC uint32 StartHeader struct { NextHeaderOffset int64 NextHeaderSize int64 NextHeaderCRC uint32 } }
SignatureHeader is the structure found at the top of 7z files.
func ReadSignatureHeader ¶
func ReadSignatureHeader(r io.Reader) (*SignatureHeader, error)
ReadSignatureHeader reads the signature header.
type StreamsInfo ¶
type StreamsInfo struct { PackInfo *PackInfo UnpackInfo *UnpackInfo SubStreamsInfo *SubStreamsInfo }
StreamsInfo is a top-level structure of the 7z format.
func ReadStreamsInfo ¶
func ReadStreamsInfo(r io.Reader) (*StreamsInfo, error)
ReadStreamsInfo reads the streams info structure.
type SubStreamsInfo ¶
type SubStreamsInfo struct { NumUnpackStreamsInFolders []int UnpackSizes []uint64 Digests []uint32 }
SubStreamsInfo is a structure found within the StreamsInfo structure.
func ReadSubStreamsInfo ¶
func ReadSubStreamsInfo(r io.Reader, unpackInfo *UnpackInfo) (*SubStreamsInfo, error)
ReadSubStreamsInfo reads the substreams info structure.
type UnpackInfo ¶
type UnpackInfo struct {
Folders []*Folder
}
UnpackInfo is a structure containing folders.
func ReadUnpackInfo ¶
func ReadUnpackInfo(r io.Reader) (*UnpackInfo, error)
ReadUnpackInfo reads unpack info structures.