diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs
index 2b66617afc..23d40cf67f 100644
--- a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs
+++ b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Model.IO;
+using SharpCompress.Archive.Rar;
using SharpCompress.Archive.SevenZip;
using SharpCompress.Archive.Tar;
using SharpCompress.Common;
@@ -123,5 +124,43 @@ namespace MediaBrowser.Common.Implementations.Archiving
}
}
}
+
+ ///
+ /// Extracts all from rar.
+ ///
+ /// The source file.
+ /// The target path.
+ /// if set to true [overwrite existing files].
+ public void ExtractAllFromRar(string sourceFile, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var fileStream = File.OpenRead(sourceFile))
+ {
+ ExtractAllFromRar(fileStream, targetPath, overwriteExistingFiles);
+ }
+ }
+
+ ///
+ /// Extracts all from rar.
+ ///
+ /// The source.
+ /// The target path.
+ /// if set to true [overwrite existing files].
+ public void ExtractAllFromRar(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var archive = RarArchive.Open(source))
+ {
+ using (var reader = archive.ExtractAllEntries())
+ {
+ var options = ExtractOptions.ExtractFullPath;
+
+ if (overwriteExistingFiles)
+ {
+ options = options | ExtractOptions.Overwrite;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+ }
}
}
diff --git a/MediaBrowser.Model/IO/IZipClient.cs b/MediaBrowser.Model/IO/IZipClient.cs
index 1fa3e0271b..ba0725da53 100644
--- a/MediaBrowser.Model/IO/IZipClient.cs
+++ b/MediaBrowser.Model/IO/IZipClient.cs
@@ -54,5 +54,21 @@ namespace MediaBrowser.Model.IO
/// The target path.
/// if set to true [overwrite existing files].
void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles);
+
+ ///
+ /// Extracts all from rar.
+ ///
+ /// The source file.
+ /// The target path.
+ /// if set to true [overwrite existing files].
+ void ExtractAllFromRar(string sourceFile, string targetPath, bool overwriteExistingFiles);
+
+ ///
+ /// Extracts all from rar.
+ ///
+ /// The source.
+ /// The target path.
+ /// if set to true [overwrite existing files].
+ void ExtractAllFromRar(Stream source, string targetPath, bool overwriteExistingFiles);
}
}