diff --git a/.gitignore b/.gitignore index 3aacfc27..86591033 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ TestResults/ packages/*/ project.lock.json test/TestArchives/Scratch +.vs diff --git a/global.json b/global.json index 29fdab68..d0f936b5 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,3 @@ { - "projects": ["src","test"], - "sdk": { - "version": "1.0.0-rc1-final" - } + "projects": ["src","test"] } diff --git a/src/SharpCompress/Common/Tar/Headers/EntryType.cs b/src/SharpCompress/Common/Tar/Headers/EntryType.cs index bcc66f83..a8b55ea6 100644 --- a/src/SharpCompress/Common/Tar/Headers/EntryType.cs +++ b/src/SharpCompress/Common/Tar/Headers/EntryType.cs @@ -14,5 +14,6 @@ LongName = (byte) 'L', SparseFile = (byte) 'S', VolumeHeader = (byte) 'V', + GlobalExtendedHeader = (byte) 'g', } } \ No newline at end of file diff --git a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs index 0ad1a5cd..cda9f131 100644 --- a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs +++ b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs @@ -5,7 +5,6 @@ using SharpCompress.Converter; namespace SharpCompress.Common.Tar.Headers { - GlobalExtendedHeader = (byte) 'g', internal class TarHeader { internal static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); @@ -25,25 +24,25 @@ namespace SharpCompress.Common.Tar.Headers { byte[] buffer = new byte[512]; - WriteOctalBytes(511, buffer, 100, 8); // file mode - WriteOctalBytes(0, buffer, 108, 8); // owner ID - WriteOctalBytes(0, buffer, 116, 8); // group ID + WriteOctalBytes(511, buffer, 100, 8); // file mode + WriteOctalBytes(0, buffer, 108, 8); // owner ID + WriteOctalBytes(0, buffer, 116, 8); // group ID //Encoding.UTF8.GetBytes("magic").CopyTo(buffer, 257); if (Name.Length > 100) { // Set mock filename and filetype to indicate the next block is the actual name of the file WriteStringBytes("././@LongLink", buffer, 0, 100); - buffer[156] = (byte)EntryType.LongName; + buffer[156] = (byte) EntryType.LongName; WriteOctalBytes(Name.Length + 1, buffer, 124, 12); } else { WriteStringBytes(Name, buffer, 0, 100); WriteOctalBytes(Size, buffer, 124, 12); - var time = (long)(LastModifiedTime.ToUniversalTime() - Epoch).TotalSeconds; + var time = (long) (LastModifiedTime.ToUniversalTime() - Epoch).TotalSeconds; WriteOctalBytes(time, buffer, 136, 12); - buffer[156] = (byte)EntryType; + buffer[156] = (byte) EntryType; if (Size >= 0x1FFFFFFFF) { @@ -67,13 +66,14 @@ namespace SharpCompress.Common.Tar.Headers Write(output); } } + private void WriteLongFilenameHeader(Stream output) { byte[] nameBytes = ArchiveEncoding.Default.GetBytes(Name); output.Write(nameBytes, 0, nameBytes.Length); // pad to multiple of 512 bytes, and make sure a terminating null is added - int numPaddingBytes = 512 - (nameBytes.Length % 512); + int numPaddingBytes = 512 - (nameBytes.Length%512); if (numPaddingBytes == 0) numPaddingBytes = 512; output.Write(new byte[numPaddingBytes], 0, numPaddingBytes); @@ -110,7 +110,8 @@ namespace SharpCompress.Common.Tar.Headers Magic = ArchiveEncoding.Default.GetString(buffer, 257, 6).TrimNulls(); - if (!string.IsNullOrEmpty(Magic) && "ustar".Equals(Magic)) + if (!string.IsNullOrEmpty(Magic) + && "ustar".Equals(Magic)) { string namePrefix = ArchiveEncoding.Default.GetString(buffer, 345, 157); namePrefix = namePrefix.TrimNulls(); @@ -119,7 +120,8 @@ namespace SharpCompress.Common.Tar.Headers Name = namePrefix + "/" + Name; } } - if (EntryType != EntryType.LongName && Name.Length == 0) + if (EntryType != EntryType.LongName + && Name.Length == 0) { return false; } diff --git a/src/SharpCompress/Compressor/LZMA/AesDecoderStream.cs b/src/SharpCompress/Compressor/LZMA/AesDecoderStream.cs index ba83fdc8..9008ff47 100644 --- a/src/SharpCompress/Compressor/LZMA/AesDecoderStream.cs +++ b/src/SharpCompress/Compressor/LZMA/AesDecoderStream.cs @@ -9,28 +9,28 @@ namespace SharpCompress.Compressor.LZMA { internal class AesDecoderStream : DecoderStream2 { -#region Variables + #region Variables - private Stream mStream; - private ICryptoTransform mDecoder; - private byte[] mBuffer; + private readonly Stream mStream; + private readonly ICryptoTransform mDecoder; + private readonly byte[] mBuffer; private long mWritten; - private long mLimit; + private readonly long mLimit; private int mOffset; private int mEnding; private int mUnderflow; private bool isDisposed; -#endregion + #endregion -#region Stream Methods + #region Stream Methods public AesDecoderStream(Stream input, byte[] info, IPasswordProvider pass, long limit) { mStream = input; mLimit = limit; - if (((uint)input.Length & 15) != 0) + if (((uint) input.Length & 15) != 0) throw new NotSupportedException("AES decoder does not support padding."); int numCyclesPower; @@ -73,17 +73,24 @@ namespace SharpCompress.Compressor.LZMA public override long Position { - get { return mWritten; } + get + { + return mWritten; + } } public override long Length { - get { return mLimit; } + get + { + return mLimit; + } } public override int Read(byte[] buffer, int offset, int count) { - if (count == 0 || mWritten == mLimit) + if (count == 0 + || mWritten == mLimit) return 0; if (mUnderflow > 0) @@ -106,14 +113,15 @@ namespace SharpCompress.Compressor.LZMA } mEnding += read; - } while (mEnding - mOffset < 16); + } + while (mEnding - mOffset < 16); } // We shouldn't return more data than we are limited to. // Currently this is handled by forcing an underflow if // the stream length is not a multiple of the block size. if (count > mLimit - mWritten) - count = (int)(mLimit - mWritten); + count = (int) (mLimit - mWritten); // We cannot transform less than 16 bytes into the target buffer, // but we also cannot return zero, so we need to handle this. @@ -131,9 +139,9 @@ namespace SharpCompress.Compressor.LZMA return processed; } -#endregion + #endregion -#region Private Methods + #region Private Methods private void Init(byte[] info, out int numCyclesPower, out byte[] salt, out byte[] iv) { @@ -186,7 +194,7 @@ namespace SharpCompress.Compressor.LZMA } else { -#if DOTNET54 || DOTNET51 +#if NETSTANDARD13 using (IncrementalHash sha = IncrementalHash.CreateHash(HashAlgorithmName.SHA256)) { byte[] counter = new byte[8]; @@ -250,7 +258,8 @@ namespace SharpCompress.Compressor.LZMA return count; } -#endregion + #endregion } } + #endif \ No newline at end of file diff --git a/src/SharpCompress/SharpCompress.xproj b/src/SharpCompress/SharpCompress.xproj index e585095c..269099f5 100644 --- a/src/SharpCompress/SharpCompress.xproj +++ b/src/SharpCompress/SharpCompress.xproj @@ -4,17 +4,16 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - + fd19ddd8-72b2-4024-8665-0d1f7a2aa998 SharpCompress - ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\obj + .\bin\ + v4.5.2 - 2.0 - + diff --git a/src/SharpCompress/project.json b/src/SharpCompress/project.json index b64ae0ad..b74e2dd9 100644 --- a/src/SharpCompress/project.json +++ b/src/SharpCompress/project.json @@ -1,87 +1,65 @@ { - "version": "0.11.4", + "version": "0.12.0", "title": "SharpCompress - Pure C# Decompression/Compression", "authors": [ "Adam Hathcock" ], - "owners": [ "Adam Hathcock" ], - "tags": [ "rar", "unrar", "zip", "unzip", "bzip2", "gzip", "tar", "7zip" ], - "projectUrl": "https://github.com/adamhathcock/sharpcompress", - "licenseUrl": "https://github.com/adamhathcock/sharpcompress/blob/master/LICENSE.txt", - "description": "SharpCompress is a compression library for .NET/Mono/Silverlight/WP7/WindowsStore that can unrar, decompress 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.", "language": "en-US", - "requireLicenseAcceptance": false, + "packOptions": { + "owners": [ "Adam Hathcock" ], + "tags": [ "rar", "unrar", "zip", "unzip", "bzip2", "gzip", "tar", "7zip" ], + "projectUrl": "https://github.com/adamhathcock/sharpcompress", + "licenseUrl": "https://github.com/adamhathcock/sharpcompress/blob/master/LICENSE.txt", + "description": "SharpCompress is a compression library for .NET/Mono/Silverlight/WP7/WindowsStore that can unrar, decompress 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.", + "requireLicenseAcceptance": false + }, "frameworks": { "net35": { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "allowUnsafe": true } }, "net40": { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "allowUnsafe": true } }, "net45": { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "allowUnsafe": true } }, - ".NETPortable,Version=v4.5,Profile=Profile259": { - "compilationOptions": { + "netstandard1.0": { + "buildOptions": { "warningsAsErrors": true, "allowUnsafe": true, - "define": [ "PROFILE259", "NO_FILE", "NO_CRYPTO" ] - }, - "frameworkAssemblies": { - "Microsoft.CSharp": "", - "System.Collections": "", - "System.Diagnostics.Debug": "", - "System.Dynamic.Runtime": "", - "System.Globalization": "", - "System.IO": "", - "System.Linq": "", - "System.Reflection": "", - "System.Reflection.Extensions": "", - "System.Runtime": "", - "System.Runtime.Extensions": "", - "System.Core": "", - "System.Threading": "", - "System.Threading.Tasks": "", - "System.Text.Encoding": "4.0.0.0" - } - }, - "dotnet5.1": { - "compilationOptions": { - "warningsAsErrors": true, - "allowUnsafe": true, - "define": [ "DOTNET51", "NO_FILE" ] + "define": [ "NETSTANDARD10", "NO_FILE" ] }, "dependencies": { - "System.Collections": "4.0.11-beta-23516", - "System.Diagnostics.Debug": "4.0.11-beta-23516", - "System.IO": "4.0.11-beta-23516", - "System.Linq": "4.0.1-beta-23516", - "System.Runtime.Extensions": "4.0.11-beta-23516", - "System.Security.Cryptography.Algorithms": "4.0.0-beta-23516", - "System.Text.Encoding.Extensions": "4.0.11-beta-23516" + "System.Collections": "4.0.11-rc2-24027", + "System.Diagnostics.Debug": "4.0.11-rc2-24027", + "System.IO": "4.1.0-rc2-24027", + "System.Linq": "4.1.0-rc2-24027", + "System.Runtime.Extensions": "4.1.0-rc2-24027", + "System.Text.Encoding.Extensions": "4.0.11-rc2-24027" } }, - "dotnet5.4": { - "compilationOptions": { + "netstandard1.3": { + "buildOptions": { "warningsAsErrors": true, "allowUnsafe": true, - "define": [ "DOTNET54" ] + "define": [ "NETSTANDARD13" ] }, "dependencies": { - "System.Collections": "4.0.11-beta-23516", - "System.Diagnostics.Debug": "4.0.11-beta-23516", - "System.IO": "4.0.11-beta-23516", - "System.IO.FileSystem": "4.0.1-beta-23516", - "System.Linq": "4.0.1-beta-23516", - "System.Security.Cryptography.Algorithms": "4.0.0-beta-23516", - "System.Text.Encoding.Extensions": "4.0.11-beta-23516" + "System.Collections": "4.0.11-rc2-24027", + "System.Diagnostics.Debug": "4.0.11-rc2-24027", + "System.IO": "4.1.0-rc2-24027", + "System.IO.FileSystem": "4.0.1-rc2-24027", + "System.Linq": "4.1.0-rc2-24027", + "System.Runtime.Extensions": "4.1.0-rc2-24027", + "System.Security.Cryptography.Algorithms": "4.1.0-rc2-24027", + "System.Text.Encoding.Extensions": "4.0.11-rc2-24027" } } } diff --git a/test/SharpCompress.Test/SharpCompress.Test.xproj b/test/SharpCompress.Test/SharpCompress.Test.xproj index 23b3f832..707a4032 100644 --- a/test/SharpCompress.Test/SharpCompress.Test.xproj +++ b/test/SharpCompress.Test/SharpCompress.Test.xproj @@ -4,12 +4,13 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 3b80e585-a2f3-4666-8f69-c7ffda0dd7e5 SharpCompress.Test - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + .\obj + .\bin\ + v4.5.2 2.0 @@ -17,5 +18,5 @@ - + \ No newline at end of file diff --git a/test/SharpCompress.Test/project.json b/test/SharpCompress.Test/project.json index 3fd5aa08..fa86b255 100644 --- a/test/SharpCompress.Test/project.json +++ b/test/SharpCompress.Test/project.json @@ -3,17 +3,20 @@ "test": "xunit.runner.dnx -parallel none" }, "frameworks": { - "dnxcore50": { + "netcoreapp1.0": { + "imports": [ + "dnxcore50" + ] } }, "dependencies": { - "Microsoft.CSharp": "4.0.1-beta-23516", - "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final", - "System.Console": "4.0.0-beta-23516", - "System.Collections": "4.0.11-beta-23516", - "System.Linq": "4.0.1-beta-23516", - "System.Runtime": "4.0.21-beta-23516", - "System.Threading": "4.0.11-beta-23516", + "Microsoft.CSharp": "4.0.1-rc2-24027", + "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final", + "System.Console": "4.0.0-rc2-24027", + "System.Collections": "4.0.11-rc2-24027", + "System.Linq": "4.1.0-rc2-24027", + "System.Runtime": "4.1.0-rc2-24027", + "System.Threading": "4.0.11-rc2-24027", "SharpCompress": "0.11.4", "xunit": "2.1.0", "xunit.runner.dnx": "2.1.0-rc1-build204"