#region Disclaimer / License
// Copyright (C) 2011, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace Duplicati.Library.Interface
{
///
/// An interface for accessing files in an archive, such as a folder or compressed file.
/// All modules that implements compression must implement this interface.
/// The classes that implements this interface MUST also
/// implement a default constructor and a construtor that
/// has the signature new(string file, Dictionary<string, string> options).
/// The default constructor is used to construct an instance
/// so the DisplayName and other values can be read.
/// The other constructor is used to do the actual work.
/// The input file may not exist or have zero length, in which case it should be created.
///
public interface ICompression : IDisposable
{
///
/// Returns all files in the archive, matching the prefix, if any.
///
/// An optional prefix for limiting the files returned
/// All files in the archive, matching the prefix, if any
string[] ListFiles(string prefix);
///
/// Returns all directories in the archive, matching the prefix, if any.
///
/// An optional prefix for limiting the directories returned
/// All directories in the archive, matching the prefix, if any
string[] ListDirectories(string prefix);
///
/// Returns all files and directories in the archive, matching the prefix, if any.
///
/// An optional prefix for limiting the files and directories returned
/// All files and directories in the archive, matching the prefix, if any
string[] ListEntries(string prefix);
///
/// Returns all the bytes from a given file
///
/// The file to read data from
/// All bytes from the given file
byte[] ReadAllBytes(string file);
///
/// Returns all lines in the given file
///
/// The file to read the data from
/// All lines in the given file
string[] ReadAllLines(string file);
///
/// Returns a stream with data from the given file
///
/// The file to read the data from
/// A stream with data from the given file
System.IO.Stream OpenRead(string file);
///
/// Returns a stream with data from the given file
///
/// The file to write the data to
/// A stream with data from the given file
System.IO.Stream OpenWrite(string file);
///
/// Writes data to a file
///
/// The file to write to
/// The data to write
void WriteAllBytes(string file, byte[] data);
///
/// Writes the given lines to the files
///
/// The file to write to
/// The data to write
void WriteAllLines(string file, string[] data);
///
/// Removes a file from the archive
///
/// The file to remove
void DeleteFile(string file);
///
/// Creates a file in the archive
///
/// The file to create
/// A stream with the data to write into the file
System.IO.Stream CreateFile(string file);
///
/// Creates a file in the archive
///
/// The file to create
/// The time the file was last written
/// A stream with the data to write into the file
System.IO.Stream CreateFile(string file, DateTime lastWrite);
///
/// Deletes the named directory, if it is empty
///
/// The directory to remove
void DeleteDirectory(string file);
///
/// Adds a directory to the archive
///
/// The name of the archive to create
void AddDirectory(string file);
///
/// Returns a value indicating if the specified file exists
///
/// The name of the file to examine
/// True if the file exists, false otherwise
bool FileExists(string file);
///
/// Returns a value indicating if the specified directory exists
///
/// The name of the directory to examine
/// True if the directory exists, false otherwise
bool DirectoryExists(string file);
///
/// The total size of the archive
///
long Size { get; }
///
/// Returns the last modification time for the file
///
/// The name of the file to examine
/// The timestamp on the file
DateTime GetLastWriteTime(string file);
///
/// The size in bytes of the buffer that will be written when flushed
///
long FlushBufferSize { get; }
///
/// The extension that the compression implementation adds to the filename
///
string FilenameExtension { get; }
///
/// A localized string describing the compression module with a friendly name
///
string DisplayName { get; }
///
/// A localized description of the compression module
///
string Description { get; }
///
/// Gets a list of supported commandline arguments
///
IList SupportedCommands { get; }
}
}