From e98665a0917f93eba79970de44c68c9a88b78bb8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 12 Oct 2013 23:39:22 -0400 Subject: added ffmpeg downloading for mono --- .../Archiving/ZipClient.cs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'MediaBrowser.Common.Implementations') diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs index 39690eb07e..2b66617afc 100644 --- a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs +++ b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs @@ -1,5 +1,6 @@ using MediaBrowser.Model.IO; using SharpCompress.Archive.SevenZip; +using SharpCompress.Archive.Tar; using SharpCompress.Common; using SharpCompress.Reader; using System.IO; @@ -83,5 +84,44 @@ namespace MediaBrowser.Common.Implementations.Archiving } } } + + + /// + /// Extracts all from tar. + /// + /// The source file. + /// The target path. + /// if set to true [overwrite existing files]. + public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles) + { + using (var fileStream = File.OpenRead(sourceFile)) + { + ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles); + } + } + + /// + /// Extracts all from tar. + /// + /// The source. + /// The target path. + /// if set to true [overwrite existing files]. + public void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles) + { + using (var archive = TarArchive.Open(source)) + { + using (var reader = archive.ExtractAllEntries()) + { + var options = ExtractOptions.ExtractFullPath; + + if (overwriteExistingFiles) + { + options = options | ExtractOptions.Overwrite; + } + + reader.WriteAllToDirectory(targetPath, options); + } + } + } } } -- cgit v1.2.3