diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-23 14:53:06 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-23 14:53:06 -0400 |
| commit | 51b01d0f6d21bf31a093cf7d8f88e31aba884288 (patch) | |
| tree | 0143c6f7cf95253b30df97898addb62bdec81c13 /MediaBrowser.ServerApplication/Implementations/ZipClient.cs | |
| parent | d43fd8c51dcd801959ed0581598efe2cd9314a9f (diff) | |
updated nuget
Diffstat (limited to 'MediaBrowser.ServerApplication/Implementations/ZipClient.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/Implementations/ZipClient.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/MediaBrowser.ServerApplication/Implementations/ZipClient.cs b/MediaBrowser.ServerApplication/Implementations/ZipClient.cs new file mode 100644 index 000000000..e9e8645e9 --- /dev/null +++ b/MediaBrowser.ServerApplication/Implementations/ZipClient.cs @@ -0,0 +1,48 @@ +using MediaBrowser.Model.IO; +using SharpCompress.Common; +using SharpCompress.Reader; +using System.IO; + +namespace MediaBrowser.ServerApplication.Implementations +{ + /// <summary> + /// Class DotNetZipClient + /// </summary> + public class ZipClient : IZipClient + { + /// <summary> + /// Extracts all. + /// </summary> + /// <param name="sourceFile">The source file.</param> + /// <param name="targetPath">The target path.</param> + /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param> + public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles) + { + using (var fileStream = File.OpenRead(sourceFile)) + { + ExtractAll(fileStream, targetPath, overwriteExistingFiles); + } + } + + /// <summary> + /// Extracts all. + /// </summary> + /// <param name="source">The source.</param> + /// <param name="targetPath">The target path.</param> + /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param> + public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles) + { + using (var reader = ReaderFactory.Open(source)) + { + var options = ExtractOptions.ExtractFullPath; + + if (overwriteExistingFiles) + { + options = options | ExtractOptions.Overwrite; + } + + reader.WriteAllToDirectory(targetPath, options); + } + } + } +} |
