archiver

package module
v0.0.0-...-cfe4802 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2013 License: MIT Imports: 8 Imported by: 0

README

archiver

Go library for working with tar.gz, tar.bz2, zip... archives

Documentation

Overview

Package archiver provides an easy way of accessing files inside archives such as tar.gz.

Package archiver provides an easy way of accessing files inside archives such as tar.gz.

Example

package main

import "fmt"
import "os"
import "github.com/erggo/archiver"

func main() {
	f, e := os.Open("archive.tar.bz2")
	if e != nil {
		fmt.Printf("%s \n", e)
		return
	}
	tar := archiver.NewTarBz2(f)
	info, e := tar.GetFile("file.xml")
	if e != nil {
		fmt.Printf("%s \n", e)
		return
	}
	fmt.Printf("%s", info)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive interface {
	WalkAllWithContent(walkFn WalkFunc) error
	WalkWithContent(root string, walkFn WalkFunc) error
	GetFile(path string) (*bytes.Buffer, error)
}

Archive is a generic interface representing any archive. Supported suffixes right now are: .tgz .tar.gz .tbz, .tbz2 & .tb2 .tar.bz2 TODO suffixes: .taz .tar.Z .tlz .tar.lz & .tar.lzma .txz .tar.xz .zip .rar ???

func NewTarBz2

func NewTarBz2(path io.Reader) Archive

NewTarBz2 is a contructor that takes a file of type .tbz, .tbz2, .tb2 or .tar.bz2 and returns an initialised archive.

func NewTarGz

func NewTarGz(path io.Reader) (Archive, error)

NewTarGz is a contructor that takes a file of type .tgz or .tar.gz and returns an initialised archive.

type WalkFunc

type WalkFunc func(path string, info os.FileInfo, content bytes.Buffer, err error) error

WalkFunc is a function type for interfacing with client code.

Jump to

Keyboard shortcuts

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