mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
reorganizing a bit
This commit is contained in:
57
UnRarDotNet/RarCompressionProvider.cs
Normal file
57
UnRarDotNet/RarCompressionProvider.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using CUETools.Compression;
|
||||
|
||||
namespace CUETools.Compression.Rar
|
||||
{
|
||||
[CompressionProviderClass("rar")]
|
||||
public class RarCompressionProvider: ICompressionProvider
|
||||
{
|
||||
private string _archivePath;
|
||||
|
||||
public RarCompressionProvider(string path)
|
||||
{
|
||||
_archivePath = path;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
~RarCompressionProvider()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public Stream Decompress(string file)
|
||||
{
|
||||
RarStream stream = new RarStream(_archivePath, file);
|
||||
stream.PasswordRequired += PasswordRequired;
|
||||
stream.ExtractionProgress += ExtractionProgress;
|
||||
return stream;
|
||||
}
|
||||
|
||||
public IEnumerable<string> Contents
|
||||
{
|
||||
get
|
||||
{
|
||||
using (Unrar _unrar = new Unrar())
|
||||
{
|
||||
_unrar.PasswordRequired += PasswordRequired;
|
||||
_unrar.Open(_archivePath, Unrar.OpenMode.List);
|
||||
while (_unrar.ReadHeader())
|
||||
{
|
||||
if (!_unrar.CurrentFile.IsDirectory)
|
||||
yield return _unrar.CurrentFile.FileName;
|
||||
_unrar.Skip();
|
||||
}
|
||||
_unrar.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<CompressionPasswordRequiredEventArgs> PasswordRequired;
|
||||
public event EventHandler<CompressionExtractionProgressEventArgs> ExtractionProgress;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user