using Ionic.Zip;
using MediaBrowser.Model.IO;
using System.IO;
namespace MediaBrowser.ServerApplication.Implementations
{
///
/// Class DotNetZipClient
///
public class DotNetZipClient : IZipClient
{
///
/// Extracts all.
///
/// The source file.
/// The target path.
/// if set to true [overwrite existing files].
public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
{
using (var fileStream = File.OpenRead(sourceFile))
{
using (var zipFile = ZipFile.Read(fileStream))
{
zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
}
}
}
///
/// Extracts all.
///
/// The source.
/// The target path.
/// if set to true [overwrite existing files].
public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles)
{
using (var zipFile = ZipFile.Read(source))
{
zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
}
}
}
}