示例#1
0
// Get the restore Plist from the IPSW
func (ip *IPSW) GetRestorePlist() (parsed Restore, err error) {
	url, err := url.Parse(ip.DownloadURL)

	// retrieve the Restore.plist from the IPSW, possibly need the BuildManifest too?
	reader, err := ranger.NewReader(&ranger.HTTPRanger{URL: url})
	zipreader, err := zip.NewReader(reader, reader.Length())

	restorePlist, err := ReadFile(zipreader, "Restore.plist")
	// decode the plist
	dec := plist.NewDecoder(bytes.NewReader(restorePlist))

	dec.Decode(&parsed)

	return parsed, err
}
示例#2
0
// Opens the given URL, returning a Resource.
func openURL(url *url.URL) (resource, error) {
	switch url.Scheme {
	case "http", "https":

		// Resolve the URL as a remote HTTP/HTTPS stream.
		reader, err := ranger.NewReader(&ranger.HTTPRanger{URL: url})
		if err != nil {
			return nil, err
		}

		return &rangerResource{url.String(), reader}, nil

	case "file", "":

		// Resolve the URL as a local file.
		return os.Open(url.Path)

	default:
		return nil, fmt.Errorf("Unknown URL scheme: %s", url)
	}
}