From acf5b0b6ed173a3a9540d0585bd491a119d524cf Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Thu, 21 Feb 2013 00:00:56 -0500 Subject: isolated DotNetZip dependancy --- .../Implementations/DotNetZipClient.cs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs (limited to 'MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs') diff --git a/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs b/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs new file mode 100644 index 000000000..3b174a9b2 --- /dev/null +++ b/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs @@ -0,0 +1,43 @@ +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); + } + } + } +} -- cgit v1.2.3