Show / Hide Table of Contents

Class Archive

Retrieves an implementation by downloading and extracting an archive.

Inheritance
Object
XmlUnknown
FeedElement
RetrievalMethod
DownloadRetrievalMethod
Archive
Implements
IEquatable<XmlUnknown>
IEquatable<FeedElement>
ICloneable<RetrievalMethod>
IRecipeStep
ICloneable<IRecipeStep>
IEquatable<DownloadRetrievalMethod>
IEquatable<Archive>
Inherited Members
DownloadRetrievalMethod.Equals(DownloadRetrievalMethod)
DownloadRetrievalMethod.Href
DownloadRetrievalMethod.HrefString
DownloadRetrievalMethod.Size
FeedElement.FilterMismatch<T>(T)
FeedElement.FilterMismatch(IRecipeStep)
FeedElement.Equals(FeedElement)
FeedElement.IfZeroInstallVersion
FeedElement.IfZeroInstallVersionString
XmlUnknown.UnknownAttributes
XmlUnknown.UnknownElements
XmlUnknown.EnsureAttribute(Object, String)
XmlUnknown.EnsureAttributeSafeID(String, String)
XmlUnknown.ToShortXml()
XmlUnknown.Equals(XmlUnknown)
Namespace: ZeroInstall.Model
Assembly: ZeroInstall.Model.dll
Syntax
public sealed class Archive : DownloadRetrievalMethod, IRecipeStep

Constructors

Archive()

Declaration
public Archive()

Fields

KnownMimeTypes

All known MimeType values for archives.

Declaration
public static readonly IEnumerable<string> KnownMimeTypes
Field Value
Type Description
IEnumerable<String>

MimeType7Z

A MimeType value for archives.

Declaration
public const string MimeType7Z = "application/x-7z-compressed"
Field Value
Type Description
String

MimeTypeCab

A MimeType value for archives.

Declaration
public const string MimeTypeCab = "application/vnd.ms-cab-compressed"
Field Value
Type Description
String

MimeTypeDeb

A MimeType value for archives.

Declaration
public const string MimeTypeDeb = "application/x-deb"
Field Value
Type Description
String

MimeTypeDmg

A MimeType value for archives.

Declaration
public const string MimeTypeDmg = "application/x-apple-diskimage"
Field Value
Type Description
String

MimeTypeMsi

A MimeType value for archives.

Declaration
public const string MimeTypeMsi = "application/x-msi"
Field Value
Type Description
String

MimeTypeRar

A MimeType value for archives.

Declaration
public const string MimeTypeRar = "application/vnd.rar"
Field Value
Type Description
String

MimeTypeRpm

A MimeType value for archives.

Declaration
public const string MimeTypeRpm = "application/x-rpm"
Field Value
Type Description
String

MimeTypeRubyGem

A MimeType value for archives.

Declaration
public const string MimeTypeRubyGem = "application/x-ruby-gem"
Field Value
Type Description
String

MimeTypeTar

A MimeType value for archives.

Declaration
public const string MimeTypeTar = "application/x-tar"
Field Value
Type Description
String

MimeTypeTarBzip

A MimeType value for archives.

Declaration
public const string MimeTypeTarBzip = "application/x-bzip-compressed-tar"
Field Value
Type Description
String

MimeTypeTarGzip

A MimeType value for archives.

Declaration
public const string MimeTypeTarGzip = "application/x-compressed-tar"
Field Value
Type Description
String

MimeTypeTarLzip

A MimeType value for archives.

Declaration
public const string MimeTypeTarLzip = "application/x-lzip-compressed-tar"
Field Value
Type Description
String

MimeTypeTarLzma

A MimeType value for archives.

Declaration
public const string MimeTypeTarLzma = "application/x-lzma-compressed-tar"
Field Value
Type Description
String

MimeTypeTarXz

A MimeType value for archives.

Declaration
public const string MimeTypeTarXz = "application/x-xz-compressed-tar"
Field Value
Type Description
String

MimeTypeTarZstandard

A MimeType value for archives.

Declaration
public const string MimeTypeTarZstandard = "application/x-zstd-compressed-tar"
Field Value
Type Description
String

MimeTypeZip

A MimeType value for archives.

