Documentation ¶
Index ¶
- func Archive(sourceFolder, destinationZip string) error
- func Clean(path ...string) string
- func Extract(z *zip.Reader, zipDirectory, osDirectory string) error
- func Find(z *zip.Reader, path ...string) *zip.File
- func Join(path ...string) string
- func List(z *zip.Reader, w io.Writer)
- func Open(z *zip.Reader, path ...string) (io.ReadCloser, error)
- func Unarchive(zipFile, destination string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Archive ¶
Archive creates a zip from the contents of the sourceFolder at the destinationZip location.
func Clean ¶
Clean converts a path into a zip style path by replacing backslashes with forward-slashes and making the paths relative by removing leading "/" and "./".
func Extract ¶
Extracts the contents of the zipDirectory to the given OS osDirectory. This routine is overly strict and doesn't allow extracting _any_ files that contain "..".
Example ¶
tmp, err := ioutil.TempDir("", "ziptest") if err != nil { panic(err) } defer os.RemoveAll(tmp) zf := openZipfile() // extract all files/dirs under the path/to directory to tmp if err := Extract(zf, "path/to", tmp); err != nil { panic(err) } stream.Copy(stream.FromFile(tmp, "my", "file.txt"), stream.ToWriter(os.Stdout))
Output: Hello, world!
func Find ¶
Find returns a pointer to the file at the given path if it exists, otherwise nil.
Example ¶
zf := openZipfile() fmt.Println(Find(zf, "does", "not", "exist")) fmt.Println(Find(zf, "path/to/my", "file.txt").Name)
Output: <nil> path/to/my/file.txt
func List ¶
List writes a ls -la style listing of the zipfile to the given writer.
Example ¶
zf := openZipfile() List(zf, os.Stdout)
Output: MODE SIZE NAME -rw-rw-rw- 13 path/to/my/file.txt
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.