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
MimeType7Z
A MimeType value for archives.
public const string MimeType7Z = "application/x-7z-compressed"
Field Value
MimeTypeCab
A MimeType value for archives.
public const string MimeTypeCab = "application/vnd.ms-cab-compressed"
Field Value
MimeTypeDeb
A MimeType value for archives.
public const string MimeTypeDeb = "application/x-deb"
Field Value
MimeTypeDmg
A MimeType value for archives.
public const string MimeTypeDmg = "application/x-apple-diskimage"
Field Value
MimeTypeMsi
A MimeType value for archives.
public const string MimeTypeMsi = "application/x-msi"
Field Value
MimeTypeRar
A MimeType value for archives.
public const string MimeTypeRar = "application/vnd.rar"
Field Value
MimeTypeRpm
A MimeType value for archives.
public const string MimeTypeRpm = "application/x-rpm"
Field Value
MimeTypeRubyGem
A MimeType value for archives.
public const string MimeTypeRubyGem = "application/x-ruby-gem"
Field Value
MimeTypeTar
A MimeType value for archives.
public const string MimeTypeTar = "application/x-tar"
Field Value
MimeTypeTarBzip
A MimeType value for archives.
public const string MimeTypeTarBzip = "application/x-bzip-compressed-tar"
Field Value
MimeTypeTarGzip
A MimeType value for archives.
public const string MimeTypeTarGzip = "application/x-compressed-tar"
Field Value
MimeTypeTarLzip
A MimeType value for archives.
public const string MimeTypeTarLzip = "application/x-lzip-compressed-tar"
Field Value
MimeTypeTarLzma
A MimeType value for archives.
public const string MimeTypeTarLzma = "application/x-lzma-compressed-tar"
Field Value
MimeTypeTarXz
A MimeType value for archives.
public const string MimeTypeTarXz = "application/x-xz-compressed-tar"
Field Value
MimeTypeTarZstandard
A MimeType value for archives.
public const string MimeTypeTarZstandard = "application/x-zstd-compressed-tar"
Field Value
MimeTypeZip
A MimeType value for archives.
public const string MimeTypeZip = "application/zip"
Field Value
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
DownloadSize
The effective size of the file on the server.
public override long DownloadSize { get; }
Property Value
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
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
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
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
objectThe object to compare with the current object.
Returns
GetFileExtension(string)
Gets the default file extension for a particular archive MIME type.
public static string GetFileExtension(string mimeType)
Parameters
mimeType
stringThe 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
stringThe file name to analyze.
Returns
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
FeedUriThe 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
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
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
Returns
- bool
true if the objects are not equal; otherwise, false.