Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvnau <valery.naumenko@gmail.com>2017-12-25 00:12:19 +0300
committervnau <valery.naumenko@gmail.com>2017-12-25 00:12:19 +0300
commit62a7901aca6a7303a1492bdd3f9a7ba3b8998c77 (patch)
tree01c87815bfb91e591db937d55c490c9f1ffbd379 /Duplicati/Library/Interface
parent01ec66cdc56e95890457305391cbba3e68be0a72 (diff)
Compression modules refactored to work with streams instead of filenames;
Added unit test to check compression reversibility
Diffstat (limited to 'Duplicati/Library/Interface')
-rw-r--r--Duplicati/Library/Interface/ICompression.cs81
1 files changed, 51 insertions, 30 deletions
diff --git a/Duplicati/Library/Interface/ICompression.cs b/Duplicati/Library/Interface/ICompression.cs
index a0ee13ee6..6b6cec997 100644
--- a/Duplicati/Library/Interface/ICompression.cs
+++ b/Duplicati/Library/Interface/ICompression.cs
@@ -19,11 +19,27 @@
#endregion
using System;
using System.Collections.Generic;
+using System.IO;
using System.Text;
namespace Duplicati.Library.Interface
{
/// <summary>
+ /// Enumerates the possible modes for compression and decompression
+ /// </summary>
+ public enum ArchiveMode
+ {
+ /// <summary>
+ /// Indicates compression i.e. write archive mode, which means that the stream must be writeable
+ /// </summary>
+ Write,
+ /// <summary>
+ /// Indicates decompression i.e. read archive mode, which means that the stream must be readable
+ /// </summary>
+ Read
+ }
+
+ /// <summary>
/// A value that is given to the compressor as a hint
/// to how compressible the file is
/// </summary>
@@ -43,9 +59,8 @@ namespace Duplicati.Library.Interface
/// Indicates that the files is incompressible
/// </summary>
Noncompressible
-
}
-
+
/// <summary>
/// An interface for passing additional hints to the compressor
/// about the expected contents of the volume
@@ -60,18 +75,7 @@ namespace Duplicati.Library.Interface
bool LowOverheadMode { get; set; }
}
- /// <summary>
- /// 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&lt;string, string&gt; 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.
- /// </summary>
- public interface ICompression : IDisposable
+ public interface IArchiveReader
{
/// <summary>
/// Returns all files in the archive, matching the prefix, if any.
@@ -86,22 +90,20 @@ namespace Duplicati.Library.Interface
/// <param name="prefix">An optional prefix for limiting the files returned</param>
/// <returns>All files in the archive, matching the prefix, if any</returns>
IEnumerable<KeyValuePair<string, long>> ListFilesWithSize(string prefix);
-
+
/// <summary>
- /// Returns a stream with data from the given file
+ /// Returns a stream with data from the given file in archive.
/// </summary>
/// <param name="file">The file to read the data from</param>
/// <returns>A stream with data from the given file</returns>
System.IO.Stream OpenRead(string file);
/// <summary>
- /// Creates a file in the archive
+ /// Returns the last modification time for the file
/// </summary>
- /// <param name="file">The file to create</param>
- /// <param name="hint">A hint to the compressor as to how compressible the file data is</param>
- /// <param name="lastWrite">The time the file was last written</param>
- /// <returns>A stream with the data to write into the file</returns>
- System.IO.Stream CreateFile(string file, CompressionHint hint, DateTime lastWrite);
+ /// <param name="file">The name of the file to examine</param>
+ /// <returns>The timestamp on the file</returns>
+ DateTime GetLastWriteTime(string file);
/// <summary>
/// Returns a value indicating if the specified file exists
@@ -109,23 +111,42 @@ namespace Duplicati.Library.Interface
/// <param name="file">The name of the file to examine</param>
/// <returns>True if the file exists, false otherwise</returns>
bool FileExists(string file);
+ }
+ public interface IArchiveWriter
+ {
/// <summary>
- /// The total size of the archive
+ /// Creates a file in the archive.
/// </summary>
- long Size { get; }
+ /// <param name="file">The file to create in the archive</param>
+ /// <param name="hint">A hint to the compressor as to how compressible the file data is</param>
+ /// <param name="lastWrite">The time the file was last written</param>
+ /// <returns>A stream with the data to write into the file</returns>
+ System.IO.Stream CreateFile(string file, CompressionHint hint, DateTime lastWrite);
/// <summary>
- /// Returns the last modification time for the file
+ /// The size in bytes of the buffer that will be written when flushed
/// </summary>
- /// <param name="file">The name of the file to examine</param>
- /// <returns>The timestamp on the file</returns>
- DateTime GetLastWriteTime(string file);
+ long FlushBufferSize { get; }
+ }
+ /// <summary>
+ /// 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&lt;string, string&gt; 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.
+ /// </summary>
+ public interface ICompression : IDisposable, IArchiveReader, IArchiveWriter
+ {
/// <summary>
- /// The size in bytes of the buffer that will be written when flushed
+ /// The total size of the archive.
/// </summary>
- long FlushBufferSize { get; }
+ long Size { get; }
/// <summary>
/// The extension that the compression implementation adds to the filename