mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00ce509b08 | ||
|
|
13ef1c3701 | ||
|
|
ee2d6216b7 | ||
|
|
a42414bdaa | ||
|
|
3e201053c6 | ||
|
|
46c03ce027 | ||
|
|
718dac1a31 | ||
|
|
137f2655a5 | ||
|
|
8109ae003d | ||
|
|
8325b919ce | ||
|
|
61c97faf6c | ||
|
|
2dc297394f |
@@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>sharpcompress</id>
|
||||
<version>0.10</version>
|
||||
<version>0.10.1.3</version>
|
||||
<title>SharpCompress - Pure C# Decompression/Compression</title>
|
||||
<authors>Adam Hathcock</authors>
|
||||
<owners>Adam Hathcock</owners>
|
||||
@@ -15,8 +15,8 @@
|
||||
<tags>rar unrar zip unzip bzip2 gzip tar 7zip .net40 .net35 sl4</tags>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\bin\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
|
||||
<file src="..\bin\SharpCompress.WindowsStore.dll" target="lib\netcore45\SharpCompress.WindowsStore.dll" />
|
||||
<file src="..\bin\SharpCompress.Portable.dll" target="lib\portable-net4+sl4+wp7+win8\SharpCompress.Portable.dll" />
|
||||
<file src="..\bin\Full\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
|
||||
<file src="..\bin\WindowsStore\SharpCompress.dll" target="lib\netcore45\SharpCompress.dll" />
|
||||
<file src="..\bin\Portable\SharpCompress.dll" target="lib\portable-net4+sl4+wp7+win8\SharpCompress.dll" />
|
||||
</files>
|
||||
</package>
|
||||
@@ -21,6 +21,9 @@ TODOs (always lots):
|
||||
* Zip64
|
||||
* Multi-volume Zip support.
|
||||
|
||||
Version 0.10.1:
|
||||
==============
|
||||
- Fixed 7Zip extraction performance problem
|
||||
|
||||
Version 0.10:
|
||||
==============
|
||||
|
||||
@@ -61,6 +61,17 @@ namespace SharpCompress.Test
|
||||
ArchiveFileRead("7Zip.BZip2.7z");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SevenZipArchive_LZMA2_SFX_PathRead()
|
||||
{
|
||||
ArchiveFileRead("7Zip.LZMA2.sfx.exe");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SevenZipArchive_LZMA2_SFX_StreamRead() {
|
||||
ArchiveStreamRead("7Zip.LZMA2.sfx.exe");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -10,12 +11,13 @@ namespace SharpCompress.Test
|
||||
{
|
||||
public class TestBase
|
||||
{
|
||||
protected const string TEST_BASE_PATH = @"C:\Git\sharpcompress";
|
||||
protected static readonly string TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
|
||||
protected static readonly string ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
|
||||
protected static readonly string MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
|
||||
protected static readonly string SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
|
||||
protected static readonly string SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");
|
||||
//protected const string TEST_BASE_PATH = @"C:\Git\sharpcompress";
|
||||
protected static string TEST_BASE_PATH=null;
|
||||
protected static string TEST_ARCHIVES_PATH;
|
||||
protected static string ORIGINAL_FILES_PATH;
|
||||
protected static string MISC_TEST_FILES_PATH;
|
||||
protected static string SCRATCH_FILES_PATH;
|
||||
protected static string SCRATCH2_FILES_PATH;
|
||||
|
||||
protected static IEnumerable<string> GetRarArchives()
|
||||
{
|
||||
@@ -152,10 +154,26 @@ namespace SharpCompress.Test
|
||||
|
||||
private static readonly object testLock = new object();
|
||||
|
||||
private TestContext ctx;
|
||||
public TestContext TestContext {
|
||||
get {
|
||||
return ctx;
|
||||
}
|
||||
set {
|
||||
ctx = value;
|
||||
}
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void TestSetup()
|
||||
{
|
||||
Monitor.Enter(testLock);
|
||||
TEST_BASE_PATH = Path.GetDirectoryName(Path.GetDirectoryName(ctx.TestDir));
|
||||
TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
|
||||
ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
|
||||
MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
|
||||
SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
|
||||
SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -15,91 +15,48 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Test.Portable
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F18F1765-4A02-42FD-9BEF-F0E2FCBD9D17}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
NuGet\sharpcompress.nuspec = NuGet\sharpcompress.nuspec
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x64.Build.0 = Debug|x64
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x86.Build.0 = Debug|x86
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|ARM.Build.0 = Release|ARM
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x64.ActiveCfg = Release|x64
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x64.Build.0 = Release|x64
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x86.ActiveCfg = Release|x86
|
||||
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x86.Build.0 = Release|x86
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
{E9C3C94B-FB27-4B4F-B225-57513C254D37} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -43,10 +43,12 @@ namespace SharpCompress.Archive
|
||||
return TarArchive.Open(stream, options);
|
||||
}
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
if (SevenZipArchive.IsSevenZipFile(stream))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return SevenZipArchive.Open(stream, options);
|
||||
long offset = SevenZipArchive.FindSignature(stream);
|
||||
if (offset > -1) {
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
return SevenZipArchive.Open(stream, options);
|
||||
}
|
||||
}
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
if (GZipArchive.IsGZipFile(stream))
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace SharpCompress.Archive.SevenZip
|
||||
{
|
||||
if (database == null)
|
||||
{
|
||||
stream.Position = 0;
|
||||
stream.Seek(FindSignature(stream),SeekOrigin.Begin);
|
||||
var reader = new ArchiveReader();
|
||||
reader.Open(stream);
|
||||
database = reader.ReadDatabase(null);
|
||||
@@ -157,7 +157,7 @@ namespace SharpCompress.Archive.SevenZip
|
||||
{
|
||||
try
|
||||
{
|
||||
return SignatureMatch(stream);
|
||||
return FindSignature(stream)>-1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -165,13 +165,27 @@ namespace SharpCompress.Archive.SevenZip
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly byte[] SIGNATURE = new byte[] {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
|
||||
private static bool SignatureMatch(Stream stream)
|
||||
{
|
||||
private static readonly byte[] SIGNATURE = {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
const int MAX_BYTES_TO_ARCHIVE = 0x40000;
|
||||
public static long FindSignature(Stream stream){
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
byte[] signatureBytes = reader.ReadBytes(6);
|
||||
return signatureBytes.BinaryEquals(SIGNATURE);
|
||||
int j = 0;
|
||||
long match=-1;
|
||||
var maxPos = Math.Min(MAX_BYTES_TO_ARCHIVE+SIGNATURE.Length, stream.Length);
|
||||
for (; stream.Position < maxPos; ) {
|
||||
var bt = reader.ReadByte();
|
||||
if (bt == SIGNATURE[j]){
|
||||
if (j == SIGNATURE.Length-1){
|
||||
match = stream.Position - j-1;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
protected override IReader CreateReaderForSolidExtraction()
|
||||
|
||||
@@ -10,10 +10,10 @@ using System.Runtime.CompilerServices;
|
||||
[assembly: AssemblyProduct("SharpCompress")]
|
||||
[assembly:
|
||||
InternalsVisibleTo(
|
||||
"SharpCompress.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
|
||||
"SharpCompress.Test"
|
||||
)]
|
||||
[assembly:
|
||||
InternalsVisibleTo(
|
||||
"SharpCompress.Test.Portable, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
|
||||
"SharpCompress.Test.Portable"
|
||||
)]
|
||||
#endif
|
||||
@@ -941,6 +941,7 @@ namespace SharpCompress.Common.SevenZip
|
||||
|
||||
#region Public Methods
|
||||
|
||||
const int HEADER_SIZE=0x20;
|
||||
public void Open(Stream stream)
|
||||
{
|
||||
Close();
|
||||
@@ -949,13 +950,14 @@ namespace SharpCompress.Common.SevenZip
|
||||
_streamEnding = stream.Length;
|
||||
|
||||
// TODO: Check Signature!
|
||||
_header = new byte[0x20];
|
||||
for (int offset = 0; offset < 0x20; )
|
||||
_header = new byte[HEADER_SIZE];
|
||||
int delta;
|
||||
for (int offset = 0; offset < HEADER_SIZE; offset += delta)
|
||||
{
|
||||
int delta = stream.Read(_header, offset, 0x20 - offset);
|
||||
delta = stream.Read(_header, offset, HEADER_SIZE - offset);
|
||||
if (delta == 0)
|
||||
throw new EndOfStreamException();
|
||||
offset += delta;
|
||||
throw new EndOfStreamException("ArchiveReader.Open : unable to read");
|
||||
|
||||
}
|
||||
|
||||
_stream = stream;
|
||||
@@ -995,7 +997,7 @@ namespace SharpCompress.Common.SevenZip
|
||||
crc = CRC.Finish(crc);
|
||||
|
||||
if (crc != crcFromArchive)
|
||||
throw new InvalidOperationException();
|
||||
throw new InvalidOperationException("Bad CRC");
|
||||
|
||||
db.StartPositionAfterHeader = _streamOrigin + 0x20;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using SharpCompress.Common.SevenZip;
|
||||
using SharpCompress.Compressor.LZMA.Utilites;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressor.LZMA
|
||||
{
|
||||
@@ -158,12 +159,10 @@ namespace SharpCompress.Compressor.LZMA
|
||||
if (!folderInfo.CheckStructure())
|
||||
throw new NotSupportedException("Unsupported stream binding structure.");
|
||||
|
||||
// We have multiple views into the same stream which will be used by several threads - need to sync those.
|
||||
object sync = new object();
|
||||
Stream[] inStreams = new Stream[folderInfo.PackStreams.Count];
|
||||
for (int j = 0; j < folderInfo.PackStreams.Count; j++)
|
||||
{
|
||||
inStreams[j] = new SyncStreamView(sync, inStream, startPos, packSizes[j]);
|
||||
inStreams[j] = new ReadOnlySubStream(inStream, startPos, packSizes[j]);
|
||||
startPos += packSizes[j];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SharpCompress.Compressor.LZMA.Utilites
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows reading the same stream from multiple threads by synchronizing read access.
|
||||
/// </summary>
|
||||
internal class SyncStreamView : Stream
|
||||
{
|
||||
private object mSync;
|
||||
private Stream mStream;
|
||||
private long mOrigin;
|
||||
private long mEnding;
|
||||
private long mOffset;
|
||||
private bool isDisposed;
|
||||
|
||||
public SyncStreamView(object sync, Stream stream, long origin, long length)
|
||||
{
|
||||
mSync = sync;
|
||||
mStream = stream;
|
||||
mOrigin = origin;
|
||||
mEnding = checked(origin + length);
|
||||
mOffset = 0;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (isDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isDisposed = true;
|
||||
base.Dispose(disposing);
|
||||
mStream.Dispose();
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return mEnding - mOrigin; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return mOffset; }
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > Length)
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
|
||||
mOffset = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
long remaining = mEnding - mOrigin - mOffset;
|
||||
if (count > remaining)
|
||||
count = (int)remaining;
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
int delta;
|
||||
lock (mSync)
|
||||
{
|
||||
mStream.Position = mOrigin + mOffset;
|
||||
delta = mStream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
mOffset += delta;
|
||||
return delta;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
return Position = offset;
|
||||
case SeekOrigin.Current:
|
||||
return Position += offset;
|
||||
case SeekOrigin.End:
|
||||
return Position = Length + offset;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("origin");
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace master._7zip.Utilities
|
||||
{
|
||||
/// <remarks>
|
||||
/// This stream is a length-constrained wrapper around a cached stream so it does not dispose the inner stream.
|
||||
/// </remarks>
|
||||
internal class UnpackSubStream: Stream
|
||||
{
|
||||
private Stream mSource;
|
||||
private long mLength;
|
||||
private long mOffset;
|
||||
|
||||
internal UnpackSubStream(Stream source, long length)
|
||||
{
|
||||
mSource = source;
|
||||
mLength = length;
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return mSource.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return mLength; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return mOffset; }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if(buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
|
||||
if(offset < 0 || offset > buffer.Length)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
|
||||
if(count < 0 || count > buffer.Length - offset)
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
|
||||
if(count > mLength - mOffset)
|
||||
count = (int)(mLength - mOffset);
|
||||
|
||||
if(count == 0)
|
||||
return 0;
|
||||
|
||||
int processed = mSource.Read(buffer, offset, count);
|
||||
if(processed == 0)
|
||||
throw new EndOfStreamException("Decoded stream ended prematurely, unpacked data is corrupt.");
|
||||
|
||||
mOffset += processed;
|
||||
return processed;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,17 @@ namespace SharpCompress.IO
|
||||
internal class ReadOnlySubStream : Stream
|
||||
{
|
||||
public ReadOnlySubStream(Stream stream, long bytesToRead)
|
||||
: this(stream, null, bytesToRead)
|
||||
{
|
||||
}
|
||||
|
||||
public ReadOnlySubStream(Stream stream, long? origin, long bytesToRead)
|
||||
{
|
||||
Stream = stream;
|
||||
if (origin != null)
|
||||
{
|
||||
stream.Position = origin.Value;
|
||||
}
|
||||
BytesLeftToRead = bytesToRead;
|
||||
}
|
||||
|
||||
@@ -57,7 +66,7 @@ namespace SharpCompress.IO
|
||||
{
|
||||
if (BytesLeftToRead < count)
|
||||
{
|
||||
count = (int) BytesLeftToRead;
|
||||
count = (int)BytesLeftToRead;
|
||||
}
|
||||
int read = Stream.Read(buffer, offset, count);
|
||||
if (read > 0)
|
||||
|
||||
@@ -7,19 +7,20 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SharpCompress</RootNamespace>
|
||||
<AssemblyName>SharpCompress.Portable</AssemblyName>
|
||||
<AssemblyName>SharpCompress</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Profile1</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
|
||||
<BaseIntermediateOutputPath>obj\Portable\</BaseIntermediateOutputPath>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Portable\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -28,7 +29,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Portable\</OutputPath>
|
||||
<DefineConstants>TRACE;PORTABLE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -203,8 +204,6 @@
|
||||
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\SyncStreamView.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\UnpackSubStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\Utils.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
|
||||
|
||||
@@ -207,9 +207,6 @@
|
||||
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Compressor\LZMA\Utilites\SyncStreamView.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Compressor\LZMA\Utilites\Utils.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -10,16 +10,17 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SharpCompress</RootNamespace>
|
||||
<AssemblyName>SharpCompress.WindowsStore</AssemblyName>
|
||||
<AssemblyName>SharpCompress</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<BaseIntermediateOutputPath>obj\WindowsStore\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\WindowsStore\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -27,77 +28,11 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\WindowsStore\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
|
||||
<Compile Include="Archive\AbstractArchive.cs" />
|
||||
@@ -259,8 +194,6 @@
|
||||
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\SyncStreamView.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\UnpackSubStream.cs" />
|
||||
<Compile Include="Compressor\LZMA\Utilites\Utils.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
|
||||
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<BaseIntermediateOutputPath>obj\Full\</BaseIntermediateOutputPath>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
@@ -49,7 +50,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Full\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;DISABLE_TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -57,18 +58,20 @@
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>..\bin\SharpCompress.XML</DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<OutputPath>..\bin\Full\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>..\bin\SharpCompress.xml</DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
@@ -209,9 +212,6 @@
|
||||
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Compressor\LZMA\Utilites\SyncStreamView.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Compressor\LZMA\Utilites\Utils.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © Adam Hathcock")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("0.10.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.10.0.0")]
|
||||
[assembly: AssemblyVersion("0.10.1.3")]
|
||||
[assembly: AssemblyFileVersion("0.10.1.3")]
|
||||
BIN
TestArchives/Archives/7Zip.LZMA2.sfx.exe
Normal file
BIN
TestArchives/Archives/7Zip.LZMA2.sfx.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user