Categorygithub.com/Defacto2/archive
modulepackage
1.0.9
Repository: https://github.com/defacto2/archive.git
Documentation: pkg.go.dev

# README

Defacto2 / archive

Go Reference Go Report Card

The archive package provides compressed and stored archive file extraction and content listing functions. See the reference documentation for additional usage and examples.

Usage

In your Go project, import the releaser library.

go get github.com/Defacto2/archive

Use the functions.

import "github.com/Defacto2/archive"

func main() {
    // Extract all files from an archive.
    if err := archive.Extract("path/to/archive.zip", "path/to/extract"); err != nil {
        fmt.Println(err)
    }

    // Extract a specific files from an archive.
    x := archive.Extractor{
        Source: "path/to/archive.zip",
        Destination: "path/to/extract",
    }
    if err := x.Extract("file1.txt", "file2.txt"); err != nil {
        fmt.Println(err)
    }

    // Extract all files to a temporary directory.
    path, err := archive.ExtractSource("path/to/archive.zip", "tempsubdir")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println("Extracted to:", path)

    // List the contents of an archive.
    files, err := archive.List("path/to/archive.zip", "archive.zip")
    if err != nil {
        fmt.Println(err)
    }
    for _, f := range files {
        fmt.Println(f)
    }

    // Search for a possible readme file within the list of files.
    name := archive.Readme("archive.zip", cont.Files)
    fmt.Println(name)

    // Compress a file into a new archive.
    if _, err := rezip.Compress("file1.txt", "path/to/new.zip"); err != nil {
        fmt.Println(err)
    }
    // Compress a directory into a new archive.
    if _, err = rezip.CompressDir("path/to/directory", "path/to/new.zip"); err != nil {
        fmt.Println(err)
    }
}

# Packages

No description provided by the author
Package pkzip provides constants and functions for working with PKZip files to determine the compression methods used.
Package rezip provides compression for files and directories to create zip archives using the universal Store and Deflate compression methods.

# Functions

ExtractAll extracts all files from the src archive file to the destination directory.
ExtractSource extracts the source file into a temporary directory.
List returns the files within an rar, tar, lha, or zip archive.
MagicExt uses the Linux [file] program to determine the src archive file type.
Readme returns the best matching scene text README or NFO file from a collection of files.

# Constants

Lvl1 is the highest usability.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Lvl9 is the least usable.
TimeoutDefunct is the maximum time allowed for the defunct file extraction.
TimeoutExtract is the maximum time allowed for the archive extraction.
TimeoutLookup is the maximum time allowed for the program list content.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Content are the result of using system programs to read the file archives.
Extractor uses system archiver programs to extract the targets from the src file archive.

# Type aliases

Finds are a collection of matched filenames and their usability ranking.
Usability of search, filename pattern matches.