zip

package module
v0.0.0-...-4c6e5c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 8 Imported by: 0

README

zip

Build Status

🚧 Work in progress

Examples

See also: examples/main.go.

Compress
a, _ := zip.CreateArchive("test.zip")
defer a.Close()

a.Add(".", "test")

Optionally function function can be provided, to ignore specific files or directories.

a, _ := zip.CreateArchive("test.zip")
defer a.Close()

a.Add(".", "test", func(path string, sourcePath string) bool {

  // The file / directory will be ignored if `false` is returned
  if path == ".git" {
    fmt.Println("> Ignore:", path)
    return false
  }

  fmt.Println("> Add:   ", path)
  return true
})
List archive content
	a, _ := zip.OpenArchive("test.zip")
	defer a.Close()

	filePaths, _ := a.List()
	for _, f := range filePaths {
		fmt.Println(f)
	}

Todo

  • Extract archive

License

MIT © Josa Gesell

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	// contains filtered or unexported fields
}

Archive :

func CreateArchive

func CreateArchive(path string) (Archive, error)

CreateArchive creates a new zip archive at the given path.

func OpenArchive

func OpenArchive(path string) (Archive, error)

OpenArchive opens an existing zip archive.

func (*Archive) Add

func (a *Archive) Add(path, sourcePath string, progress ...ProgressFunc) error

Add adds a file or directory recursively at the given path. Use `/` to add something to the root of the archive.

func (*Archive) Close

func (a *Archive) Close()

Close closes open files.

func (*Archive) List

func (a *Archive) List() ([]string, error)

List returns an array of paths that the archive contains

type ProgressFunc

type ProgressFunc func(path string, sourcePath string) bool

ProgressFunc : Function to track progress and ignore specific files or directories.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL