// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : IArchive.cs // Author(s) : Michael Drüing // // Component : Archives. // // --[ Description ] ---------------------------------------------------------- // // Defines the interface for an Archive. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2018 Michael Drüing // Copyright © 2011-2018 Natalia Portillo // ****************************************************************************/ using System; using System.IO; using System.Collections.Generic; namespace DiscImageChef.Archives { public interface IArchive { /// Descriptive name of the plugin string Name { get; } /// Unique UUID of the plugin Guid Id { get; } /// /// Identifies if the specified path contains data recognizable by this archive instance /// /// Path. bool Identify(string path); /// /// Identifies if the specified stream contains data recognizable by this archive instance /// /// Stream. bool Identify(Stream stream); /// /// Identifies if the specified buffer contains data recognizable by this archive instance /// /// Buffer. bool Identify(byte[] buffer); /// /// Opens the specified path with this archive instance /// /// Path. void Open(string path); /// /// Opens the specified stream with this archive instance /// /// Stream. void Open(Stream stream); /// /// Opens the specified buffer with this archive instance /// /// Buffer. void Open(byte[] buffer); /// /// Returns true if the archive has a file/stream/buffer currently opened and no /// has been issued. /// bool IsOpened(); /// /// Closes all opened streams. /// void Close(); /// /// Gets length of file referenced by ths archive. /// /// The length. long GetLength(); /// /// Gets the number of entries (i.e. files) that are contained in this archive. /// /// /// 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! /// /// The number of files. int GetNumberOfEntries(); /// /// Gets the file name (and path) of the given entry in the archive. /// /// /// The path components are separated by a forward slash "/".
/// The path should not start with a leading slash (i.e. it should be relative, not absolute). ///
/// /// The entry in the archive for which to return the file name. /// The file name, with (relative) path string GetFilename(int entryNumber); /// /// Gets the attributes of a file or directory. /// /// /// Error number. /// The entry in the archive for which to retreive the attributes. /// File attributes, or zero if the archive does not support attributes. FileAttributes GetAttributes(int entryNumber); /// /// Lists all extended attributes, alternate data streams and forks of the given file. /// /// The entry in the archive for which to retreive the list of attributes. /// List of extended attributes, alternate data streams and forks. List GetXAttr(int entryNumber); /// /// Reads an extended attribute, alternate data stream or fork from the given file. /// /// Error number. /// The entry in the archive for which to retreive the XAttr. /// Extended attribute, alternate data stream or fork name. /// Buffer with the XAttr data. byte[] GetXattr(int entryNumber, string xattr); /// /// Gets information about an entry in the archive. /// /// /// Note that some of the data might be incomplete or not available at all, depending on the type of /// archive. /// /// /// /// The entry int he archive for which to get the information /// The available information about the entry in the archive FileSystemInfo Stat(int entryNumber); /// /// Returns the data stream of the given entry. It will return null if the entry in question /// is not a regular file stream (i.e. directory, volume label, etc.) /// /// The entry for which the data stream should be returned. /// The stream for the given entry. Stream GetStream(int entryNumber); } }