Compare commits

...

4 Commits

Author SHA1 Message Date
Adam Hathcock
3a52c68270 0.12.3 2016-07-22 16:50:33 +01:00
Adam Hathcock
89fd778bd8 Make all framework assemblies be build targets as a fix https://github.com/NuGet/Home/issues/3103 2016-07-22 16:47:59 +01:00
Tobias Käs
6e3e8343a8 Ignore unofficial extension of file attributes. (#153)
The high bits may contain posix file attributes when the archive was written by certain third party 7z implementations. These must be removed before we can interpret the attributes as windows (or .NET) file attributes.
2016-07-21 11:06:42 +01:00
Tobias Käs
9224237a99 Fix for issue #73 (#154)
7z archives may require alternating reads from multiple substreams so it is important to seek before reading from the underlying stream. To keep performance at an acceptable level it is necessary to perform buffering because seeking on every single one-byte-read will destroy performance.
2016-07-21 11:06:25 +01:00
5 changed files with 145 additions and 17 deletions

View File

@@ -34,6 +34,10 @@ I'm always looking for help or ideas. Please submit code or email with ideas. Un
## Version Log
### Version 0.12.3
* 7Zip fixes https://github.com/adamhathcock/sharpcompress/issues/73
* Maybe all profiles will work with project.json now
### Version 0.12.2
* Support Profile 259 again

View File

@@ -895,6 +895,26 @@ namespace SharpCompress.Common.SevenZip
#endif
ReadAttributeVector(dataVector, numFiles, delegate(int i, uint? attr)
{
// Some third party implementations established an unofficial extension
// of the 7z archive format by placing posix file attributes in the high
// bits of the windows file attributes. This makes use of the fact that
// the official implementation does not perform checks on this value.
//
// Newer versions of the official 7z GUI client will try to parse this
// extension, thus acknowledging the unofficial use of these bits.
//
// For us it is safe to just discard the upper bits if they are set and
// keep the windows attributes from the lower bits (which should be set
// properly even if posix file attributes are present, in order to be
// compatible with older 7z archive readers)
//
// Note that the 15th bit is used by some implementations to indicate
// presence of the extension, but not all implementations do that so
// we can't trust that bit and must ignore it.
//
if (attr.HasValue && (attr.Value >> 16) != 0)
attr = attr.Value & 0x7FFFu;
db.Files[i].Attrib = attr;
#if DEBUG
Log.Write(" " + (attr.HasValue ? attr.Value.ToString("x8") : "n/a"));

View File

@@ -162,7 +162,7 @@ namespace SharpCompress.Compressor.LZMA
Stream[] inStreams = new Stream[folderInfo.PackStreams.Count];
for (int j = 0; j < folderInfo.PackStreams.Count; j++)
{
inStreams[j] = new ReadOnlySubStream(inStream, startPos, packSizes[j]);
inStreams[j] = new BufferedSubStream(inStream, startPos, packSizes[j]);
startPos += packSizes[j];
}

View File

@@ -0,0 +1,105 @@
using System.IO;
namespace SharpCompress.IO
{
internal class BufferedSubStream : Stream
{
private long position;
private int cacheOffset;
private int cacheLength;
private byte[] cache;
public BufferedSubStream(Stream stream, long origin, long bytesToRead)
{
Stream = stream;
position = origin;
BytesLeftToRead = bytesToRead;
cache = new byte[32 << 10];
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
//Stream.Dispose();
}
}
private long BytesLeftToRead { get; set; }
public Stream Stream { get; private set; }
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return false; }
}
public override void Flush()
{
throw new System.NotSupportedException();
}
public override long Length
{
get { throw new System.NotSupportedException(); }
}
public override long Position
{
get { throw new System.NotSupportedException(); }
set { throw new System.NotSupportedException(); }
}
public override int Read(byte[] buffer, int offset, int count)
{
if (count > BytesLeftToRead)
count = (int)BytesLeftToRead;
if (count > 0)
{
if (cacheLength == 0)
{
cacheOffset = 0;
Stream.Position = position;
cacheLength = Stream.Read(cache, 0, cache.Length);
position += cacheLength;
}
if (count > cacheLength)
count = cacheLength;
System.Buffer.BlockCopy(cache, cacheOffset, buffer, offset, count);
cacheOffset += count;
cacheLength -= count;
BytesLeftToRead -= count;
}
return count;
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new System.NotSupportedException();
}
public override void SetLength(long value)
{
throw new System.NotSupportedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new System.NotSupportedException();
}
}
}

View File

@@ -1,5 +1,5 @@
{
"version": "0.12.2",
"version": "0.12.3",
"title": "SharpCompress - Pure C# Decompression/Compression",
"authors": [ "Adam Hathcock" ],
"language": "en-US",
@@ -37,9 +37,9 @@
"define": [ "NO_FILE", "NO_CRYPTO", "SILVERLIGHT" ]
},
"frameworkAssemblies": {
"mscorlib": "",
"System": "",
"System.Core": ""
"mscorlib": { "type": "build" },
"System": { "type": "build" },
"System.Core": { "type": "build" }
}
},
".NETPortable,Version=v4.5,Profile=Profile259": {
@@ -49,18 +49,17 @@
"define": [ "NO_FILE", "NO_CRYPTO", "SILVERLIGHT" ]
},
"frameworkAssemblies": {
"Microsoft.CSharp": "",
"System": "",
"System.Collections": "",
"System.Core": "",
"System.Diagnostics.Debug": "",
"System.IO": "",
"System.Linq": "",
"System.Linq.Expressions": "",
"System.Resources.ResourceManager": "",
"System.Runtime": "",
"System.Runtime.Extensions": "",
"System.Text.Encoding": ""
"System": { "type": "build" },
"System.Collections": { "type": "build" },
"System.Core": { "type": "build" },
"System.Diagnostics.Debug": { "type": "build" },
"System.IO": { "type": "build" },
"System.Linq": { "type": "build" },
"System.Linq.Expressions": { "type": "build" },
"System.Resources.ResourceManager": { "type": "build" },
"System.Runtime": { "type": "build" },
"System.Runtime.Extensions": { "type": "build" },
"System.Text.Encoding": { "type": "build" }
}
},
"netstandard1.0": {