mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-05 21:23:57 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a52c68270 | ||
|
|
89fd778bd8 | ||
|
|
6e3e8343a8 | ||
|
|
9224237a99 |
@@ -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
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
105
src/SharpCompress/IO/BufferedSubStream.cs
Normal file
105
src/SharpCompress/IO/BufferedSubStream.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user