Table of Contents

Class Archive

Namespace
ZeroInstall.Model
Assembly
ZeroInstall.Model.dll

Retrieves an implementation by downloading and extracting an archive.

[Serializable]
[Equatable]
public sealed class Archive : DownloadRetrievalMethod, IEquatable<XmlUnknown>, IEquatable<FeedElement>, ICloneable<RetrievalMethod>, IRecipeStep, ICloneable<IRecipeStep>, IEquatable<DownloadRetrievalMethod>, IEquatable<Archive>
Inheritance
Archive
Implements
Inherited Members

Fields

KnownMimeTypes

All known MimeType values for archives.

public static readonly IEnumerable<string> KnownMimeTypes

Field Value

IEnumerable<string>

MimeType7Z

A MimeType value for archives.

public const string MimeType7Z = "application/x-7z-compressed"

Field Value

string

MimeTypeCab

A MimeType value for archives.

public const string MimeTypeCab = "application/vnd.ms-cab-compressed"

Field Value

string

MimeTypeDeb

A MimeType value for archives.

public const string MimeTypeDeb = "application/x-deb"

Field Value

string

MimeTypeDmg

A MimeType value for archives.

public const string MimeTypeDmg = "application/x-apple-diskimage"

Field Value

string

MimeTypeMsi

A MimeType value for archives.

public const string MimeTypeMsi = "application/x-msi"

Field Value

string

MimeTypeRar

A MimeType value for archives.

public const string MimeTypeRar = "application/vnd.rar"

Field Value

string

MimeTypeRpm

A MimeType value for archives.

public const string MimeTypeRpm = "application/x-rpm"

Field Value

string

MimeTypeRubyGem

A MimeType value for archives.

public const string MimeTypeRubyGem = "application/x-ruby-gem"

Field Value

string

MimeTypeTar

A MimeType value for archives.

public const string MimeTypeTar = "application/x-tar"

Field Value

string

MimeTypeTarBzip

A MimeType value for archives.

public const string MimeTypeTarBzip = "application/x-bzip-compressed-tar"

Field Value

string

MimeTypeTarGzip

A MimeType value for archives.

public const string MimeTypeTarGzip = "application/x-compressed-tar"

Field Value

string

MimeTypeTarLzip

A MimeType value for archives.

public const string MimeTypeTarLzip = "application/x-lzip-compressed-tar"

Field Value

string

MimeTypeTarLzma

A MimeType value for archives.

public const string MimeTypeTarLzma = "application/x-lzma-compressed-tar"

Field Value

string

MimeTypeTarXz

A MimeType value for archives.

public const string MimeTypeTarXz = "application/x-xz-compressed-tar"

Field Value

string

MimeTypeTarZstandard

A MimeType value for archives.

public const string MimeTypeTarZstandard = "application/x-zstd-compressed-tar"

Field Value

string

MimeTypeZip

A MimeType value for archives.

public const string MimeTypeZip = "application/zip"

Field Value

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.

public string? Destination { get; set; }

Property Value

string

DownloadSize

The effective size of the file on the server.

public override long DownloadSize { get; }

Property Value

long

Extract

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

public string? Extract { get; set; }

Property Value

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.

[TypeConverter(typeof(ArchiveMimeTypeConverter))]
public string? MimeType { get; set; }

Property Value

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.

public int StartOffset { get; set; }

Property Value

int

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.

public override RetrievalMethod Clone()

Returns

RetrievalMethod

The new copy of the Archive.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetFileExtension(string)

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

public static string GetFileExtension(string mimeType)

Parameters

mimeType string

The MIME type to get the extension for.

Returns

string

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

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GuessMimeType(string)

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

public static string GuessMimeType(string fileName)

Parameters

fileName string

The file name to analyze.

Returns

string

Exceptions

NotSupportedException

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

Normalize(FeedUri?)

Sets missing default values and handles legacy elements.

public override void Normalize(FeedUri? feedUri = null)

Parameters

feedUri FeedUri

The feed the data was originally loaded from.

Exceptions

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!

public override string ToString()

Returns

string

Operators

operator ==(Archive?, Archive?)

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

public static bool operator ==(Archive? left, Archive? right)

Parameters

left Archive

The left object

right Archive

The right object

Returns

bool

true if the objects are equal; otherwise, false.

operator !=(Archive?, Archive?)

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

public static bool operator !=(Archive? left, Archive? right)

Parameters

left Archive

The left object

right Archive

The right object

Returns

bool

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