zipwalk

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

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

Go to latest
Published: Mar 3, 2019 License: MIT Imports: 11 Imported by: 0

README

zipwalk

like filepath.Walk except also walks through zipfiles

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipDir = filepath.SkipDir

SkipDir is used as a return value from WalkFuncs to indicate that the directory named in the call is to be skipped. It is not returned as an error by any function.

View Source
var SkipZip = fmt.Errorf("SkipZip")

SkipZip allows you to skip going into the zip file

Functions

func Stat

func Stat(path string) (os.FileInfo, error)

Stat will get the status of files embedded in a zip path e.g., file1.zip/file2.zip/a.txt

func Walk

func Walk(root string, walkFn WalkFunc) error

Walk walks the file tree rooted at root including through zip files, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The real files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Files insize zip files are walked in the order they appear in the zip file. Walk does not follow symbolic links.

Types

type WalkFunc

type WalkFunc func(path string, info os.FileInfo, reader io.Reader, err error) error

WalkFunc is the type of the function called for each file or directory visited by Walk. The path argument contains the argument to Walk as a prefix; that is, if Walk is called with "dir", which is a directory containing the file "a", the walk function will be called with argument "dir/a". The info argument is the os.FileInfo for the named path.

If there was a problem walking to the file or directory named by path, the incoming error will describe the problem and the function can decide how to handle that error (and Walk will not descend into that directory). If an error is returned, processing stops. The sole exception is when the function returns the special value SkipDir. If the function returns SkipDir when invoked on a directory, Walk skips the directory's contents entirely. If the function returns SkipDir when invoked on a non-directory file, Walk skips the remaining files in the containing directory.

type ZipFileInfo

type ZipFileInfo struct {
	os.FileInfo
	LastModified time.Time
}

ZipFileInfo is used to "mask" the modified time of the files extracted from the zip

func NewZipFileInfo

func NewZipFileInfo(lm time.Time, info os.FileInfo) ZipFileInfo

NewZipFileInfo creates an os.FileInfo from given last modified time and "parent" FileInfo

func (ZipFileInfo) ModTime

func (zfi ZipFileInfo) ModTime() time.Time

ModTime returns the date of the full parent zip file's modification time

Jump to

Keyboard shortcuts

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