ziptraverser

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package ziptraverser provides a transparent way of opening files by path name, where some of the directory names are actually zip archive files.

Usage:

Create an empty ziptraverser. Afterwards, ask it to open a file.

zm := ziptraverser.New()
f, err := zm.Get("path/to/foo.zip/bar.txt")
if err != nil {
	panic(err)
}
io.Copy(os.Stdout, f)

A Ziptraverser will cache open file pointers to zip archives it's encountered. If you call `Get`, ziptraverser expects you to call Close() on the resulting ReadCloser before calling `Get` again. This library is not thread-safe in any way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ZipTraverser

type ZipTraverser interface {
	// Exists tests if the given filename exists
	Exists(filename string) bool

	// Get opens the specified file name and provides a reader into its contents
	Get(filename string) (io.ReadCloser, error)

	// CopyTo copies the source file to a destination on the local file system
	CopyTo(filename, destination string) error

	// Close cleans up any open files in use
	Close()
}

A ZipTraverser provides a transparent way of opening files by path name, where some of the directory names are actually zip archive files.

func New

func New() ZipTraverser

New instantiates a new ZipTraverser

Jump to

Keyboard shortcuts

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