// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : Filter.cs // Author(s) : Natalia Portillo // // Component : Filters. // // --[ Description ] ---------------------------------------------------------- // // Defines the interface for a Filter. // // --[ 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 © 2011-2017 Natalia Portillo // ****************************************************************************/ using System; using System.IO; namespace DiscImageChef.Filters { public abstract class Filter { public string Name; public Guid UUID; protected Filter() { } /// /// Closes all opened streams. /// public abstract void Close(); /// /// Gets the path used to open this filter.
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip/path/to/file.bin
/// Windows: C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip\path\to\file.bin ///
/// Path used to open this filter. public abstract string GetBasePath(); /// /// Gets creation time of file referenced by this filter. /// /// The creation time. public abstract DateTime GetCreationTime(); /// /// Gets length of this filter's data fork. /// /// The data fork length. public abstract long GetDataForkLength(); /// /// Gets a stream to access the data fork contents. /// /// The data fork stream. public abstract Stream GetDataForkStream(); /// /// Gets the filename for the file referenced by this filter.
/// UNIX: /path/to/archive.zip/path/to/file.bin => file.bin
/// Windows: C:\path\to\archive.zip\path\to\file.bin => file.bin ///
/// The filename. public abstract string GetFilename(); /// /// Gets last write time of file referenced by this filter. /// /// The last write time. public abstract DateTime GetLastWriteTime(); /// /// Gets length of file referenced by ths filter. /// /// The length. public abstract long GetLength(); /// /// Gets full path to file referenced by this filter. If it's an archive, it's the path inside the archive.
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/file.bin
/// Windows: C:\path\to\archive.zip\path\to\file.bin => \path\to\file.bin ///
/// The path. public abstract string GetPath(); /// /// Gets path to parent folder to the file referenced by this filter. If it's an archive, it's the full path to the archive itself.
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip
/// Windows: C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip ///
/// The parent folder. public abstract string GetParentFolder(); /// /// Gets length of this filter's resource fork. /// /// The resource fork length. public abstract long GetResourceForkLength(); /// /// Gets a stream to access the resource fork contents. /// /// The resource fork stream. public abstract Stream GetResourceForkStream(); /// /// Returns true if the file referenced by this filter has a resource fork /// public abstract bool HasResourceFork(); /// /// Identifies if the specified path contains data recognizable by this filter instance /// /// Path. public abstract bool Identify(string path); /// /// Identifies if the specified stream contains data recognizable by this filter instance /// /// Stream. public abstract bool Identify(Stream stream); /// /// Identifies if the specified buffer contains data recognizable by this filter instance /// /// Buffer. public abstract bool Identify(byte[] buffer); /// /// Returns true if the filter has a file/stream/buffer currently opened and no has been issued. /// public abstract bool IsOpened(); /// /// Opens the specified path with this filter instance /// /// Path. public abstract void Open(string path); /// /// Opens the specified stream with this filter instance /// /// Stream. public abstract void Open(Stream stream); /// /// Opens the specified buffer with this filter instance /// /// Buffer. public abstract void Open(byte[] buffer); } }