Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDecompressor ¶
func RegisterDecompressor(method []byte, dcomp Decompressor)
RegisterDecompressor allows custom decompressors for a specified method ID.
Types ¶
type CryptoReadCloser ¶ added in v1.2.0
CryptoReadCloser adds a Password method to decompressors.
type Decompressor ¶
type Decompressor func([]byte, uint64, []io.ReadCloser) (io.ReadCloser, error)
Decompressor describes the function signature that decompression/decryption methods must implement to return a new instance of themselves. They are passed any property bytes, the size of the stream and a slice of at least one io.ReadCloser's providing the stream(s) of bytes.
type File ¶
type File struct { FileHeader // contains filtered or unexported fields }
A File is a single file in a 7-Zip archive. The file information is in the embedded FileHeader. The file content can be accessed by calling Open.
type FileHeader ¶
type FileHeader struct { Name string Created time.Time Accessed time.Time Modified time.Time Attributes uint32 CRC32 uint32 UncompressedSize uint64 // contains filtered or unexported fields }
FileHeader describes a file within a 7-zip file.
func (*FileHeader) FileInfo ¶
func (h *FileHeader) FileInfo() fs.FileInfo
FileInfo returns an fs.FileInfo for the FileHeader.
func (*FileHeader) Mode ¶
func (h *FileHeader) Mode() (mode fs.FileMode)
Mode returns the permission and mode bits for the FileHeader.
type ReadCloser ¶
type ReadCloser struct { Reader // contains filtered or unexported fields }
A ReadCloser is a Reader that must be closed when no longer needed.
func OpenReader ¶
func OpenReader(name string) (*ReadCloser, error)
OpenReader will open the 7-zip file specified by name and return a ReadCloser. If name has a ".001" suffix it is assumed there are multiple volumes and each sequential volume will be opened.
Example ¶
package main import ( "fmt" "path/filepath" "github.com/bodgit/sevenzip" ) func main() { r, err := sevenzip.OpenReader(filepath.Join("testdata", "multi.7z.001")) if err != nil { panic(err) } defer r.Close() for _, file := range r.File { fmt.Println(file.Name) } }
Output: 01 02 03 04 05 06 07 08 09 10
func OpenReaderWithPassword ¶
func OpenReaderWithPassword(name, password string) (*ReadCloser, error)
OpenReaderWithPassword will open the 7-zip file specified by name using password as the basis of the decryption key and return a ReadCloser. If name has a ".001" suffix it is assumed there are multiple volumes and each sequential volume will be opened.
func (*ReadCloser) Close ¶
func (rc *ReadCloser) Close() error
Close closes the 7-zip file or volumes, rendering them unusable for I/O.
func (*ReadCloser) Volumes ¶ added in v1.4.0
func (rc *ReadCloser) Volumes() []string
Volumes returns the list of volumes that have been opened as part of the current archive.
type Reader ¶
type Reader struct { File []*File // contains filtered or unexported fields }
A Reader serves content from a 7-Zip archive.
func NewReader ¶
NewReader returns a new Reader reading from r, which is assumed to have the given size in bytes.
func NewReaderWithPassword ¶
NewReaderWithPassword returns a new Reader reading from r using password as the basis of the decryption key, which is assumed to have the given size in bytes.