Declaration
public const string MimeTypeZip = "application/zip"
Field Value
Type Description
String

Properties

Destination

The subdirectory below the implementation directory to extract the archive into as a Unix-style path; null or Empty for top-level.

Declaration
public string Destination { get; set; }
Property Value
Type Description
String

DownloadSize

The effective size of the file on the server.

Declaration
public override long DownloadSize { get; }
Property Value
Type Description
Int64
Overrides
DownloadRetrievalMethod.DownloadSize

Extract

The directory to extract into relative to the implementation root as a Unix-style path; null or Empty for entire archive.

Declaration
public string Extract { get; set; }
Property Value
Type Description
String

MimeType

The type of the archive as a MIME type. If missing, the type is guessed from the extension on the Href attribute. This value is case-insensitive.

Declaration
public string MimeType { get; set; }
Property Value
Type Description
String

StartOffset

The number of bytes at the beginning of the file which should be ignored. The value in Size does not include the skipped bytes.

Declaration
public int StartOffset { get; set; }
Property Value
Type Description
Int32
Remarks

This is useful for some self-extracting archives which are made up of a shell script followed by a normal archive in a single file.

Methods

Clone()

Creates a deep copy of this Archive instance.

Declaration
public override RetrievalMethod Clone()
Returns
Type Description
RetrievalMethod

The new copy of the Archive.

Overrides
RetrievalMethod.Clone()

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
Overrides
DownloadRetrievalMethod.Equals(Object)

Equals(Archive)

Declaration
public bool Equals(Archive other)
Parameters
Type Name Description
Archive other
Returns
Type Description
Boolean

GetFileExtension(String)

Gets the default file extension for a particular archive MIME type.

Declaration
public static string GetFileExtension(string mimeType)
Parameters
Type Name Description
String mimeType

The MIME type to get the extension for.

Returns
Type Description
String

The file extension including the leading dot, e.g. '.zip'. '.*' if unknown.

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
Int32
Overrides
DownloadRetrievalMethod.GetHashCode()

GuessMimeType(String)

Tries to guess the MIME type of an archive file by looking at its file extension.

Declaration
public static string GuessMimeType(string fileName)
Parameters
Type Name Description
String fileName

The file name to analyze.

Returns
Type Description
String
Exceptions
Type Condition
NotSupportedException

The file extension does not correspond to a known archive type.

Normalize(FeedUri)

Sets missing default values and handles legacy elements.

Declaration
public override void Normalize(FeedUri feedUri = null)
Parameters
Type Name Description
FeedUri feedUri

The feed the data was originally loaded from.

Overrides
DownloadRetrievalMethod.Normalize(FeedUri)
Exceptions
Type Condition
UriFormatException

Href is relative and feedUri is a remote URI.

InvalidDataException

A required property is not set or invalid.

ToString()

Returns the archive in the form "Location (MimeType, Size + StartOffset, Extract) => Destination". Not safe for parsing!

Declaration
public override string ToString()
Returns
Type Description
String

Operators

Equality(Archive, Archive)

Indicates whether the object on the left is equal to the object on the right.

Declaration
public static bool operator ==(Archive left, Archive right)
Parameters
Type Name Description
Archive left

The left object

Archive right

The right object

Returns
Type Description
Boolean

true if the objects are equal; otherwise, false.

Inequality(Archive, Archive)

Indicates whether the object on the left is not equal to the object on the right.

Declaration
public static bool operator !=(Archive left, Archive right)
Parameters
Type Name Description
Archive left

The left object

Archive right

The right object

Returns
Type Description
Boolean

true if the objects are not equal; otherwise, false.

Implements

System.IEquatable<T>
System.IEquatable<T>
ICloneable<T>
IRecipeStep
ICloneable<T>
System.IEquatable<T>
System.IEquatable<T>

Extension Methods

RetrievalMethodExtensions.SetMissing(DownloadRetrievalMethod, ICommandExecutor, String)
RetrievalMethodExtensions.CalculateDigest(RetrievalMethod, ICommandExecutor, ITaskHandler, ManifestFormat)
RetrievalMethodExtensions.ToTempDir(DownloadRetrievalMethod, ITaskHandler, String)
In This Article
Back to top Copyright Bastian Eicher et al