mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-25 16:34:45 +00:00
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using SharpCompress.Common.Rar;
|
|
using SharpCompress.Common.Rar.Headers;
|
|
using SharpCompress.IO;
|
|
using SharpCompress.Readers;
|
|
|
|
namespace SharpCompress.Archives.Rar
|
|
{
|
|
/// <summary>
|
|
/// A rar part based on a FileInfo object
|
|
/// </summary>
|
|
internal class FileInfoRarArchiveVolume : RarVolume
|
|
{
|
|
internal FileInfoRarArchiveVolume(FileInfo fileInfo, ReaderOptions options, int index = 0)
|
|
: base(StreamingMode.Seekable, fileInfo.OpenRead(), FixOptions(options), index)
|
|
{
|
|
FileInfo = fileInfo;
|
|
FileParts = GetVolumeFileParts().ToArray().ToReadOnly();
|
|
}
|
|
|
|
private static ReaderOptions FixOptions(ReaderOptions options)
|
|
{
|
|
//make sure we're closing streams with fileinfo
|
|
options.LeaveStreamOpen = false;
|
|
return options;
|
|
}
|
|
|
|
internal ReadOnlyCollection<RarFilePart> FileParts { get; }
|
|
|
|
internal FileInfo FileInfo { get; }
|
|
|
|
internal override RarFilePart CreateFilePart(MarkHeader markHeader, FileHeader fileHeader)
|
|
{
|
|
return new FileInfoRarFilePart(
|
|
this,
|
|
ReaderOptions.Password,
|
|
markHeader,
|
|
fileHeader,
|
|
FileInfo
|
|
);
|
|
}
|
|
|
|
internal override IEnumerable<RarFilePart> ReadFileParts()
|
|
{
|
|
return FileParts;
|
|
}
|
|
}
|
|
}
|