diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-12 23:39:22 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-12 23:39:22 -0400 |
| commit | e98665a0917f93eba79970de44c68c9a88b78bb8 (patch) | |
| tree | 8f2b8dd86a363b58fc47610c9565650a3587309c /MediaBrowser.Common.Implementations/Archiving/ZipClient.cs | |
| parent | f8f17efd54426067e8e5f7624ad1549125229426 (diff) | |
added ffmpeg downloading for mono
Diffstat (limited to 'MediaBrowser.Common.Implementations/Archiving/ZipClient.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/Archiving/ZipClient.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs index 39690eb07..2b66617af 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 } } } + + + /// <summary> + /// Extracts all from tar. + /// </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 ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles) + { + using (var fileStream = File.OpenRead(sourceFile)) + { + ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles); + } + } + + /// <summary> + /// Extracts all from tar. + /// </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 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); + } + } + } } } |
