mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-10-01 11:22:44 +00:00
Conflicts: NuGet/sharpcompress.nuspec SharpCompress/Common/Zip/WinzipAesCryptoStream.Portable.cs SharpCompress/Common/Zip/WinzipAesEncryptionData.Portable.cs SharpCompress/Crypto/PBKDF2.cs SharpCompress/SharpCompress.Portable.csproj SharpCompress/SharpCompress.PortableTest.csproj SharpCompress/SharpCompress.Unsigned.csproj SharpCompress/SharpCompress.WindowsStore.csproj SharpCompress/SharpCompress.csproj src/SharpCompress/Archive/ArchiveFactory.cs src/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs src/SharpCompress/Archive/Rar/RarArchive.cs src/SharpCompress/Archive/Rar/RarArchiveEntry.cs src/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs src/SharpCompress/Common/GZip/GZipFilePart.cs src/SharpCompress/Common/GZip/GZipVolume.cs src/SharpCompress/Common/Rar/Headers/MarkHeader.cs src/SharpCompress/Common/Rar/Headers/RarHeaderFactory.cs src/SharpCompress/Common/SevenZip/ArchiveReader.cs src/SharpCompress/Common/SevenZip/DataReader.cs src/SharpCompress/Common/Tar/Headers/TarHeader.cs src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs src/SharpCompress/Common/Zip/ZipFilePart.cs src/SharpCompress/Compressor/Deflate/GZipStream.cs src/SharpCompress/Compressor/Deflate/Inflate.cs src/SharpCompress/Compressor/Deflate/ZlibBaseStream.cs src/SharpCompress/Compressor/LZMA/Bcj2DecoderStream.cs src/SharpCompress/Compressor/LZMA/LzmaStream.cs src/SharpCompress/Compressor/PPMd/H/FreqData.cs src/SharpCompress/Compressor/PPMd/H/PPMContext.cs src/SharpCompress/Compressor/PPMd/H/RarMemBlock.cs src/SharpCompress/Compressor/PPMd/H/RarNode.cs src/SharpCompress/Compressor/PPMd/H/State.cs src/SharpCompress/Compressor/PPMd/PpmdProperties.cs src/SharpCompress/Compressor/Rar/VM/RarVM.cs src/SharpCompress/EnumExtensions.cs src/SharpCompress/IO/MarkingBinaryReader.cs src/SharpCompress/Reader/ReaderFactory.cs src/SharpCompress/Utility.cs src/SharpCompress/Writer/IWriter.Extensions.cs src/SharpCompress/Writer/Zip/ZipCentralDirectoryEntry.cs src/SharpCompress/Writer/Zip/ZipWriter.cs test/SharpCompress.Test/Tar/TarArchiveTests.cs test/SharpCompress.Test/Tar/TarReaderTests.cs
124 lines
3.0 KiB
C#
124 lines
3.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using SharpCompress.Converter;
|
|
|
|
namespace SharpCompress.IO
|
|
{
|
|
internal class MarkingBinaryReader : BinaryReader
|
|
{
|
|
|
|
public MarkingBinaryReader(Stream stream)
|
|
: base(stream)
|
|
{
|
|
}
|
|
|
|
public long CurrentReadByteCount { get; private set; }
|
|
|
|
public void Mark()
|
|
{
|
|
CurrentReadByteCount = 0;
|
|
}
|
|
|
|
public override int Read()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override int Read(byte[] buffer, int index, int count)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override int Read(char[] buffer, int index, int count)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override bool ReadBoolean()
|
|
{
|
|
return ReadBytes(1).Single() != 0;
|
|
}
|
|
|
|
public override byte ReadByte()
|
|
{
|
|
return ReadBytes(1).Single();
|
|
}
|
|
|
|
public override byte[] ReadBytes(int count)
|
|
{
|
|
CurrentReadByteCount += count;
|
|
var bytes = base.ReadBytes(count);
|
|
if (bytes.Length != count)
|
|
{
|
|
throw new EndOfStreamException(string.Format("Could not read the requested amount of bytes. End of stream reached. Requested: {0} Read: {1}", count, bytes.Length));
|
|
}
|
|
return bytes;
|
|
}
|
|
|
|
public override char ReadChar()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override char[] ReadChars(int count)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override decimal ReadDecimal()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override double ReadDouble()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override short ReadInt16()
|
|
{
|
|
return DataConverter.LittleEndian.GetInt16(ReadBytes(2), 0);
|
|
}
|
|
|
|
public override int ReadInt32()
|
|
{
|
|
return DataConverter.LittleEndian.GetInt32(ReadBytes(4), 0);
|
|
}
|
|
|
|
public override long ReadInt64()
|
|
{
|
|
return DataConverter.LittleEndian.GetInt64(ReadBytes(8), 0);
|
|
}
|
|
|
|
public override sbyte ReadSByte()
|
|
{
|
|
return (sbyte)ReadByte();
|
|
}
|
|
|
|
public override float ReadSingle()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override string ReadString()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override ushort ReadUInt16()
|
|
{
|
|
return DataConverter.LittleEndian.GetUInt16(ReadBytes(2), 0);
|
|
}
|
|
|
|
public override uint ReadUInt32()
|
|
{
|
|
return DataConverter.LittleEndian.GetUInt32(ReadBytes(4), 0);
|
|
}
|
|
|
|
public override ulong ReadUInt64()
|
|
{
|
|
return DataConverter.LittleEndian.GetUInt64(ReadBytes(8), 0);
|
|
}
|
|
}
|
|
} |