zippkg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: AGPL-3.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ContentTypesFilename = "[Content_Types].xml"
	BaseRelsFilename     = "_rels/.rels"
	AppPropsFilename     = "docProps/app.xml"
	CorePropsFilename    = "docProps/core.xml"
)

Common filenames used in zip packages.

View Source
const XMLHeader = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>` + "\n"

XMLHeader is a header that MarshalXML uses to prefix the XML files it creates.

Variables

This section is empty.

Functions

func AddFileFromDisk

func AddFileFromDisk(z *zip.Writer, zipPath, diskPath string) error

AddFileFromDisk reads a file from disk and adds it at a given path to a zip file.

func Decode

func Decode(f *zip.File, dest interface{}) error

Decode unmarshals the content of a *zip.File as XML to a given destination.

func DecodeFromMap

func DecodeFromMap(files []*zip.File, decMap map[string]interface{}) error

DecodeFromMap iterates over a slice of *zip.File, decoding the entries in decMap with a matching filename.

func ExtractToDiskTmp

func ExtractToDiskTmp(f *zip.File, path string) (string, error)

ExtractToDiskTmp extracts a zip file to a temporary file in a given path, returning the name of the file.

func MarshalXML

func MarshalXML(z *zip.Writer, filename string, v interface{}) error

MarshalXML creates a file inside of a zip and marshals an object as xml, prefixing it with a standard XML header.

func RelationsPathFor

func RelationsPathFor(path string) string

RelationsPathFor returns the relations path for a given filename.

Types

type SelfClosingWriter

type SelfClosingWriter struct {
	W io.Writer
}

SelfClosingWriter wraps a writer and replaces XML tags of the type <foo></foo> with <foo/>

func (SelfClosingWriter) Write

func (s SelfClosingWriter) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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