metalinks

package module
v0.0.0-...-3f109bc Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2016 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeMd5

func ComputeMd5(filePath string) ([]byte, error)

func ComputeSha1

func ComputeSha1(filePath string) ([]byte, error)

func ComputeSha256

func ComputeSha256(filePath string) ([]byte, error)

func ComputeSha512

func ComputeSha512(filePath string) ([]byte, error)

Types

type FileVerification

type FileVerification struct {
	XMLName xml.Name `xml:"verification"`
	Hashes  []Hash   `xml:"hash"`
}

type Files

type Files struct {
	XMLName xml.Name   `xml:"files"`
	Text    string     `xml:",chardata"`
	File    []MetaFile `xml:"file"`
}

type Hash

type Hash struct {
	XMLName xml.Name `xml:"hash"`
	Type    string   `xml:"type,attr"`
	Text    string   `xml:",chardata"`
}

type MetaFile

type MetaFile struct {
	XMLName      xml.Name         `xml:"file"`
	Name         string           `xml:"name,attr"`
	Text         string           `xml:",chardata"`
	Size         Size             `xml:"size"`
	Resources    []Resources      `xml:"resources"`
	Verification FileVerification `xml:"verification"`
}

func (MetaFile) CompareHash

func (metadata MetaFile) CompareHash(hash, filename string) (bool, error)

Compares a file to the metalink file hash using a specified hash.

type Metalink struct {
	XMLName xml.Name `xml:"metalink"`
	Text    string   `xml:",chardata"`
	Files   Files
}

func ParseBytes

func ParseBytes(content []byte) (Metalink, error)

Reads a metalink xml bytes slice and returns a metalink struct

func ParseFile

func ParseFile(filename string) (Metalink, error)

Reads a local file and returns a metalink struct

func ParseFileFromUrl

func ParseFileFromUrl(link string) (Metalink, error)

Downloads a metalink xml file by a http\https url and returns a metalink struct

func ParseString

func ParseString(content string) (Metalink, error)

Reads a metalink xml string and returns a metalink struct

type Resources

type Resources struct {
	XMLName xml.Name `xml:"resources"`
	Urls    []Url    `xml:"url"`
}

type Size

type Size struct {
	XMLName xml.Name `xml:"size"`
	Text    string   `xml:",chardata"`
}

type Url

type Url struct {
	XMLName    xml.Name `xml:"url"`
	Type       string   `xml:"type,attr"`
	Protocol   string   `xml:"protocol,attr"`
	Location   string   `xml:"location,attr"`
	Preference string   `xml:"preference,attr"`
	Link       string   `xml:",chardata"`
}

Jump to

Keyboard shortcuts

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