mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 11:14:29 +00:00
[Archive interface] Refactor methods to follow same conventions as IReadOnlyFilesystem.
This commit is contained in:
@@ -35,9 +35,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using FileAttributes = System.IO.FileAttributes;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces;
|
||||
|
||||
@@ -83,48 +84,51 @@ public interface IArchive
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>Identifies if the specified filter contains data recognizable by this archive instance</summary>
|
||||
/// <param name="filter">Filter that contains the archive. This allows use to handle .tar.gz and similars.</param>
|
||||
bool Identify(IFilter filter);
|
||||
|
||||
/// <summary>Opens the specified stream with this archive instance</summary>
|
||||
/// <param name="filter">Filter that contains the archive. This allows use to handle .tar.gz and similars.</param>
|
||||
ErrorNumber Open(IFilter filter, Encoding encoding);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the archive has a file/stream/buffer currently opened and no
|
||||
/// <see cref="M:Aaru.Filters.Filter.Close" /> has been issued.
|
||||
/// </summary>
|
||||
bool IsOpened();
|
||||
|
||||
/// <summary>Closes all opened streams.</summary>
|
||||
void Close();
|
||||
/// <value><c>true</c> if the archive is opened, <c>false</c> otherwise.</value>
|
||||
bool Opened { get; }
|
||||
|
||||
/// <summary>Return a bitfield indicating the features supported by this archive type.</summary>
|
||||
/// <returns>The <c>ArchiveSupportedFeature</c> bitfield.</returns>
|
||||
/// <value>The <c>ArchiveSupportedFeature</c> bitfield.</value>
|
||||
/// <remarks>
|
||||
/// If the archive is not opened, this returns the capabilities of the archive format, otherwise it returns the
|
||||
/// capabilities in use by the currently opened archive.
|
||||
/// </remarks>
|
||||
ArchiveSupportedFeature GetArchiveFeatures();
|
||||
ArchiveSupportedFeature ArchiveFeatures { get; }
|
||||
|
||||
/// <summary>Gets the number of entries (i.e. files) that are contained in this archive.</summary>
|
||||
/// <remarks>
|
||||
/// Entries in this context can also mean directories or volume labels, for some types of archives that store
|
||||
/// these explicitly. Do not rely on all entries being regular files!
|
||||
/// </remarks>
|
||||
/// <returns>The number of files.</returns>
|
||||
int GetNumberOfEntries();
|
||||
/// <value>The number of files.</value>
|
||||
int NumberOfEntries { get; }
|
||||
|
||||
/// <summary>Identifies if the specified filter contains data recognizable by this archive instance</summary>
|
||||
/// <param name="filter">Filter that contains the archive. This allows use to handle .tar.gz and similars.</param>
|
||||
bool Identify(IFilter filter);
|
||||
|
||||
/// <summary>Opens the specified stream with this archive instance</summary>
|
||||
/// <param name="filter">Filter that contains the archive. This allows use to handle .tar.gz and similars.</param>
|
||||
/// <param name="encoding">The encoding codepage to use for this archive.</param>
|
||||
ErrorNumber Open(IFilter filter, Encoding encoding);
|
||||
|
||||
/// <summary>Closes the archive.</summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>Gets the file name (and path) of the given entry in the archive.</summary>
|
||||
/// <remarks>
|
||||
/// The path components are separated by a forward slash "/". <br /> The path should not start with a leading
|
||||
/// slash (i.e. it should be relative, not absolute).
|
||||
/// </remarks>
|
||||
/// <seealso cref="Stat(int)" />
|
||||
/// <seealso cref="Stat" />
|
||||
/// <param name="entryNumber">The entry in the archive for which to return the file name.</param>
|
||||
/// <returns>The file name, with (relative) path</returns>
|
||||
string GetFilename(int entryNumber);
|
||||
/// <param name="fileName">The file name, with (relative) path</param>
|
||||
/// <returns>Error number.</returns>
|
||||
ErrorNumber GetFilename(int entryNumber, out string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entry number for a particular file path in the archive. <c>fileName</c> is the relative path of the
|
||||
@@ -136,58 +140,69 @@ public interface IArchive
|
||||
/// </remarks>
|
||||
/// <param name="fileName">The relative path for which to get the entry number.</param>
|
||||
/// <param name="caseInsensitiveMatch">If set, do a case insensitive matching and return the first file that matches.</param>
|
||||
/// <returns>The number of the entry corresponding to the given path, or -1 if the path does not exist.</returns>
|
||||
int GetEntryNumber(string fileName, bool caseInsensitiveMatch);
|
||||
/// <param name="entryNumber">The number of the entry corresponding to the given path, or -1 if the path does not exist.</param>
|
||||
/// <returns>Error number.</returns>
|
||||
ErrorNumber GetEntryNumber(string fileName, bool caseInsensitiveMatch, out int entryNumber);
|
||||
|
||||
/// <summary>Gets the (compressed) size of the given entry.</summary>
|
||||
/// <param name="entryNumber">The entry for which to get the compressed size.</param>
|
||||
/// <returns>The compressed size of the entry, or 0 if the entry is not a regular file.</returns>
|
||||
/// <param name="length">The compressed size of the entry, or 0 if the entry is not a regular file.</param>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <remarks>The return value is equal to the return value of <c>GetUncompressedSize()</c> if the file is not compressed.</remarks>
|
||||
/// <seealso cref="GetUncompressedSize(int)" />
|
||||
long GetCompressedSize(int entryNumber);
|
||||
/// <seealso cref="GetUncompressedSize" />
|
||||
ErrorNumber GetCompressedSize(int entryNumber, out long length);
|
||||
|
||||
/// <summary>Gets the uncompressed size of the given entry.</summary>
|
||||
/// <param name="entryNumber">The entry for which to get the uncompressed size.</param>
|
||||
/// <returns>The uncompressed size of the entry, or 0 if the entry is not a regular file.</returns>
|
||||
/// <param name="length">The uncompressed size of the entry, or 0 if the entry is not a regular file.</param>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <remarks>The return value is equal to the return value of <c>GetCompressedSize()</c> if the file is not compressed.</remarks>
|
||||
/// <seealso cref="GetCompressedSize(int)" />
|
||||
long GetUncompressedSize(int entryNumber);
|
||||
/// <seealso cref="GetCompressedSize" />
|
||||
ErrorNumber GetUncompressedSize(int entryNumber, out long length);
|
||||
|
||||
/// <summary>Gets the attributes of a file or directory.</summary>
|
||||
/// <seealso cref="Stat(int)" />
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retrieve the attributes.</param>
|
||||
/// <returns>File attributes, or zero if the archive does not support attributes.</returns>
|
||||
FileAttributes GetAttributes(int entryNumber);
|
||||
/// <param name="attributes">File attributes, or zero if the archive does not support attributes.</param>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <seealso cref="Stat" />
|
||||
ErrorNumber GetAttributes(int entryNumber, out FileAttributes attributes);
|
||||
|
||||
/// <summary>Lists all extended attributes, alternate data streams and forks of the given file.</summary>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retrieve the list of attributes.</param>
|
||||
/// <returns>List of extended attributes, alternate data streams and forks.</returns>
|
||||
List<string> GetXAttrs(int entryNumber);
|
||||
/// <param name="xattrs">List of extended attributes, alternate data streams and forks.</param>
|
||||
/// <returns>Error number.</returns>
|
||||
ErrorNumber ListXAttr(int entryNumber, out List<string> xattrs);
|
||||
|
||||
/// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retrieve the XAttr.</param>
|
||||
/// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
|
||||
/// <param name="buffer">Buffer where the extended attribute data will be stored.</param>
|
||||
/// <returns>Buffer with the XAttr data.</returns>
|
||||
ErrorNumber GetXattr(int entryNumber, string xattr, out byte[] buffer);
|
||||
/// <returns>Error number.</returns>
|
||||
ErrorNumber GetXattr(int entryNumber, string xattr, ref byte[] buffer);
|
||||
|
||||
/// <summary>Gets information about an entry in the archive.</summary>
|
||||
/// <remarks>Note that some of the data might be incomplete or not available at all, depending on the type of archive.</remarks>
|
||||
/// <seealso cref="GetAttributes(int)" />
|
||||
/// <seealso cref="GetFilename(int)" />
|
||||
/// <param name="entryNumber">The entry int he archive for which to get the information</param>
|
||||
/// <returns>The available information about the entry in the archive</returns>
|
||||
FileSystemInfo Stat(int entryNumber);
|
||||
/// <param name="stat">The available information about the entry in the archive</param>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <seealso cref="GetAttributes" />
|
||||
/// <seealso cref="GetFilename" />
|
||||
ErrorNumber Stat(int entryNumber, out FileEntryInfo stat);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Filter for the given entry. It will return <c>null</c> if the entry in question is not a regular
|
||||
/// file (i.e. directory, volume label, etc.)
|
||||
/// </summary>
|
||||
/// <param name="entryNumber">The entry for which the Filter should be returned.</param>
|
||||
/// <returns>The Filter for the given entry.</returns>
|
||||
IFilter GetEntry(int entryNumber);
|
||||
/// <param name="filter">The Filter for the given entry.</param>
|
||||
/// <returns>Error number.</returns>
|
||||
ErrorNumber GetEntry(int entryNumber, out IFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Gets user readable information about the archive. The exact contents depend on the archive plugin implementation.
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter that handles the archive.</param>
|
||||
/// <param name="encoding">The encoding codepage to use with the archive.</param>
|
||||
/// <param name="information">Variable that holds the user readable information.</param>
|
||||
void GetInformation(IFilter filter, Encoding encoding, out string information);
|
||||
}
|
||||
Reference in New Issue
Block a user