### Configure extraction options Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Functions to set various extraction parameters for RAR archives. ```go func BufferSize(size int) Option ``` ```go func FileSystem(fs fs.FS) Option ``` ```go func MaxDictionarySize(size int64) Option ``` ```go func Password(pass string) Option ``` -------------------------------- ### Define Option type Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Used for configuring optional archive extraction settings. ```go type Option func(*options) ``` -------------------------------- ### Calculate FileHeader mode Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Returns an fs.FileMode for the file based on its attributes. ```go func (f *FileHeader) Mode() fs.FileMode ``` -------------------------------- ### OpenFS Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Opens a RAR archive as an fs.FS implementation for filesystem-like access. ```APIDOC ## func OpenFS ### Description Opens a RAR archive and returns a RarFS instance which implements the fs.FS interface. ### Parameters #### Arguments - **name** (string) - Required - The path to the RAR archive file. - **opts** (...Option) - Optional - Optional archive extraction settings. ### Response - **RarFS** (*RarFS) - An object implementing fs.FS for accessing files in the archive. - **error** (error) - Returns an error if the archive cannot be opened. ``` -------------------------------- ### Define FileHeader structure Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Represents a single file within a RAR archive. ```go type FileHeader struct { Name string // file name using '/' as the directory separator IsDir bool // is a directory Solid bool // is a solid file Encrypted bool // file contents are encrypted HeaderEncrypted bool // file header is encrypted HostOS byte // Host OS the archive was created on Attributes int64 // Host OS specific file attributes PackedSize int64 // packed file size (or first block if the file spans volumes) UnPackedSize int64 // unpacked file size UnKnownSize bool // unpacked file size is not known ModificationTime time.Time // modification time (non-zero if set) CreationTime time.Time // creation time (non-zero if set) AccessTime time.Time // access time (non-zero if set) Version int // file version } ``` -------------------------------- ### Define HostOS Constants Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Constants representing different host operating systems for RAR file headers. ```go const ( HostOSUnknown = 0 HostOSMSDOS = 1 HostOSOS2 = 2 HostOSWindows = 3 HostOSUnix = 4 HostOSMacOS = 5 HostOSBeOS = 6 ) ``` -------------------------------- ### Check Options Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Functions for checking options during archive opening. ```APIDOC ## Check Options ### `OpenFSCheck(o *options) ` Performs checks on the provided options when opening a file system. - **o** (*options) - Required - The options struct to check. ### `SkipCheck(o *options)` Skips checks on the provided options. - **o** (*options) - Required - The options struct to skip checks on. ``` -------------------------------- ### Rardecode Package Overview Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Provides a high-level overview of the rardecode package and its capabilities. ```APIDOC ## rardecode Package A go package for reading RAR archives. ### Constants #### Host OS Types ```go const ( HostOSUnknown = 0 HostOSMSDOS = 1 HostOS2 = 2 HostOSWindows = 3 HostOSUnix = 4 HostOSMacOS = 5 HostOSBeOS = 6 ) ``` #### Default Max Dictionary Size ```go const ( DefaultMaxDictionarySize = 4 << 30 // default max dictionary size of 4GB ) ``` ``` -------------------------------- ### Manage ReadCloser Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Functions to open, close, and inspect volumes of a RAR archive. ```go func OpenReader(name string, opts ...Option) (*ReadCloser, error) ``` ```go func (rc *ReadCloser) Close() error ``` ```go func (rc *ReadCloser) Volumes() []string ``` -------------------------------- ### Interact with RarFS Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Methods for opening and reading files within a RarFS instance. ```go func OpenFS(name string, opts ...Option) (*RarFS, error) ``` ```go func (rfs *RarFS) Open(name string) (fs.File, error) ``` ```go func (rfs *RarFS) ReadDir(name string) ([]fs.DirEntry, error) ``` ```go func (rfs *RarFS) ReadFile(name string) ([]byte, error) ``` ```go func (rfs *RarFS) Stat(name string) (fs.FileInfo, error) ``` ```go func (rfs *RarFS) Sub(dir string) (fs.FS, error) ``` -------------------------------- ### Configure archive checking options Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Functions to control whether archive files are checked for integrity during operations. ```go func OpenFSCheck(o *options) ``` ```go func SkipCheck(o *options) ``` -------------------------------- ### Interact with Reader Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Methods for reading data from a RAR archive reader. ```go func NewReader(r io.Reader, opts ...Option) (*Reader, error) ``` ```go func (r *Reader) Next() (*FileHeader, error) ``` ```go func (r *Reader) Read(p []byte) (int, error) ``` ```go func (r *Reader) ReadByte() (byte, error) ``` ```go func (r *Reader) WriteTo(w io.Writer) (int64, error) ``` -------------------------------- ### Handle RAR archive files Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Types and methods for representing and accessing files within a RAR archive. ```go type File struct { FileHeader // contains filtered or unexported fields } ``` ```go func List(name string, opts ...Option) ([]*File, error) ``` ```go func (f *File) Open() (io.ReadCloser, error) ``` -------------------------------- ### NewReader Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Creates a Reader reading from an io.Reader for single volume archives. ```APIDOC ## func NewReader ### Description Creates a Reader reading from r. NewReader only supports single volume archives. ### Parameters #### Arguments - **r** (io.Reader) - Required - The input stream to read the RAR data from. - **opts** (...Option) - Optional - Optional archive extraction settings. ### Response - **Reader** (*Reader) - A reader providing sequential access to files. - **error** (error) - Returns an error if the reader cannot be initialized. ``` -------------------------------- ### Define Reader structure Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Provides sequential access to files in a RAR archive. ```go type Reader struct { // contains filtered or unexported fields } ``` -------------------------------- ### OpenReader Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Opens a RAR archive specified by the name and returns a ReadCloser for sequential access. ```APIDOC ## func OpenReader ### Description Opens a RAR archive specified by the name and returns a ReadCloser. ### Parameters #### Arguments - **name** (string) - Required - The path to the RAR archive file. - **opts** (...Option) - Optional - Optional archive extraction settings (e.g., Password, BufferSize). ### Response - **ReadCloser** (*ReadCloser) - A reader that allows closing of the rar archive. - **error** (error) - Returns an error if the archive cannot be opened. ``` -------------------------------- ### Reader and Options Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Provides functionality for creating readers and configuring options for RAR archive processing. ```APIDOC ## Reader and Options ### `NewReader(r io.Reader, opts ...Option) (*Reader, error)` Creates a new `Reader` for a RAR archive from an `io.Reader`. - **r** (io.Reader) - Required - The source reader for the RAR archive. - **opts** ([]Option) - Optional - Options to configure the reader. ### `(*Reader) Next() (*FileHeader, error)` Reads the next file header from the RAR archive. ### `(*Reader) Read(p []byte) (int, error)` Reads data from the current file in the RAR archive. ### `(*Reader) ReadByte() (byte, error)` Reads a single byte from the current file in the RAR archive. ### `(*Reader) WriteTo(w io.Writer) (int64, error)` Writes the content of the current file to a writer. ### `type Reader` Represents a reader for RAR archives. ### `Option` Interface An interface for configuring RAR archive reading options. #### `BufferSize(size int) Option` Sets the buffer size for reading. #### `FileSystem(fs fs.FS) Option` Sets a custom file system to use. #### `MaxDictionarySize(size int64) Option` Sets the maximum dictionary size for decompression. #### `Password(pass string) Option` Sets the password for encrypted RAR archives. ``` -------------------------------- ### Define Default Dictionary Size Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Constant defining the default maximum dictionary size for RAR decompression. ```go const ( DefaultMaxDictionarySize = 4 << 30 // default max dictionary size of 4GB ) ``` -------------------------------- ### File Operations Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Functions and types for listing and opening files within RAR archives. ```APIDOC ## File Operations ### `List(name string, opts ...Option) ([]*File, error)` Opens a RAR archive and lists its contents. - **name** (string) - Required - The path to the RAR archive. - **opts** ([]Option) - Optional - Options to configure the archive reading process. ### `(*File) Open() (io.ReadCloser, error)` Opens a specific file within the RAR archive for reading. ### `(*FileHeader) Mode() fs.FileMode` Returns the file mode of the `FileHeader`. ### `type File` Represents a file within a RAR archive. ### `type FileHeader` Represents the header information for a file in a RAR archive. ``` -------------------------------- ### Rardecode Options Functions Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Functions to control archive checking behavior during file operations. ```APIDOC ## Rardecode Options Functions ### Description These functions modify the behavior of archive operations, specifically concerning file integrity checks. ### Functions #### `OpenFSCheck` ##### Description Flags the archive files to be checked on `Open` or `List` operations. ##### Signature `func OpenFSCheck(o *options)` ##### Parameters * `o` (*options) - Pointer to options struct to modify. #### `SkipCheck` ##### Description Sets archive files checksum not to be checked during operations. ##### Signature `func SkipCheck(o *options)` ##### Parameters * `o` (*options) - Pointer to options struct to modify. ``` -------------------------------- ### Define ReadCloser structure Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 A Reader that supports closing the RAR archive. ```go type ReadCloser struct { Reader // contains filtered or unexported fields } ``` -------------------------------- ### RarFS Operations Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Provides functionality for treating RAR archives as a file system. ```APIDOC ## RarFS Operations ### `OpenFS(name string, opts ...Option) (*RarFS, error)` Opens a RAR archive and returns it as a `RarFS` (file system). - **name** (string) - Required - The path to the RAR archive. - **opts** ([]Option) - Optional - Options to configure the archive reading process. ### `(*RarFS) Open(name string) (fs.File, error)` Opens a file within the `RarFS`. ### `(*RarFS) ReadDir(name string) ([]fs.DirEntry, error)` Reads the contents of a directory within the `RarFS`. ### `(*RarFS) ReadFile(name string) ([]byte, error)` Reads the entire content of a file within the `RarFS`. ### `(*RarFS) Stat(name string) (fs.FileInfo, error)` Returns file information for a path within the `RarFS`. ### `(*RarFS) Sub(dir string) (fs.FS, error)` Returns a sub-file system rooted at the specified directory within the `RarFS`. ### `type RarFS` Represents a RAR archive as a file system. ``` -------------------------------- ### Define RarFS structure Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Implements the fs.FS interface for accessing files in a RAR archive. ```go type RarFS struct { // contains filtered or unexported fields } ``` -------------------------------- ### ReadCloser Operations Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Provides functionality for reading from RAR archives with a `ReadCloser` interface. ```APIDOC ## ReadCloser Operations ### `OpenReader(name string, opts ...Option) (*ReadCloser, error)` Opens a RAR archive and returns a `ReadCloser`. - **name** (string) - Required - The path to the RAR archive. - **opts** ([]Option) - Optional - Options to configure the archive reading process. ### `(*ReadCloser) Close() error` Closes the `ReadCloser` and releases any resources. ### `(*ReadCloser) Volumes() []string` Returns a list of volume names for multi-volume RAR archives. ### `type ReadCloser` Represents a `ReadCloser` for RAR archives. ``` -------------------------------- ### Rardecode File Type and Operations Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 Details about the `File` type and its associated methods for listing and accessing archive contents. ```APIDOC ## Rardecode File Type and Operations ### Description This section describes the `File` type, which represents a file within a RAR archive, and the functions to interact with archive contents. ### Types #### `File` struct ##### Description Represents a file in a RAR archive. ##### Fields * `FileHeader` (FileHeader) - Embedded FileHeader struct containing file metadata. ### Functions #### `List` function ##### Description Returns a list of `File` objects in the RAR archive specified by the given name. ##### Signature `func List(name string, opts ...Option) ([]*File, error)` ##### Parameters * `name` (string) - The path to the RAR archive file. * `opts` (...Option) - Optional configuration options for listing. ##### Returns * `[]*File` - A slice of pointers to `File` objects representing the archive contents. * `error` - An error if the listing operation fails. #### `(*File) Open` method ##### Description Opens and returns an `io.ReadCloser` for the `File`'s contents. Note: This method is not supported for Solid files, as their content depends on the decoding of preceding files. Use `OpenReader` and `Next` for Solid file contents instead. ##### Signature `func (f *File) Open() (io.ReadCloser, error)` ##### Returns * `io.ReadCloser` - An interface for reading the file's content. * `error` - An error if opening the file fails or is not supported. ``` -------------------------------- ### Rardecode Error Variables Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 This section lists the various error variables defined within the rardecode package, indicating potential issues during archive processing. ```APIDOC ## Rardecode Error Variables ### Description These variables represent specific error conditions encountered during RAR archive operations. ### Error List * `ErrCorruptBlockHeader`: Indicates a corrupted block header. * `ErrCorruptFileHeader`: Indicates a corrupted file header. * `ErrBadHeaderCRC`: Indicates an invalid CRC checksum for a header. * `ErrUnknownDecoder`: Indicates an unknown decoder version. * `ErrDecoderOutOfData`: Indicates the decoder expected more data than available. * `ErrArchiveEncrypted`: Indicates the archive is encrypted and requires a password. * `ErrArchivedFileEncrypted`: Indicates archived files are encrypted and require a password. * `ErrMultiVolume`: Indicates the archive is multi-volume and continues in the next file. * `ErrBadPassword`: Indicates an incorrect password was provided. * `ErrCorruptEncryptData`: Indicates corrupt encryption data. * `ErrUnknownEncryptMethod`: Indicates an unknown encryption method. * `ErrPlatformIntSize`: Indicates the platform's integer size is too small. * `ErrDictionaryTooLarge`: Indicates the decode dictionary is too large. * `ErrBadVolumeNumber`: Indicates an invalid volume number. * `ErrNoArchiveBlock`: Indicates a missing archive block. * `ErrNoSig`: Indicates the RAR signature was not found. * `ErrNegativeRead`: Indicates a negative read operation from the reader. * `ErrUnknownFilter`: Indicates an unknown V5 filter. * `ErrCorruptDecodeHeader`: Indicates a corrupted decode header. * `ErrTooManyFilters`: Indicates too many filters were specified. * `ErrInvalidFilter`: Indicates an invalid filter was specified. * `ErrMultipleDecoders`: Indicates multiple decoders in a single archive are not supported. * `ErrHuffDecodeFailed`: Indicates Huffman decoding failed. * `ErrInvalidLengthTable`: Indicates an invalid Huffman code length table. * `ErrShortFile`: Indicates the decoded file is too short. * `ErrInvalidFileBlock`: Indicates an invalid file block. * `ErrUnexpectedArcEnd`: Indicates an unexpected end of the archive. * `ErrBadFileChecksum`: Indicates a bad file checksum. * `ErrSolidOpen`: Indicates that `Open` is not supported on Solid files. * `ErrUnknownVersion`: Indicates an unknown archive version. * `ErrVerMismatch`: Indicates a volume version mismatch. * `ErrArchiveNameEmpty`: Indicates the archive name is empty. * `ErrFileNameRequired`: Indicates a filename is required for a multi-volume archive. * `ErrInvalidHeaderOff`: Indicates an invalid file header offset. * `ErrCorruptPPM`: Indicates corrupt PPM data. * `ErrInvalidVMInstruction`: Indicates an invalid VM instruction. * `ErrUnsupportedDecoder`: Indicates an unsupported decoder version. ``` -------------------------------- ### Define rardecode error variables Source: https://pkg.go.dev/github.com/nwaples/rardecode/v2 A collection of error variables used to signal specific failure states during RAR archive processing. ```go var ( ErrCorruptBlockHeader = errors.New("rardecode: corrupt block header") ErrCorruptFileHeader = errors.New("rardecode: corrupt file header") ErrBadHeaderCRC = errors.New("rardecode: bad header crc") ErrUnknownDecoder = errors.New("rardecode: unknown decoder version") ErrDecoderOutOfData = errors.New("rardecode: decoder expected more data than is in packed file") ErrArchiveEncrypted = errors.New("rardecode: archive encrypted, password required") ErrArchivedFileEncrypted = errors.New("rardecode: archived files encrypted, password required") ErrMultiVolume = errors.New("rardecode: multi-volume archive continues in next file") ) ``` ```go var ( ErrBadPassword = errors.New("rardecode: incorrect password") ErrCorruptEncryptData = errors.New("rardecode: corrupt encryption data") ErrUnknownEncryptMethod = errors.New("rardecode: unknown encryption method") ErrPlatformIntSize = errors.New("rardecode: platform integer size too small") ErrDictionaryTooLarge = errors.New("rardecode: decode dictionary too large") ErrBadVolumeNumber = errors.New("rardecode: bad volume number") ErrNoArchiveBlock = errors.New("rardecode: missing archive block") ) ``` ```go var ( ErrNoSig = errors.New("rardecode: RAR signature not found") ErrNegativeRead = errors.New("rardecode: negative read from Reader") ) ``` ```go var ( ErrUnknownFilter = errors.New("rardecode: unknown V5 filter") ErrCorruptDecodeHeader = errors.New("rardecode: corrupt decode header") ) ``` ```go var ( ErrTooManyFilters = errors.New("rardecode: too many filters") ErrInvalidFilter = errors.New("rardecode: invalid filter") ErrMultipleDecoders = errors.New("rardecode: multiple decoders in a single archive not supported") ) ``` ```go var ( ErrHuffDecodeFailed = errors.New("rardecode: huffman decode failed") ErrInvalidLengthTable = errors.New("rardecode: invalid huffman code length table") ) ``` ```go var ( ErrShortFile = errors.New("rardecode: decoded file too short") ErrInvalidFileBlock = errors.New("rardecode: invalid file block") ErrUnexpectedArcEnd = errors.New("rardecode: unexpected end of archive") ErrBadFileChecksum = errors.New("rardecode: bad file checksum") ErrSolidOpen = errors.New("rardecode: solid files don't support Open") ErrUnknownVersion = errors.New("rardecode: unknown archive version") ) ``` ```go var ( ErrVerMismatch = errors.New("rardecode: volume version mistmatch") ErrArchiveNameEmpty = errors.New("rardecode: archive name empty") ErrFileNameRequired = errors.New("rardecode: filename required for multi volume archive") ErrInvalidHeaderOff = errors.New("rardecode: invalid filed header offset") ) ``` ```go var ( ErrCorruptPPM = errors.New("rardecode: corrupt ppm data") ) ``` ```go var ( ErrInvalidVMInstruction = errors.New("rardecode: invalid vm instruction") ) ``` ```go var ( ErrUnsupportedDecoder = errors.New("rardecode: unsupported decoder version") ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.