diff --git a/Documentation/COPYING.txt b/Documentation/COPYING.txt deleted file mode 100644 index 7d1313a4f..000000000 --- a/Documentation/COPYING.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/GlobalAssemblyInfo.cs b/GlobalAssemblyInfo.cs index 12d70d608..e116e6a78 100644 --- a/GlobalAssemblyInfo.cs +++ b/GlobalAssemblyInfo.cs @@ -6,7 +6,7 @@ // associated with an assembly. [assembly: AssemblyCompany("ICSharpCode")] [assembly: AssemblyProduct("SharpZipLib (#ziplib)")] -[assembly: AssemblyCopyright("Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team")] +[assembly: AssemblyCopyright("Copyright © 2000-2016 SharpZipLib Contributors")] [assembly: AssemblyTrademark("")] #if DEBUG @@ -38,11 +38,11 @@ // Revision: the number of two second intervals since midnight in local time; i.e. 31308 = 17:23:36 local time. // Specifies the version of the assembly being attributed. -[assembly: AssemblyVersion("0.87.*")] +[assembly: AssemblyVersion("1.0.*")] // Instructs a compiler to use a specific version number for the Win32 file version resource. // The Win32 file version is not required to be the same as the assembly's version number. -[assembly: AssemblyFileVersion("0.87")] +[assembly: AssemblyFileVersion("1.0")] // Defines additional version information for an assembly manifest. -[assembly: AssemblyInformationalVersion("0.87 Cleanup Build")] +[assembly: AssemblyInformationalVersion("1.0")] diff --git a/ICSharpCode.SharpZipLib.Tests/Checksum/ChecksumTests.cs b/ICSharpCode.SharpZipLib.Tests/Checksum/ChecksumTests.cs index 82c3977b8..82e78e6ec 100644 --- a/ICSharpCode.SharpZipLib.Tests/Checksum/ChecksumTests.cs +++ b/ICSharpCode.SharpZipLib.Tests/Checksum/ChecksumTests.cs @@ -57,7 +57,8 @@ public void CRC_32() exceptionTesting(underTestCrc32); } - private void exceptionTesting(IChecksum crcUnderTest) { + private void exceptionTesting(IChecksum crcUnderTest) + { bool exception = false; diff --git a/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj b/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj index b07deccb9..263743499 100644 --- a/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj +++ b/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj @@ -104,12 +104,12 @@ ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll True - - ..\packages\AutoFixture.3.45.1\lib\net40\Ploeh.AutoFixture.dll + + ..\packages\AutoFixture.3.46.0\lib\net40\Ploeh.AutoFixture.dll True - - ..\packages\AutoFixture.NUnit3.3.45.1\lib\net40\Ploeh.AutoFixture.NUnit3.dll + + ..\packages\AutoFixture.NUnit3.3.46.0\lib\net40\Ploeh.AutoFixture.NUnit3.dll True diff --git a/ICSharpCode.SharpZipLib.Tests/Lzw/LzwTests.cs b/ICSharpCode.SharpZipLib.Tests/Lzw/LzwTests.cs index e8494546f..f72521d45 100644 --- a/ICSharpCode.SharpZipLib.Tests/Lzw/LzwTests.cs +++ b/ICSharpCode.SharpZipLib.Tests/Lzw/LzwTests.cs @@ -1,9 +1,9 @@ using System.IO; -using ICSharpCode.SharpZipLib.LZW; +using ICSharpCode.SharpZipLib.Lzw; using ICSharpCode.SharpZipLib.Tests.TestSupport; using NUnit.Framework; -namespace ICSharpCode.SharpZipLib.Tests.LZW +namespace ICSharpCode.SharpZipLib.Tests.Lzw { [TestFixture] diff --git a/ICSharpCode.SharpZipLib.Tests/TestSupport/RingBuffer.cs b/ICSharpCode.SharpZipLib.Tests/TestSupport/RingBuffer.cs index bdb5a83ba..19ae1f130 100644 --- a/ICSharpCode.SharpZipLib.Tests/TestSupport/RingBuffer.cs +++ b/ICSharpCode.SharpZipLib.Tests/TestSupport/RingBuffer.cs @@ -271,58 +271,47 @@ public int Read(byte[] buffer, int index, int count) /// /// Gets a value indicating wether the buffer is empty or not. /// - public bool IsEmpty - { + public bool IsEmpty { get { return count_ == 0; } } - public bool IsFull - { - get - { + public bool IsFull { + get { return (count_ == array_.Length); } } - public bool IsClosed - { + public bool IsClosed { get { return isClosed_; } } /// /// Gets the number of elements in the buffer. /// - public int Count - { - get - { + public int Count { + get { return count_; } } - public int Length - { + public int Length { get { return array_.Length; } } - public long BytesWritten - { + public long BytesWritten { get { return bytesWritten_; } } - public long BytesRead - { + public long BytesRead { get { return bytesRead_; } } /// /// Indexer - Get an element from the tail of the RingBuffer. /// - public byte this[int index] - { - get - { + public byte this[int index] { + get { if ((index < 0) || (index >= array_.Length)) { throw new ArgumentOutOfRangeException(nameof(index)); } diff --git a/ICSharpCode.SharpZipLib.Tests/TestSupport/Streams.cs b/ICSharpCode.SharpZipLib.Tests/TestSupport/Streams.cs index c9b519442..93aeed7ef 100644 --- a/ICSharpCode.SharpZipLib.Tests/TestSupport/Streams.cs +++ b/ICSharpCode.SharpZipLib.Tests/TestSupport/Streams.cs @@ -72,8 +72,7 @@ public override void Close() /// Gets a value indicating whether this instance is closed. /// /// true if this instance is closed; otherwise, false. - public bool IsClosed - { + public bool IsClosed { get { return isClosed_; } } @@ -83,8 +82,7 @@ public bool IsClosed /// /// true if this instance is disposed; otherwise, false. /// - public bool IsDisposed - { + public bool IsDisposed { get { return isDisposed_; } } @@ -105,10 +103,8 @@ public class MemoryStreamWithoutSeek : TrackedMemoryStream /// /// /// true if the stream is open. - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -124,8 +120,7 @@ public class NullStream : Stream /// /// /// true if the stream supports reading; otherwise, false. - public override bool CanRead - { + public override bool CanRead { get { return false; } } @@ -134,8 +129,7 @@ public override bool CanRead /// /// /// true if the stream supports seeking; otherwise, false. - public override bool CanSeek - { + public override bool CanSeek { get { return false; } } @@ -144,8 +138,7 @@ public override bool CanSeek /// /// /// true if the stream supports writing; otherwise, false. - public override bool CanWrite - { + public override bool CanWrite { get { return true; } } @@ -165,8 +158,7 @@ public override void Flush() /// A long value representing the length of the stream in bytes. /// A class derived from Stream does not support seeking. /// Methods were called after the stream was closed. - public override long Length - { + public override long Length { get { throw new Exception("The method or operation is not implemented."); } } @@ -178,14 +170,11 @@ public override long Length /// An I/O error occurs. /// The stream does not support seeking. /// Methods were called after the stream was closed. - public override long Position - { - get - { + public override long Position { + get { throw new Exception("The method or operation is not implemented."); } - set - { + set { throw new Exception("The method or operation is not implemented."); } } @@ -281,8 +270,7 @@ public WindowedStream(int size) /// /// /// true if the stream supports reading; otherwise, false. - public override bool CanRead - { + public override bool CanRead { get { return true; } } @@ -291,8 +279,7 @@ public override bool CanRead /// /// /// true if the stream supports seeking; otherwise, false. - public override bool CanSeek - { + public override bool CanSeek { get { return false; } } @@ -301,8 +288,7 @@ public override bool CanSeek /// /// /// true if the stream supports writing; otherwise, false. - public override bool CanWrite - { + public override bool CanWrite { get { return true; } } @@ -322,8 +308,7 @@ public override void Flush() /// A long value representing the length of the stream in bytes. /// A class derived from Stream does not support seeking. /// Methods were called after the stream was closed. - public override long Length - { + public override long Length { // A bit of a HAK as its not true in the stream sense. get { return ringBuffer_.Count; } } @@ -336,14 +321,11 @@ public override long Length /// An I/O error occurs. /// The stream does not support seeking. /// Methods were called after the stream was closed. - public override long Position - { - get - { + public override long Position { + get { throw new Exception("The method or operation is not implemented."); } - set - { + set { throw new Exception("The method or operation is not implemented."); } } @@ -436,8 +418,7 @@ public override void Write(byte[] buffer, int offset, int count) /// Gets a value indicating whether this instance is closed. /// /// true if this instance is closed; otherwise, false. - public bool IsClosed - { + public bool IsClosed { get { return ringBuffer_.IsClosed; } } @@ -453,8 +434,7 @@ public override void Close() /// Gets the bytes written. /// /// The bytes written. - public long BytesWritten - { + public long BytesWritten { get { return ringBuffer_.BytesWritten; } } @@ -462,8 +442,7 @@ public long BytesWritten /// Gets the bytes read. /// /// The bytes read. - public long BytesRead - { + public long BytesRead { get { return ringBuffer_.BytesRead; } } diff --git a/ICSharpCode.SharpZipLib.Tests/Zip/ZipTests.cs b/ICSharpCode.SharpZipLib.Tests/Zip/ZipTests.cs index 1e1f39f18..779c3db89 100644 --- a/ICSharpCode.SharpZipLib.Tests/Zip/ZipTests.cs +++ b/ICSharpCode.SharpZipLib.Tests/Zip/ZipTests.cs @@ -54,43 +54,35 @@ public RuntimeInfo(string password, bool isDirectory) original = new byte[0]; } - public byte[] Original - { + public byte[] Original { get { return original; } } - public CompressionMethod Method - { + public CompressionMethod Method { get { return method; } } - public int CompressionLevel - { + public int CompressionLevel { get { return compressionLevel; } } - public int Size - { + public int Size { get { return size; } } - public string Password - { + public string Password { get { return password; } } - bool Random - { + bool Random { get { return random; } } - public long Crc - { + public long Crc { get { return crc; } } - public bool IsDirectory - { + public bool IsDirectory { get { return isDirectory_; } } diff --git a/ICSharpCode.SharpZipLib.Tests/packages.config b/ICSharpCode.SharpZipLib.Tests/packages.config index 7e3bc8ca2..46eb857d7 100644 --- a/ICSharpCode.SharpZipLib.Tests/packages.config +++ b/ICSharpCode.SharpZipLib.Tests/packages.config @@ -1,7 +1,8 @@  - - + + + diff --git a/ICSharpCode.SharpZipLib/AssemblyInfo.cs b/ICSharpCode.SharpZipLib/AssemblyInfo.cs index 7ac70d524..cc881c45d 100644 --- a/ICSharpCode.SharpZipLib/AssemblyInfo.cs +++ b/ICSharpCode.SharpZipLib/AssemblyInfo.cs @@ -1,38 +1,3 @@ -// AssemblyInfo.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Reflection; diff --git a/ICSharpCode.SharpZipLib/BZip2/BZip2.cs b/ICSharpCode.SharpZipLib/BZip2/BZip2.cs index 3b17fbb20..4877716e5 100644 --- a/ICSharpCode.SharpZipLib/BZip2/BZip2.cs +++ b/ICSharpCode.SharpZipLib/BZip2/BZip2.cs @@ -1,44 +1,8 @@ -// BZip2.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; namespace ICSharpCode.SharpZipLib.BZip2 { - /// /// An example class to demonstrate compression and decompression of BZip2 streams. /// diff --git a/ICSharpCode.SharpZipLib/BZip2/BZip2Constants.cs b/ICSharpCode.SharpZipLib/BZip2/BZip2Constants.cs index bf334580a..01bf81939 100644 --- a/ICSharpCode.SharpZipLib/BZip2/BZip2Constants.cs +++ b/ICSharpCode.SharpZipLib/BZip2/BZip2Constants.cs @@ -1,41 +1,5 @@ -// BZip2Constants.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - namespace ICSharpCode.SharpZipLib.BZip2 { - /// /// Defines internal values for both compression and decompression /// @@ -155,44 +119,3 @@ private BZip2Constants() } } } - -/* This file was derived from a file containing this license: - * - * This file is a part of bzip2 and/or libbzip2, a program and - * library for lossless, block-sorting data compression. - * - * Copyright (C) 1996-1998 Julian R Seward. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. The origin of this software must not be misrepresented; you must - * not claim that you wrote the original software. If you use this - * software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 3. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 4. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Java version ported by Keiron Liddle, Aftex Software 1999-2001 - */ diff --git a/ICSharpCode.SharpZipLib/BZip2/BZip2Exception.cs b/ICSharpCode.SharpZipLib/BZip2/BZip2Exception.cs index c481fa7f5..2ef20c32f 100644 --- a/ICSharpCode.SharpZipLib/BZip2/BZip2Exception.cs +++ b/ICSharpCode.SharpZipLib/BZip2/BZip2Exception.cs @@ -1,38 +1,3 @@ -// BZip2Exception.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Runtime.Serialization; diff --git a/ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs b/ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs index 7c057a8a8..11afe5bfa 100644 --- a/ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs +++ b/ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs @@ -1,46 +1,9 @@ -// BZip2InputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; - using ICSharpCode.SharpZipLib.Checksum; namespace ICSharpCode.SharpZipLib.BZip2 { - /// /// An input stream that decompresses files in the BZip2 format /// @@ -81,8 +44,7 @@ public BZip2InputStream(Stream stream) /// Get/set flag indicating ownership of underlying stream. /// When the flag is true will close the underlying stream also. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } @@ -92,10 +54,8 @@ public bool IsStreamOwner /// /// Gets a value indicating if the stream supports reading /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return baseStream.CanRead; } } @@ -103,10 +63,8 @@ public override bool CanRead /// /// Gets a value indicating whether the current stream supports seeking. /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return baseStream.CanSeek; } } @@ -115,10 +73,8 @@ public override bool CanSeek /// Gets a value indicating whether the current stream supports writing. /// This property always returns false /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return false; } } @@ -126,10 +82,8 @@ public override bool CanWrite /// /// Gets the length in bytes of the stream. /// - public override long Length - { - get - { + public override long Length { + get { return baseStream.Length; } } @@ -139,14 +93,11 @@ public override long Length /// Setting the position is not supported and will throw a NotSupportException /// /// Any attempt to set the position - public override long Position - { - get - { + public override long Position { + get { return baseStream.Position; } - set - { + set { throw new NotSupportedException("BZip2InputStream position cannot be set"); } } @@ -255,22 +206,22 @@ public override int ReadByte() int retChar = currentChar; switch (currentState) { - case RAND_PART_B_STATE: - SetupRandPartB(); - break; - case RAND_PART_C_STATE: - SetupRandPartC(); - break; - case NO_RAND_PART_B_STATE: - SetupNoRandPartB(); - break; - case NO_RAND_PART_C_STATE: - SetupNoRandPartC(); - break; - case START_BLOCK_STATE: - case NO_RAND_PART_A_STATE: - case RAND_PART_A_STATE: - break; + case RAND_PART_B_STATE: + SetupRandPartB(); + break; + case RAND_PART_C_STATE: + SetupRandPartC(); + break; + case NO_RAND_PART_B_STATE: + SetupNoRandPartB(); + break; + case NO_RAND_PART_C_STATE: + SetupNoRandPartC(); + break; + case START_BLOCK_STATE: + case NO_RAND_PART_A_STATE: + case RAND_PART_A_STATE: + break; } return retChar; } @@ -956,43 +907,3 @@ during decompression. #endregion } } -/* This file was derived from a file containing this license: - * - * This file is a part of bzip2 and/or libbzip2, a program and - * library for lossless, block-sorting data compression. - * - * Copyright (C) 1996-1998 Julian R Seward. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. The origin of this software must not be misrepresented; you must - * not claim that you wrote the original software. If you use this - * software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 3. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 4. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Java version ported by Keiron Liddle, Aftex Software 1999-2001 - */ diff --git a/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs b/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs index 7e335f270..b83a3f778 100644 --- a/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs +++ b/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs @@ -1,48 +1,9 @@ -// BZip2OutputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; - using ICSharpCode.SharpZipLib.Checksum; namespace ICSharpCode.SharpZipLib.BZip2 { - - // TODO: Update to BZip2 1.0.1, 1.0.2 - /// /// An output stream that compresses into the BZip2 format /// including file header chars into another stream. @@ -133,8 +94,7 @@ public BZip2OutputStream(Stream stream, int blockSize) /// Get/set flag indicating ownership of underlying stream. /// When the flag is true will close the underlying stream also. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } @@ -144,10 +104,8 @@ public bool IsStreamOwner /// /// Gets a value indicating whether the current stream supports reading /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return false; } } @@ -155,10 +113,8 @@ public override bool CanRead /// /// Gets a value indicating whether the current stream supports seeking /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -166,10 +122,8 @@ public override bool CanSeek /// /// Gets a value indicating whether the current stream supports writing /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return baseStream.CanWrite; } } @@ -177,10 +131,8 @@ public override bool CanWrite /// /// Gets the length in bytes of the stream /// - public override long Length - { - get - { + public override long Length { + get { return baseStream.Length; } } @@ -188,14 +140,11 @@ public override long Length /// /// Gets or sets the current position of this stream. /// - public override long Position - { - get - { + public override long Position { + get { return baseStream.Position; } - set - { + set { throw new NotSupportedException("BZip2OutputStream position cannot be set"); } } @@ -333,37 +282,37 @@ void WriteRun() } switch (runLength) { - case 1: - last++; - block[last + 1] = (byte)currentChar; - break; - case 2: - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - break; - case 3: - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - break; - default: - inUse[runLength - 4] = true; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)(runLength - 4); - break; + case 1: + last++; + block[last + 1] = (byte)currentChar; + break; + case 2: + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)currentChar; + break; + case 3: + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)currentChar; + break; + default: + inUse[runLength - 4] = true; + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)currentChar; + last++; + block[last + 1] = (byte)(runLength - 4); + break; } } else { EndBlock(); @@ -375,8 +324,7 @@ void WriteRun() /// /// Get the number of bytes written to the output. /// - public int BytesWritten - { + public int BytesWritten { get { return bytesOut; } } @@ -1547,16 +1495,16 @@ void GenerateMTFValues() zPend--; while (true) { switch (zPend % 2) { - case 0: - szptr[wr] = (short)BZip2Constants.RunA; - wr++; - mtfFreq[BZip2Constants.RunA]++; - break; - case 1: - szptr[wr] = (short)BZip2Constants.RunB; - wr++; - mtfFreq[BZip2Constants.RunB]++; - break; + case 0: + szptr[wr] = (short)BZip2Constants.RunA; + wr++; + mtfFreq[BZip2Constants.RunA]++; + break; + case 1: + szptr[wr] = (short)BZip2Constants.RunB; + wr++; + mtfFreq[BZip2Constants.RunB]++; + break; } if (zPend < 2) { break; @@ -1575,16 +1523,16 @@ void GenerateMTFValues() zPend--; while (true) { switch (zPend % 2) { - case 0: - szptr[wr] = (short)BZip2Constants.RunA; - wr++; - mtfFreq[BZip2Constants.RunA]++; - break; - case 1: - szptr[wr] = (short)BZip2Constants.RunB; - wr++; - mtfFreq[BZip2Constants.RunB]++; - break; + case 0: + szptr[wr] = (short)BZip2Constants.RunA; + wr++; + mtfFreq[BZip2Constants.RunA]++; + break; + case 1: + szptr[wr] = (short)BZip2Constants.RunB; + wr++; + mtfFreq[BZip2Constants.RunB]++; + break; } if (zPend < 2) { break; @@ -1843,44 +1791,3 @@ The current block size is 100000 * this number. #endregion } } - -/* This file was derived from a file containing this license: - * - * This file is a part of bzip2 and/or libbzip2, a program and - * library for lossless, block-sorting data compression. - * - * Copyright (C) 1996-1998 Julian R Seward. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. The origin of this software must not be misrepresented; you must - * not claim that you wrote the original software. If you use this - * software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 3. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 4. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Java version ported by Keiron Liddle, Aftex Software 1999-2001 - */ diff --git a/ICSharpCode.SharpZipLib/Checksum/Adler32.cs b/ICSharpCode.SharpZipLib/Checksum/Adler32.cs index f67d8b5ad..9767425b1 100644 --- a/ICSharpCode.SharpZipLib/Checksum/Adler32.cs +++ b/ICSharpCode.SharpZipLib/Checksum/Adler32.cs @@ -1,46 +1,7 @@ -// Adler32.cs - Computes Adler32 data checksum of a data stream -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Checksum { - /// /// Computes Adler32 checksum for a stream of data. An Adler32 /// checksum is not as reliable as a CRC32 checksum, but a lot faster to diff --git a/ICSharpCode.SharpZipLib/Checksum/BZip2Crc.cs b/ICSharpCode.SharpZipLib/Checksum/BZip2Crc.cs index 0e4cf4843..48ee241ca 100644 --- a/ICSharpCode.SharpZipLib/Checksum/BZip2Crc.cs +++ b/ICSharpCode.SharpZipLib/Checksum/BZip2Crc.cs @@ -1,41 +1,3 @@ -// BZip2Crc.cs - computes a crc used in the bzip2lib -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Checksum diff --git a/ICSharpCode.SharpZipLib/Checksum/Crc32.cs b/ICSharpCode.SharpZipLib/Checksum/Crc32.cs index b9e0919fd..897076942 100644 --- a/ICSharpCode.SharpZipLib/Checksum/Crc32.cs +++ b/ICSharpCode.SharpZipLib/Checksum/Crc32.cs @@ -1,41 +1,3 @@ -// Crc32.cs - Computes CRC32 data checksum of a data stream -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Checksum diff --git a/ICSharpCode.SharpZipLib/Checksum/IChecksum.cs b/ICSharpCode.SharpZipLib/Checksum/IChecksum.cs index 327fbfb6f..93dc51cfa 100644 --- a/ICSharpCode.SharpZipLib/Checksum/IChecksum.cs +++ b/ICSharpCode.SharpZipLib/Checksum/IChecksum.cs @@ -1,44 +1,5 @@ -// IChecksum.cs - Interface to compute a data checksum -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - namespace ICSharpCode.SharpZipLib.Checksum { - /// /// Interface to compute a data checksum used by checked input/output streams. /// A data checksum can be updated by one byte or with a byte array. After each @@ -56,8 +17,7 @@ public interface IChecksum /// /// Returns the data checksum computed so far. /// - long Value - { + long Value { get; } diff --git a/ICSharpCode.SharpZipLib/CompressionLevel.cs b/ICSharpCode.SharpZipLib/CompressionLevel.cs deleted file mode 100644 index dcb6d374c..000000000 --- a/ICSharpCode.SharpZipLib/CompressionLevel.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace ICSharpCode.SharpZipLib -{ - /// - /// Defines a tradeoff between fast vs. strong compression. The specific meaning depends of the Deflater implementation. - /// - - // This is an abstract concept and NOT the ZLib compression level. - // There may or may not be any correspondence with the a possible implementation-specific level-parameter of the deflater. - public enum CompressionLevel - { - Optimal = 0, - Fastest = 1, - NoCompression = 2 - } -} diff --git a/ICSharpCode.SharpZipLib/CompressionMode.cs b/ICSharpCode.SharpZipLib/CompressionMode.cs deleted file mode 100644 index e9bcd361f..000000000 --- a/ICSharpCode.SharpZipLib/CompressionMode.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace ICSharpCode.SharpZipLib -{ - public enum CompressionMode - { - Decompress = 0, - Compress = 1 - } -} - diff --git a/ICSharpCode.SharpZipLib/Core/FileSystemScanner.cs b/ICSharpCode.SharpZipLib/Core/FileSystemScanner.cs index dd76e23e9..2a375b7d2 100644 --- a/ICSharpCode.SharpZipLib/Core/FileSystemScanner.cs +++ b/ICSharpCode.SharpZipLib/Core/FileSystemScanner.cs @@ -1,39 +1,3 @@ -// FileSystemScanner.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - - using System; namespace ICSharpCode.SharpZipLib.Core @@ -58,16 +22,14 @@ public ScanEventArgs(string name) /// /// The file or directory name for this event. /// - public string Name - { + public string Name { get { return name_; } } /// /// Get set a value indicating if scanning should continue or not. /// - public bool ContinueRunning - { + public bool ContinueRunning { get { return continueRunning_; } set { continueRunning_ = value; } } @@ -101,16 +63,14 @@ public ProgressEventArgs(string name, long processed, long target) /// /// The name for this event if known. /// - public string Name - { + public string Name { get { return name_; } } /// /// Get set a value indicating wether scanning should continue or not. /// - public bool ContinueRunning - { + public bool ContinueRunning { get { return continueRunning_; } set { continueRunning_ = value; } } @@ -119,10 +79,8 @@ public bool ContinueRunning /// Get a percentage representing how much of the has been processed /// /// 0.0 to 100.0 percent; 0 if target is not known. - public float PercentComplete - { - get - { + public float PercentComplete { + get { float result; if (target_ <= 0) { result = 0; @@ -136,8 +94,7 @@ public float PercentComplete /// /// The number of bytes processed so far /// - public long Processed - { + public long Processed { get { return processed_; } } @@ -145,8 +102,7 @@ public long Processed /// The number of bytes to process. /// /// Target may be 0 or negative if the value isnt known. - public long Target - { + public long Target { get { return target_; } } @@ -179,8 +135,7 @@ public DirectoryEventArgs(string name, bool hasMatchingFiles) /// /// Get a value indicating if the directory contains any matching files or not. /// - public bool HasMatchingFiles - { + public bool HasMatchingFiles { get { return hasMatchingFiles_; } } @@ -213,24 +168,21 @@ public ScanFailureEventArgs(string name, Exception e) /// /// The applicable name. /// - public string Name - { + public string Name { get { return name_; } } /// /// The applicable exception. /// - public Exception Exception - { + public Exception Exception { get { return exception_; } } /// /// Get / set a value indicating wether scanning should continue. /// - public bool ContinueRunning - { + public bool ContinueRunning { get { return continueRunning_; } set { continueRunning_ = value; } } diff --git a/ICSharpCode.SharpZipLib/Core/INameTransform.cs b/ICSharpCode.SharpZipLib/Core/INameTransform.cs index 2fa77dba0..492e2a9e6 100644 --- a/ICSharpCode.SharpZipLib/Core/INameTransform.cs +++ b/ICSharpCode.SharpZipLib/Core/INameTransform.cs @@ -1,38 +1,3 @@ -// INameTransform.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - namespace ICSharpCode.SharpZipLib.Core { /// diff --git a/ICSharpCode.SharpZipLib/Core/IScanFilter.cs b/ICSharpCode.SharpZipLib/Core/IScanFilter.cs index 8c5b923fd..ac07fd174 100644 --- a/ICSharpCode.SharpZipLib/Core/IScanFilter.cs +++ b/ICSharpCode.SharpZipLib/Core/IScanFilter.cs @@ -1,39 +1,4 @@ -// IScanFilter.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -namespace ICSharpCode.SharpZipLib.Core +namespace ICSharpCode.SharpZipLib.Core { /// /// Scanning filters support filtering of names. diff --git a/ICSharpCode.SharpZipLib/Core/NameFilter.cs b/ICSharpCode.SharpZipLib/Core/NameFilter.cs index 22f4bc584..217e12ba7 100644 --- a/ICSharpCode.SharpZipLib/Core/NameFilter.cs +++ b/ICSharpCode.SharpZipLib/Core/NameFilter.cs @@ -1,41 +1,3 @@ -// NameFilter.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2010-03-03 Z-1654 Fixed bug where escape characters were excluded in SplitQuoted() - using System; using System.Collections; using System.Text; diff --git a/ICSharpCode.SharpZipLib/Core/PathFilter.cs b/ICSharpCode.SharpZipLib/Core/PathFilter.cs index e5c7b1861..76a40bdde 100644 --- a/ICSharpCode.SharpZipLib/Core/PathFilter.cs +++ b/ICSharpCode.SharpZipLib/Core/PathFilter.cs @@ -1,38 +1,3 @@ -// PathFilter.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; @@ -167,11 +132,9 @@ public override bool IsMatch(string name) /// /// The default value is zero. /// value is less than zero; greater than - public long MinSize - { + public long MinSize { get { return minSize_; } - set - { + set { if ((value < 0) || (maxSize_ < value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -185,11 +148,9 @@ public long MinSize /// /// The default value is /// value is less than zero or less than - public long MaxSize - { + public long MaxSize { get { return maxSize_; } - set - { + set { if ((value < 0) || (minSize_ > value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -202,15 +163,12 @@ public long MaxSize /// Get/set the minimum value that will match for this filter. /// /// Files with a LastWrite time less than this value are excluded by the filter. - public DateTime MinDate - { - get - { + public DateTime MinDate { + get { return minDate_; } - set - { + set { if (value > maxDate_) { throw new ArgumentOutOfRangeException(nameof(value), "Exceeds MaxDate"); } @@ -223,15 +181,12 @@ public DateTime MinDate /// Get/set the maximum value that will match for this filter. /// /// Files with a LastWrite time greater than this value are excluded by the filter. - public DateTime MaxDate - { - get - { + public DateTime MaxDate { + get { return maxDate_; } - set - { + set { if (minDate_ > value) { throw new ArgumentOutOfRangeException(nameof(value), "Exceeds MinDate"); } @@ -292,11 +247,9 @@ public override bool IsMatch(string name) /// /// Get/set the minimum size for a file that will match this filter. /// - public long MinSize - { + public long MinSize { get { return minSize_; } - set - { + set { if ((value < 0) || (maxSize_ < value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -308,11 +261,9 @@ public long MinSize /// /// Get/set the maximum size for a file that will match this filter. /// - public long MaxSize - { + public long MaxSize { get { return maxSize_; } - set - { + set { if ((value < 0) || (minSize_ > value)) { throw new ArgumentOutOfRangeException(nameof(value)); } diff --git a/ICSharpCode.SharpZipLib/Core/StreamUtils.cs b/ICSharpCode.SharpZipLib/Core/StreamUtils.cs index ca5cbc6c0..2f150adbb 100644 --- a/ICSharpCode.SharpZipLib/Core/StreamUtils.cs +++ b/ICSharpCode.SharpZipLib/Core/StreamUtils.cs @@ -1,38 +1,3 @@ -// StreamUtils.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; diff --git a/ICSharpCode.SharpZipLib/Core/WindowsPathUtils.cs b/ICSharpCode.SharpZipLib/Core/WindowsPathUtils.cs index 837d589af..d771b3731 100644 --- a/ICSharpCode.SharpZipLib/Core/WindowsPathUtils.cs +++ b/ICSharpCode.SharpZipLib/Core/WindowsPathUtils.cs @@ -1,38 +1,3 @@ -// WindowsPathUtils.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - namespace ICSharpCode.SharpZipLib.Core { /// diff --git a/ICSharpCode.SharpZipLib/Encryption/PkzipClassic.cs b/ICSharpCode.SharpZipLib/Encryption/PkzipClassic.cs index 08b8f8d0a..8c1c7517c 100644 --- a/ICSharpCode.SharpZipLib/Encryption/PkzipClassic.cs +++ b/ICSharpCode.SharpZipLib/Encryption/PkzipClassic.cs @@ -1,39 +1,3 @@ -// PkzipClassic encryption -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. -// - using System; using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Checksum; @@ -209,10 +173,8 @@ public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, b /// /// Gets a value indicating whether the current transform can be reused. /// - public bool CanReuseTransform - { - get - { + public bool CanReuseTransform { + get { return true; } } @@ -220,10 +182,8 @@ public bool CanReuseTransform /// /// Gets the size of the input data blocks in bytes. /// - public int InputBlockSize - { - get - { + public int InputBlockSize { + get { return 1; } } @@ -231,10 +191,8 @@ public int InputBlockSize /// /// Gets the size of the output data blocks in bytes. /// - public int OutputBlockSize - { - get - { + public int OutputBlockSize { + get { return 1; } } @@ -242,10 +200,8 @@ public int OutputBlockSize /// /// Gets a value indicating whether multiple blocks can be transformed. /// - public bool CanTransformMultipleBlocks - { - get - { + public bool CanTransformMultipleBlocks { + get { return true; } } @@ -319,10 +275,8 @@ public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, b /// /// Gets a value indicating whether the current transform can be reused. /// - public bool CanReuseTransform - { - get - { + public bool CanReuseTransform { + get { return true; } } @@ -330,10 +284,8 @@ public bool CanReuseTransform /// /// Gets the size of the input data blocks in bytes. /// - public int InputBlockSize - { - get - { + public int InputBlockSize { + get { return 1; } } @@ -341,10 +293,8 @@ public int InputBlockSize /// /// Gets the size of the output data blocks in bytes. /// - public int OutputBlockSize - { - get - { + public int OutputBlockSize { + get { return 1; } } @@ -352,10 +302,8 @@ public int OutputBlockSize /// /// Gets a value indicating whether multiple blocks can be transformed. /// - public bool CanTransformMultipleBlocks - { - get - { + public bool CanTransformMultipleBlocks { + get { return true; } } @@ -385,15 +333,12 @@ public sealed class PkzipClassicManaged : PkzipClassic /// Get / set the applicable block size in bits. /// /// The only valid block size is 8. - public override int BlockSize - { - get - { + public override int BlockSize { + get { return 8; } - set - { + set { if (value != 8) { throw new CryptographicException("Block size is invalid"); } @@ -403,10 +348,8 @@ public override int BlockSize /// /// Get an array of legal key sizes. /// - public override KeySizes[] LegalKeySizes - { - get - { + public override KeySizes[] LegalKeySizes { + get { KeySizes[] keySizes = new KeySizes[1]; keySizes[0] = new KeySizes(12 * 8, 12 * 8, 0); return keySizes; @@ -424,10 +367,8 @@ public override void GenerateIV() /// /// Get an array of legal block sizes. /// - public override KeySizes[] LegalBlockSizes - { - get - { + public override KeySizes[] LegalBlockSizes { + get { KeySizes[] keySizes = new KeySizes[1]; keySizes[0] = new KeySizes(1 * 8, 1 * 8, 0); return keySizes; @@ -437,10 +378,8 @@ public override KeySizes[] LegalBlockSizes /// /// Get / set the key value applicable. /// - public override byte[] Key - { - get - { + public override byte[] Key { + get { if (key_ == null) { GenerateKey(); } @@ -448,8 +387,7 @@ public override byte[] Key return (byte[])key_.Clone(); } - set - { + set { if (value == null) { throw new ArgumentNullException(nameof(value)); } diff --git a/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs b/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs index befd514e2..18e7ec6a9 100644 --- a/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs +++ b/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs @@ -1,52 +1,16 @@ -// ZipAESStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. -// - using System; using System.IO; using System.Security.Cryptography; namespace ICSharpCode.SharpZipLib.Encryption { - - // Based on information from http://www.winzip.com/aes_info.htm - // and http://www.gladman.me.uk/cryptography_technology/fileencrypt/ - /// /// Encrypts and decrypts AES ZIP /// + /// + /// Based on information from http://www.winzip.com/aes_info.htm + /// and http://www.gladman.me.uk/cryptography_technology/fileencrypt/ + /// internal class ZipAESStream : CryptoStream { diff --git a/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs b/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs index 9a0911dfc..ece00722c 100644 --- a/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs +++ b/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs @@ -1,53 +1,13 @@ -// ZipAESTransform.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. -// - -// Framework version 2.0 required for Rfc2898DeriveBytes - using System; using System.Security.Cryptography; namespace ICSharpCode.SharpZipLib.Encryption { - /// /// Transforms stream using AES in CTR mode /// internal class ZipAESTransform : ICryptoTransform { - private const int PWD_VER_LENGTH = 2; // WinZip use iteration count of 1000 for PBKDF2 key generation @@ -142,10 +102,8 @@ public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, b /// /// Returns the 2 byte password verifier /// - public byte[] PwdVerifier - { - get - { + public byte[] PwdVerifier { + get { return _pwdVerifier; } } @@ -178,10 +136,8 @@ public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int input /// /// Gets the size of the input data blocks in bytes. /// - public int InputBlockSize - { - get - { + public int InputBlockSize { + get { return _blockSize; } } @@ -189,10 +145,8 @@ public int InputBlockSize /// /// Gets the size of the output data blocks in bytes. /// - public int OutputBlockSize - { - get - { + public int OutputBlockSize { + get { return _blockSize; } } @@ -200,10 +154,8 @@ public int OutputBlockSize /// /// Gets a value indicating whether multiple blocks can be transformed. /// - public bool CanTransformMultipleBlocks - { - get - { + public bool CanTransformMultipleBlocks { + get { return true; } } @@ -211,10 +163,8 @@ public bool CanTransformMultipleBlocks /// /// Gets a value indicating whether the current transform can be reused. /// - public bool CanReuseTransform - { - get - { + public bool CanReuseTransform { + get { return true; } } diff --git a/ICSharpCode.SharpZipLib/GZip/GZip.cs b/ICSharpCode.SharpZipLib/GZip/GZip.cs index 91a3d5df4..b63a1985c 100644 --- a/ICSharpCode.SharpZipLib/GZip/GZip.cs +++ b/ICSharpCode.SharpZipLib/GZip/GZip.cs @@ -1,44 +1,8 @@ -// GZip.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; +using System; using System.IO; namespace ICSharpCode.SharpZipLib.GZip { - /// /// An example class to demonstrate compression and decompression of GZip streams. /// diff --git a/ICSharpCode.SharpZipLib/GZip/GZipConstants.cs b/ICSharpCode.SharpZipLib/GZip/GZipConstants.cs index 6f00b1289..747d71a54 100644 --- a/ICSharpCode.SharpZipLib/GZip/GZipConstants.cs +++ b/ICSharpCode.SharpZipLib/GZip/GZipConstants.cs @@ -1,44 +1,5 @@ -// GZipConstants.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - namespace ICSharpCode.SharpZipLib.GZip { - /// /// This class contains constants used for gzip. /// diff --git a/ICSharpCode.SharpZipLib/GZip/GZipException.cs b/ICSharpCode.SharpZipLib/GZip/GZipException.cs index 1e7c40457..cde0cec25 100644 --- a/ICSharpCode.SharpZipLib/GZip/GZipException.cs +++ b/ICSharpCode.SharpZipLib/GZip/GZipException.cs @@ -1,38 +1,3 @@ -// GZipException.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Runtime.Serialization; diff --git a/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs b/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs index 50639fd01..9d310b557 100644 --- a/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs +++ b/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs @@ -1,48 +1,5 @@ -// GzipInputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2009-08-11 T9121 Geoff Hart Added Multi-member gzip support -// 2012-06-03 Z-1802 Incorrect endianness and subfield in FEXTRA handling. - using System; using System.IO; - using ICSharpCode.SharpZipLib.Checksum; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; diff --git a/ICSharpCode.SharpZipLib/GZip/GzipOutputStream.cs b/ICSharpCode.SharpZipLib/GZip/GzipOutputStream.cs index b3d650219..c20c01225 100644 --- a/ICSharpCode.SharpZipLib/GZip/GzipOutputStream.cs +++ b/ICSharpCode.SharpZipLib/GZip/GzipOutputStream.cs @@ -1,51 +1,11 @@ -// GZipOutputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; - using ICSharpCode.SharpZipLib.Checksum; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.GZip { - /// /// This filter stream is used to compress a stream into a "GZIP" stream. /// The "GZIP" format is described in RFC 1952. diff --git a/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj b/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj index 087c2003f..b10938beb 100644 --- a/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj +++ b/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj @@ -85,8 +85,6 @@ - - @@ -140,7 +138,6 @@ - diff --git a/ICSharpCode.SharpZipLib/Lzw/LzwConstants.cs b/ICSharpCode.SharpZipLib/Lzw/LzwConstants.cs index 944646ad6..d36eb362a 100644 --- a/ICSharpCode.SharpZipLib/Lzw/LzwConstants.cs +++ b/ICSharpCode.SharpZipLib/Lzw/LzwConstants.cs @@ -1,41 +1,5 @@ -// LzwConstants.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -namespace ICSharpCode.SharpZipLib.LZW +namespace ICSharpCode.SharpZipLib.Lzw { - /// /// This class contains constants used for LZW /// diff --git a/ICSharpCode.SharpZipLib/Lzw/LzwException.cs b/ICSharpCode.SharpZipLib/Lzw/LzwException.cs index 3b6d75ccc..41db05b7c 100644 --- a/ICSharpCode.SharpZipLib/Lzw/LzwException.cs +++ b/ICSharpCode.SharpZipLib/Lzw/LzwException.cs @@ -1,44 +1,8 @@ -// LzwException.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; +using System; using System.Runtime.Serialization; -namespace ICSharpCode.SharpZipLib.LZW +namespace ICSharpCode.SharpZipLib.Lzw { - /// /// LzwException represents a LZW specific exception /// diff --git a/ICSharpCode.SharpZipLib/Lzw/LzwInputStream.cs b/ICSharpCode.SharpZipLib/Lzw/LzwInputStream.cs index 09c5e86be..76e1a99f9 100644 --- a/ICSharpCode.SharpZipLib/Lzw/LzwInputStream.cs +++ b/ICSharpCode.SharpZipLib/Lzw/LzwInputStream.cs @@ -1,44 +1,8 @@ -// LzwInputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; +using System; using System.IO; -namespace ICSharpCode.SharpZipLib.LZW +namespace ICSharpCode.SharpZipLib.Lzw { - /// /// This filter stream is used to decompress a LZW format stream. /// Specifically, a stream that uses the LZC compression method. @@ -86,8 +50,7 @@ public class LzwInputStream : Stream /// /// The default value is true. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } @@ -130,9 +93,11 @@ public override int ReadByte() /// The number of bytes read. Zero signals the end of stream public override int Read(byte[] buffer, int offset, int count) { - if (!headerParsed) ParseHeader(); + if (!headerParsed) + ParseHeader(); - if (eof) return 0; + if (eof) + return 0; int start = offset; @@ -171,7 +136,8 @@ public override int Read(byte[] buffer, int offset, int count) // loop, filling local buffer until enough data has been decompressed - MainLoop: do { + MainLoop: + do { if (end < EXTRA) { Fill(); } @@ -224,7 +190,8 @@ public override int Read(byte[] buffer, int offset, int count) // handle first iteration if (lOldCode == -1) { - if (code >= 256) throw new LzwException("corrupt input: " + code + " > 255"); + if (code >= 256) + throw new LzwException("corrupt input: " + code + " > 255"); lFinChar = (byte)(lOldCode = code); buffer[offset++] = lFinChar; @@ -407,10 +374,8 @@ private void ParseHeader() /// /// Gets a value indicating whether the current stream supports reading /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return baseInputStream.CanRead; } } @@ -418,10 +383,8 @@ public override bool CanRead /// /// Gets a value of false indicating seeking is not supported for this stream. /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -429,10 +392,8 @@ public override bool CanSeek /// /// Gets a value of false indicating that this stream is not writeable. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return false; } } @@ -440,10 +401,8 @@ public override bool CanWrite /// /// A value representing the length of the stream in bytes. /// - public override long Length - { - get - { + public override long Length { + get { return got; } } @@ -453,14 +412,11 @@ public override long Length /// Throws a NotSupportedException when attempting to set the position /// /// Attempting to set the position - public override long Position - { - get - { + public override long Position { + get { return baseInputStream.Position; } - set - { + set { throw new NotSupportedException("InflaterInputStream Position not supported"); } } diff --git a/ICSharpCode.SharpZipLib/SharpZipBaseException.cs b/ICSharpCode.SharpZipLib/SharpZipBaseException.cs index 62dd9294a..7d05e5ea4 100644 --- a/ICSharpCode.SharpZipLib/SharpZipBaseException.cs +++ b/ICSharpCode.SharpZipLib/SharpZipBaseException.cs @@ -1,38 +1,3 @@ -// SharpZipBaseException.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Runtime.Serialization; diff --git a/ICSharpCode.SharpZipLib/Tar/InvalidHeaderException.cs b/ICSharpCode.SharpZipLib/Tar/InvalidHeaderException.cs index 099fa899c..6564920ae 100644 --- a/ICSharpCode.SharpZipLib/Tar/InvalidHeaderException.cs +++ b/ICSharpCode.SharpZipLib/Tar/InvalidHeaderException.cs @@ -1,44 +1,8 @@ -// InvalidHeaderException.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Runtime.Serialization; namespace ICSharpCode.SharpZipLib.Tar { - /// /// This exception is used to indicate that there is a problem /// with a TAR archive header. @@ -85,19 +49,3 @@ public InvalidHeaderException(string message, Exception exception) } } } - -/* The original Java file had this header: -** Authored by Timothy Gerard Endres -** -** -** This work has been placed into the public domain. -** You may use this work in any way and for any purpose you wish. -** -** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, -** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR -** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY -** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR -** REDISTRIBUTION OF THIS SOFTWARE. -** -*/ - diff --git a/ICSharpCode.SharpZipLib/Tar/TarArchive.cs b/ICSharpCode.SharpZipLib/Tar/TarArchive.cs index 02b1e1d98..405e8a00f 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarArchive.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarArchive.cs @@ -1,42 +1,3 @@ -// TarArchive.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2010-01-28 Added IsStreamOwner -// 2012-06-07 Z-1675 RootPath was case and slash direction sensitive; trailing slash caused failure - using System; using System.IO; using System.Text; @@ -236,10 +197,8 @@ public void SetKeepOldFiles(bool keepExistingFiles) /// '\n', which is the defacto standard for a TAR archive. This makes /// text files compatible with UNIX. /// - public bool AsciiTranslate - { - get - { + public bool AsciiTranslate { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -247,8 +206,7 @@ public bool AsciiTranslate return asciiTranslate; } - set - { + set { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -278,10 +236,8 @@ public void SetAsciiTranslation(bool translateAsciiFiles) /// PathPrefix is added to entry names as they are written if the value is not null. /// A slash character is appended after PathPrefix /// - public string PathPrefix - { - get - { + public string PathPrefix { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -289,8 +245,7 @@ public string PathPrefix return pathPrefix; } - set - { + set { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -304,10 +259,8 @@ public string PathPrefix /// RootPath is removed from entry names if it is found at the /// beginning of the name. /// - public string RootPath - { - get - { + public string RootPath { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -315,8 +268,7 @@ public string RootPath return rootPath; } - set - { + set { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -362,10 +314,8 @@ public void SetUserInfo(int userId, string userName, int groupId, string groupNa /// Get or set a value indicating if overrides defined by SetUserInfo should be applied. /// /// If overrides are not applied then the values as set in each header will be used. - public bool ApplyUserInfoOverrides - { - get - { + public bool ApplyUserInfoOverrides { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -373,8 +323,7 @@ public bool ApplyUserInfoOverrides return applyUserInfoOverrides; } - set - { + set { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -391,10 +340,8 @@ public bool ApplyUserInfoOverrides /// /// The current user id. /// - public int UserId - { - get - { + public int UserId { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -411,10 +358,8 @@ public int UserId /// /// The current user name. /// - public string UserName - { - get - { + public string UserName { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -431,10 +376,8 @@ public string UserName /// /// The current group id. /// - public int GroupId - { - get - { + public int GroupId { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -451,10 +394,8 @@ public int GroupId /// /// The current group name. /// - public string GroupName - { - get - { + public string GroupName { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -473,10 +414,8 @@ public string GroupName /// /// The record size this archive is using. /// - public int RecordSize - { - get - { + public int RecordSize { + get { if (isDisposed) { throw new ObjectDisposedException("TarArchive"); } @@ -494,10 +433,8 @@ public int RecordSize /// Sets the IsStreamOwner property on the underlying stream. /// Set this to false to prevent the Close of the TarArchive from closing the stream. /// - public bool IsStreamOwner - { - set - { + public bool IsStreamOwner { + set { if (tarIn != null) { tarIn.IsStreamOwner = value; } else { @@ -891,20 +828,3 @@ static bool IsBinary(string filename) #endregion } } - - -/* The original Java file had this header: - ** Authored by Timothy Gerard Endres - ** - ** - ** This work has been placed into the public domain. - ** You may use this work in any way and for any purpose you wish. - ** - ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, - ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR - ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY - ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR - ** REDISTRIBUTION OF THIS SOFTWARE. - ** - */ - diff --git a/ICSharpCode.SharpZipLib/Tar/TarBuffer.cs b/ICSharpCode.SharpZipLib/Tar/TarBuffer.cs index 393e96a39..b18d6c76a 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarBuffer.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarBuffer.cs @@ -1,44 +1,8 @@ -// TarBuffer.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; namespace ICSharpCode.SharpZipLib.Tar { - /// /// The TarBuffer class implements the tar archive concept /// of a buffered input stream. This concept goes back to the @@ -105,10 +69,8 @@ or which contains garbage records after a zero block. /// /// The record size in bytes. /// This is equal to the multiplied by the - public int RecordSize - { - get - { + public int RecordSize { + get { return recordSize; } } @@ -128,10 +90,8 @@ public int GetRecordSize() /// Get the Blocking factor for the buffer /// /// This is the number of blocks in each record. - public int BlockFactor - { - get - { + public int BlockFactor { + get { return blockFactor; } } @@ -398,8 +358,7 @@ bool ReadRecord() /// /// Block numbers are zero based values /// - public int CurrentBlock - { + public int CurrentBlock { get { return currentBlockIndex; } } @@ -407,8 +366,7 @@ public int CurrentBlock /// Get/set flag indicating ownership of the underlying stream. /// When the flag is true will close the underlying stream also. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner_; } set { isStreamOwner_ = value; } } @@ -434,8 +392,7 @@ public int GetCurrentBlockNum() /// /// The current zero based record number. /// - public int CurrentRecord - { + public int CurrentRecord { get { return currentRecordIndex; } } @@ -592,19 +549,3 @@ public void Close() #endregion } } - -/* The original Java file had this header: - * - ** Authored by Timothy Gerard Endres - ** - ** - ** This work has been placed into the public domain. - ** You may use this work in any way and for any purpose you wish. - ** - ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, - ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR - ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY - ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR - ** REDISTRIBUTION OF THIS SOFTWARE. - ** - */ diff --git a/ICSharpCode.SharpZipLib/Tar/TarEntry.cs b/ICSharpCode.SharpZipLib/Tar/TarEntry.cs index 9e9e45b7e..f2b866a5c 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarEntry.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarEntry.cs @@ -1,38 +1,3 @@ -// TarEntry.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; @@ -197,10 +162,8 @@ public bool IsDescendent(TarEntry toTest) /// /// This entry's TarHeader. /// - public TarHeader TarHeader - { - get - { + public TarHeader TarHeader { + get { return header; } } @@ -208,14 +171,11 @@ public TarHeader TarHeader /// /// Get/Set this entry's name. /// - public string Name - { - get - { + public string Name { + get { return header.Name; } - set - { + set { header.Name = value; } } @@ -223,14 +183,11 @@ public string Name /// /// Get/set this entry's user id. /// - public int UserId - { - get - { + public int UserId { + get { return header.UserId; } - set - { + set { header.UserId = value; } } @@ -238,14 +195,11 @@ public int UserId /// /// Get/set this entry's group id. /// - public int GroupId - { - get - { + public int GroupId { + get { return header.GroupId; } - set - { + set { header.GroupId = value; } } @@ -253,14 +207,11 @@ public int GroupId /// /// Get/set this entry's user name. /// - public string UserName - { - get - { + public string UserName { + get { return header.UserName; } - set - { + set { header.UserName = value; } } @@ -268,14 +219,11 @@ public string UserName /// /// Get/set this entry's group name. /// - public string GroupName - { - get - { + public string GroupName { + get { return header.GroupName; } - set - { + set { header.GroupName = value; } } @@ -313,14 +261,11 @@ public void SetNames(string userName, string groupName) /// /// Get/Set the modification time for this entry /// - public DateTime ModTime - { - get - { + public DateTime ModTime { + get { return header.ModTime; } - set - { + set { header.ModTime = value; } } @@ -331,10 +276,8 @@ public DateTime ModTime /// /// This entry's file. /// - public string File - { - get - { + public string File { + get { return file; } } @@ -342,14 +285,11 @@ public string File /// /// Get/set this entry's recorded file size. /// - public long Size - { - get - { + public long Size { + get { return header.Size; } - set - { + set { header.Size = value; } } @@ -360,10 +300,8 @@ public long Size /// /// True if this entry is a directory. /// - public bool IsDirectory - { - get - { + public bool IsDirectory { + get { if (file != null) { return Directory.Exists(file); } @@ -556,21 +494,3 @@ static public void NameTarHeader(TarHeader header, string name) #endregion } } - - - -/* The original Java file had this header: - * - ** Authored by Timothy Gerard Endres - ** - ** - ** This work has been placed into the public domain. - ** You may use this work in any way and for any purpose you wish. - ** - ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, - ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR - ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY - ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR - ** REDISTRIBUTION OF THIS SOFTWARE. - ** - */ diff --git a/ICSharpCode.SharpZipLib/Tar/TarException.cs b/ICSharpCode.SharpZipLib/Tar/TarException.cs index 43fb808ff..fb426c5f5 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarException.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarException.cs @@ -1,44 +1,8 @@ -// TarException.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Runtime.Serialization; namespace ICSharpCode.SharpZipLib.Tar { - /// /// TarExceptions are used for exceptions specific to tar classes and code. /// diff --git a/ICSharpCode.SharpZipLib/Tar/TarHeader.cs b/ICSharpCode.SharpZipLib/Tar/TarHeader.cs index 6178e2379..033f00064 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarHeader.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarHeader.cs @@ -1,84 +1,43 @@ -// TarHeader.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 27-07-2012 Z-1647 Added handling of Tar formats for files over 8GB such as Posix and Pax - -/* The tar format and its POSIX successor PAX have a long history which makes for compatability - issues when creating and reading files. - - This is further complicated by a large number of programs with variations on formats - One common issue is the handling of names longer than 100 characters. - GNU style long names are currently supported. - -This is the ustar (Posix 1003.1) header. - -struct header -{ - char t_name[100]; // 0 Filename - char t_mode[8]; // 100 Permissions - char t_uid[8]; // 108 Numerical User ID - char t_gid[8]; // 116 Numerical Group ID - char t_size[12]; // 124 Filesize - char t_mtime[12]; // 136 st_mtime - char t_chksum[8]; // 148 Checksum - char t_typeflag; // 156 Type of File - char t_linkname[100]; // 157 Target of Links - char t_magic[6]; // 257 "ustar" or other... - char t_version[2]; // 263 Version fixed to 00 - char t_uname[32]; // 265 User Name - char t_gname[32]; // 297 Group Name - char t_devmajor[8]; // 329 Major for devices - char t_devminor[8]; // 337 Minor for devices - char t_prefix[155]; // 345 Prefix for t_name - char t_mfill[12]; // 500 Filler up to 512 -}; - -*/ - using System; using System.Text; namespace ICSharpCode.SharpZipLib.Tar { - - /// /// This class encapsulates the Tar Entry Header used in Tar Archives. /// The class also holds a number of tar constants, used mostly in headers. /// + /// + /// The tar format and its POSIX successor PAX have a long history which makes for compatability + /// issues when creating and reading files. + /// + /// This is further complicated by a large number of programs with variations on formats + /// One common issue is the handling of names longer than 100 characters. + /// GNU style long names are currently supported. + /// + /// This is the ustar (Posix 1003.1) header. + /// + /// struct header + /// { + /// char t_name[100]; // 0 Filename + /// char t_mode[8]; // 100 Permissions + /// char t_uid[8]; // 108 Numerical User ID + /// char t_gid[8]; // 116 Numerical Group ID + /// char t_size[12]; // 124 Filesize + /// char t_mtime[12]; // 136 st_mtime + /// char t_chksum[8]; // 148 Checksum + /// char t_typeflag; // 156 Type of File + /// char t_linkname[100]; // 157 Target of Links + /// char t_magic[6]; // 257 "ustar" or other... + /// char t_version[2]; // 263 Version fixed to 00 + /// char t_uname[32]; // 265 User Name + /// char t_gname[32]; // 297 Group Name + /// char t_devmajor[8]; // 329 Major for devices + /// char t_devminor[8]; // 337 Minor for devices + /// char t_prefix[155]; // 345 Prefix for t_name + /// char t_mfill[12]; // 500 Filler up to 512 + /// }; + /// public class TarHeader : ICloneable { #region Constants @@ -306,11 +265,9 @@ public TarHeader() /// Get/set the name for this tar entry. /// /// Thrown when attempting to set the property to null. - public string Name - { + public string Name { get { return name; } - set - { + set { if (value == null) { throw new ArgumentNullException(nameof(value)); } @@ -331,8 +288,7 @@ public string GetName() /// /// Get/set the entry's Unix style permission mode. /// - public int Mode - { + public int Mode { get { return mode; } set { mode = value; } } @@ -345,8 +301,7 @@ public int Mode /// This is only directly relevant to unix systems. /// The default is zero. /// - public int UserId - { + public int UserId { get { return userId; } set { userId = value; } } @@ -359,8 +314,7 @@ public int UserId /// This is only directly relevant to linux/unix systems. /// The default value is zero. /// - public int GroupId - { + public int GroupId { get { return groupId; } set { groupId = value; } } @@ -370,11 +324,9 @@ public int GroupId /// Get/set the entry's size. /// /// Thrown when setting the size to less than zero. - public long Size - { + public long Size { get { return size; } - set - { + set { if (value < 0) { throw new ArgumentOutOfRangeException(nameof(value), "Cannot be less than zero"); } @@ -390,11 +342,9 @@ public long Size /// The modification time is only accurate to within a second. /// /// Thrown when setting the date time to less than 1/1/1970. - public DateTime ModTime - { + public DateTime ModTime { get { return modTime; } - set - { + set { if (value < dateTime1970) { throw new ArgumentOutOfRangeException(nameof(value), "ModTime cannot be before Jan 1st 1970"); } @@ -406,8 +356,7 @@ public DateTime ModTime /// /// Get the entry's checksum. This is only valid/updated after writing or reading an entry. /// - public int Checksum - { + public int Checksum { get { return checksum; } } @@ -415,8 +364,7 @@ public int Checksum /// /// Get value of true if the header checksum is valid, false otherwise. /// - public bool IsChecksumValid - { + public bool IsChecksumValid { get { return isChecksumValid; } } @@ -424,8 +372,7 @@ public bool IsChecksumValid /// /// Get/set the entry's type flag. /// - public byte TypeFlag - { + public byte TypeFlag { get { return typeFlag; } set { typeFlag = value; } } @@ -435,11 +382,9 @@ public byte TypeFlag /// The entry's link name. /// /// Thrown when attempting to set LinkName to null. - public string LinkName - { + public string LinkName { get { return linkName; } - set - { + set { if (value == null) { throw new ArgumentNullException(nameof(value)); } @@ -452,11 +397,9 @@ public string LinkName /// Get/set the entry's magic tag. /// /// Thrown when attempting to set Magic to null. - public string Magic - { + public string Magic { get { return magic; } - set - { + set { if (value == null) { throw new ArgumentNullException(nameof(value)); } @@ -469,15 +412,12 @@ public string Magic /// The entry's version. /// /// Thrown when attempting to set Version to null. - public string Version - { - get - { + public string Version { + get { return version; } - set - { + set { if (value == null) { throw new ArgumentNullException(nameof(value)); } @@ -489,11 +429,9 @@ public string Version /// /// The entry's user name. /// - public string UserName - { + public string UserName { get { return userName; } - set - { + set { if (value != null) { userName = value.Substring(0, Math.Min(UNAMELEN, value.Length)); } else { @@ -513,11 +451,9 @@ public string UserName /// /// This is only directly relevant to unix systems. /// - public string GroupName - { + public string GroupName { get { return groupName; } - set - { + set { if (value == null) { groupName = "None"; } else { @@ -530,8 +466,7 @@ public string GroupName /// /// Get/set the entry's major device number. /// - public int DevMajor - { + public int DevMajor { get { return devMajor; } set { devMajor = value; } } @@ -540,8 +475,7 @@ public int DevMajor /// /// Get/set the entry's minor device number. /// - public int DevMinor - { + public int DevMinor { get { return devMinor; } set { devMinor = value; } } @@ -1141,19 +1075,3 @@ static DateTime GetDateTimeFromCTime(long ticks) #endregion } } - -/* The original Java file had this header: - * -** Authored by Timothy Gerard Endres -** -** -** This work has been placed into the public domain. -** You may use this work in any way and for any purpose you wish. -** -** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, -** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR -** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY -** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR -** REDISTRIBUTION OF THIS SOFTWARE. -** -*/ diff --git a/ICSharpCode.SharpZipLib/Tar/TarInputStream.cs b/ICSharpCode.SharpZipLib/Tar/TarInputStream.cs index 3ee8216b5..1c4e85283 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarInputStream.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarInputStream.cs @@ -1,45 +1,9 @@ -// TarInputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; using System.Text; namespace ICSharpCode.SharpZipLib.Tar { - /// /// The TarInputStream reads a UNIX tar archive as an InputStream. /// methods are provided to position at each successive entry in @@ -75,8 +39,7 @@ public TarInputStream(Stream inputStream, int blockFactor) /// Get/set flag indicating ownership of the underlying stream. /// When the flag is true will close the underlying stream also. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return tarBuffer.IsStreamOwner; } set { tarBuffer.IsStreamOwner = value; } } @@ -85,10 +48,8 @@ public bool IsStreamOwner /// /// Gets a value indicating whether the current stream supports reading /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return inputStream.CanRead; } } @@ -97,10 +58,8 @@ public override bool CanRead /// Gets a value indicating whether the current stream supports seeking /// This property always returns false. /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -109,10 +68,8 @@ public override bool CanSeek /// Gets a value indicating if the stream supports writing. /// This property always returns false. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return false; } } @@ -120,10 +77,8 @@ public override bool CanWrite /// /// The length in bytes of the stream /// - public override long Length - { - get - { + public override long Length { + get { return inputStream.Length; } } @@ -133,14 +88,11 @@ public override long Length /// Setting the Position is not supported and throws a NotSupportedExceptionNotSupportedException /// /// Any attempt to set position - public override long Position - { - get - { + public override long Position { + get { return inputStream.Position; } - set - { + set { throw new NotSupportedException("TarInputStream Seek not supported"); } } @@ -321,8 +273,7 @@ public void SetEntryFactory(IEntryFactory factory) /// /// Get the record size being used by this stream's TarBuffer. /// - public int RecordSize - { + public int RecordSize { get { return tarBuffer.RecordSize; } } @@ -348,10 +299,8 @@ public int GetRecordSize() /// /// The number of available bytes for the current entry. /// - public long Available - { - get - { + public long Available { + get { return entrySize - entryOffset; } } @@ -389,10 +338,8 @@ public void Skip(long skipCount) /// Return a value of true if marking is supported; false otherwise. /// /// Currently marking is not supported, the return value is always false. - public bool IsMarkSupported - { - get - { + public bool IsMarkSupported { + get { return false; } } @@ -441,7 +388,8 @@ public TarEntry GetNextEntry() if (headerBuf == null) { hasHitEOF = true; - } else hasHitEOF |= TarBuffer.IsEndOfArchiveBlock(headerBuf); + } else + hasHitEOF |= TarBuffer.IsEndOfArchiveBlock(headerBuf); if (hasHitEOF) { currentEntry = null; @@ -676,19 +624,3 @@ public TarEntry CreateEntry(byte[] headerBuffer) #endregion } } - -/* The original Java file had this header: - ** Authored by Timothy Gerard Endres - ** - ** - ** This work has been placed into the public domain. - ** You may use this work in any way and for any purpose you wish. - ** - ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, - ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR - ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY - ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR - ** REDISTRIBUTION OF THIS SOFTWARE. - ** - */ - diff --git a/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs b/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs index b1c490fe5..37b9a7fed 100644 --- a/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs +++ b/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs @@ -1,47 +1,8 @@ -// TarOutputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2012-06-04 Z-1419 Last char of file name was dropped if path length > 100 - using System; using System.IO; namespace ICSharpCode.SharpZipLib.Tar { - /// /// The TarOutputStream writes a UNIX tar archive as an OutputStream. /// Methods are provided to put entries, and then write their contents @@ -83,8 +44,7 @@ public TarOutputStream(Stream outputStream, int blockFactor) /// Get/set flag indicating ownership of the underlying stream. /// When the flag is true will close the underlying stream also. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return buffer.IsStreamOwner; } set { buffer.IsStreamOwner = value; } } @@ -92,10 +52,8 @@ public bool IsStreamOwner /// /// true if the stream supports reading; otherwise, false. /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return outputStream.CanRead; } } @@ -103,10 +61,8 @@ public override bool CanRead /// /// true if the stream supports seeking; otherwise, false. /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return outputStream.CanSeek; } } @@ -114,10 +70,8 @@ public override bool CanSeek /// /// true if stream supports writing; otherwise, false. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return outputStream.CanWrite; } } @@ -125,10 +79,8 @@ public override bool CanWrite /// /// length of stream in bytes /// - public override long Length - { - get - { + public override long Length { + get { return outputStream.Length; } } @@ -136,14 +88,11 @@ public override long Length /// /// gets or sets the position within the current stream. /// - public override long Position - { - get - { + public override long Position { + get { return outputStream.Position; } - set - { + set { outputStream.Position = value; } } @@ -230,8 +179,7 @@ public override void Close() /// /// Get the record size being used by this stream's TarBuffer. /// - public int RecordSize - { + public int RecordSize { get { return buffer.RecordSize; } } @@ -250,8 +198,7 @@ public int GetRecordSize() /// /// Get a value indicating wether an entry is open, requiring more data to be written. /// - bool IsEntryOpen - { + bool IsEntryOpen { get { return (currBytes < currSize); } } @@ -493,18 +440,3 @@ void WriteEofBlock() #endregion } } - -/* The original Java file had this header: - ** Authored by Timothy Gerard Endres - ** - ** - ** This work has been placed into the public domain. - ** You may use this work in any way and for any purpose you wish. - ** - ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, - ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR - ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY - ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR - ** REDISTRIBUTION OF THIS SOFTWARE. - ** - */ diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Deflater.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Deflater.cs index 3db88cc6e..ae9aa0886 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/Deflater.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/Deflater.cs @@ -1,46 +1,7 @@ -// Deflater.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// This is the Deflater class. The deflater class compresses input /// with the deflate algorithm described in RFC 1951. It has several @@ -200,10 +161,8 @@ public void Reset() /// /// Gets the current adler checksum of the data that was processed so far. /// - public int Adler - { - get - { + public int Adler { + get { return engine.Adler; } } @@ -211,10 +170,8 @@ public int Adler /// /// Gets the number of input bytes processed so far. /// - public long TotalIn - { - get - { + public long TotalIn { + get { return engine.TotalIn; } } @@ -222,10 +179,8 @@ public long TotalIn /// /// Gets the number of output bytes so far. /// - public long TotalOut - { - get - { + public long TotalOut { + get { return totalOut; } } @@ -256,10 +211,8 @@ public void Finish() /// Returns true if the stream was finished and no more output bytes /// are available. /// - public bool IsFinished - { - get - { + public bool IsFinished { + get { return (state == FINISHED_STATE) && pending.IsFlushed; } } @@ -270,10 +223,8 @@ public bool IsFinished /// NOTE: This method can also return true when the stream /// was finished. /// - public bool IsNeedingInput - { - get - { + public bool IsNeedingInput { + get { return engine.NeedsInput(); } } @@ -453,37 +404,37 @@ public int Deflate(byte[] output, int offset, int length) if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) { switch (state) { - case BUSY_STATE: - // We need more input now - return origLength - length; - case FLUSHING_STATE: - if (level != NO_COMPRESSION) { - /* We have to supply some lookahead. 8 bit lookahead - * is needed by the zlib inflater, and we must fill - * the next byte, so that all bits are flushed. - */ - int neededbits = 8 + ((-pending.BitCount) & 7); - while (neededbits > 0) { - /* write a static tree block consisting solely of - * an EOF: + case BUSY_STATE: + // We need more input now + return origLength - length; + case FLUSHING_STATE: + if (level != NO_COMPRESSION) { + /* We have to supply some lookahead. 8 bit lookahead + * is needed by the zlib inflater, and we must fill + * the next byte, so that all bits are flushed. */ - pending.WriteBits(2, 10); - neededbits -= 10; + int neededbits = 8 + ((-pending.BitCount) & 7); + while (neededbits > 0) { + /* write a static tree block consisting solely of + * an EOF: + */ + pending.WriteBits(2, 10); + neededbits -= 10; + } + } + state = BUSY_STATE; + break; + case FINISHING_STATE: + pending.AlignToByte(); + + // Compressed data is complete. Write footer information if required. + if (!noZlibHeaderOrFooter) { + int adler = engine.Adler; + pending.WriteShortMSB(adler >> 16); + pending.WriteShortMSB(adler & 0xffff); } - } - state = BUSY_STATE; - break; - case FINISHING_STATE: - pending.AlignToByte(); - - // Compressed data is complete. Write footer information if required. - if (!noZlibHeaderOrFooter) { - int adler = engine.Adler; - pending.WriteShortMSB(adler >> 16); - pending.WriteShortMSB(adler & 0xffff); - } - state = FINISHED_STATE; - break; + state = FINISHED_STATE; + break; } } } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterConstants.cs b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterConstants.cs index f43925ab9..b66efb06e 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterConstants.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterConstants.cs @@ -1,46 +1,7 @@ -// DeflaterConstants.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// This class contains constants used for deflation. /// diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterEngine.cs b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterEngine.cs index e47bcfc4c..5bfdf267b 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterEngine.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterEngine.cs @@ -1,48 +1,8 @@ -// DeflaterEngine.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; - using ICSharpCode.SharpZipLib.Checksum; namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// Strategies for deflater /// @@ -136,17 +96,17 @@ public bool Deflate(bool flush, bool finish) } #endif switch (compressionFunction) { - case DeflaterConstants.DEFLATE_STORED: - progress = DeflateStored(canFlush, finish); - break; - case DeflaterConstants.DEFLATE_FAST: - progress = DeflateFast(canFlush, finish); - break; - case DeflaterConstants.DEFLATE_SLOW: - progress = DeflateSlow(canFlush, finish); - break; - default: - throw new InvalidOperationException("unknown compressionFunction"); + case DeflaterConstants.DEFLATE_STORED: + progress = DeflateStored(canFlush, finish); + break; + case DeflaterConstants.DEFLATE_FAST: + progress = DeflateFast(canFlush, finish); + break; + case DeflaterConstants.DEFLATE_SLOW: + progress = DeflateSlow(canFlush, finish); + break; + default: + throw new InvalidOperationException("unknown compressionFunction"); } } while (pending.IsFlushed && progress); // repeat while we have no pending output and progress was made return progress; @@ -269,10 +229,8 @@ public void ResetAdler() /// /// Get current value of Adler checksum /// - public int Adler - { - get - { + public int Adler { + get { return unchecked((int)adler.Value); } } @@ -280,10 +238,8 @@ public int Adler /// /// Total data processed /// - public long TotalIn - { - get - { + public long TotalIn { + get { return totalIn; } } @@ -291,14 +247,11 @@ public long TotalIn /// /// Get/set the deflate strategy /// - public DeflateStrategy Strategy - { - get - { + public DeflateStrategy Strategy { + get { return strategy; } - set - { + set { strategy = value; } } @@ -327,34 +280,34 @@ public void SetLevel(int level) } #endif switch (compressionFunction) { - case DeflaterConstants.DEFLATE_STORED: - if (strstart > blockStart) { - huffman.FlushStoredBlock(window, blockStart, - strstart - blockStart, false); - blockStart = strstart; - } - UpdateHash(); - break; - - case DeflaterConstants.DEFLATE_FAST: - if (strstart > blockStart) { - huffman.FlushBlock(window, blockStart, strstart - blockStart, - false); - blockStart = strstart; - } - break; + case DeflaterConstants.DEFLATE_STORED: + if (strstart > blockStart) { + huffman.FlushStoredBlock(window, blockStart, + strstart - blockStart, false); + blockStart = strstart; + } + UpdateHash(); + break; - case DeflaterConstants.DEFLATE_SLOW: - if (prevAvailable) { - huffman.TallyLit(window[strstart - 1] & 0xff); - } - if (strstart > blockStart) { - huffman.FlushBlock(window, blockStart, strstart - blockStart, false); - blockStart = strstart; - } - prevAvailable = false; - matchLen = DeflaterConstants.MIN_MATCH - 1; - break; + case DeflaterConstants.DEFLATE_FAST: + if (strstart > blockStart) { + huffman.FlushBlock(window, blockStart, strstart - blockStart, + false); + blockStart = strstart; + } + break; + + case DeflaterConstants.DEFLATE_SLOW: + if (prevAvailable) { + huffman.TallyLit(window[strstart - 1] & 0xff); + } + if (strstart > blockStart) { + huffman.FlushBlock(window, blockStart, strstart - blockStart, false); + blockStart = strstart; + } + prevAvailable = false; + matchLen = DeflaterConstants.MIN_MATCH - 1; + break; } compressionFunction = DeflaterConstants.COMPR_FUNC[level]; } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterHuffman.cs b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterHuffman.cs index 869be8089..d26e79339 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterHuffman.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterHuffman.cs @@ -1,46 +1,7 @@ -// DeflaterHuffman.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// This is the DeflaterHuffman class. /// diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterPending.cs b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterPending.cs index c2b7f6384..2c6c22e1d 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterPending.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/DeflaterPending.cs @@ -1,44 +1,5 @@ -// DeflaterPending.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// This class stores the pending output of the Deflater. /// diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Inflater.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Inflater.cs index db02f2020..8d6d7a0ef 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/Inflater.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/Inflater.cs @@ -1,43 +1,4 @@ -// Inflater.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; - using ICSharpCode.SharpZipLib.Checksum; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; @@ -307,81 +268,81 @@ private bool DecodeHuffman() while (free >= 258) { int symbol; switch (mode) { - case DECODE_HUFFMAN: - // This is the inner loop so it is optimized a bit - while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) { - outputWindow.Write(symbol); - if (--free < 258) { - return true; + case DECODE_HUFFMAN: + // This is the inner loop so it is optimized a bit + while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) { + outputWindow.Write(symbol); + if (--free < 258) { + return true; + } } - } - if (symbol < 257) { - if (symbol < 0) { - return false; - } else { - // symbol == 256: end of block - distTree = null; - litlenTree = null; - mode = DECODE_BLOCKS; - return true; + if (symbol < 257) { + if (symbol < 0) { + return false; + } else { + // symbol == 256: end of block + distTree = null; + litlenTree = null; + mode = DECODE_BLOCKS; + return true; + } } - } - try { - repLength = CPLENS[symbol - 257]; - neededBits = CPLEXT[symbol - 257]; - } catch (Exception) { - throw new SharpZipBaseException("Illegal rep length code"); - } - goto case DECODE_HUFFMAN_LENBITS; // fall through + try { + repLength = CPLENS[symbol - 257]; + neededBits = CPLEXT[symbol - 257]; + } catch (Exception) { + throw new SharpZipBaseException("Illegal rep length code"); + } + goto case DECODE_HUFFMAN_LENBITS; // fall through + + case DECODE_HUFFMAN_LENBITS: + if (neededBits > 0) { + mode = DECODE_HUFFMAN_LENBITS; + int i = input.PeekBits(neededBits); + if (i < 0) { + return false; + } + input.DropBits(neededBits); + repLength += i; + } + mode = DECODE_HUFFMAN_DIST; + goto case DECODE_HUFFMAN_DIST; // fall through - case DECODE_HUFFMAN_LENBITS: - if (neededBits > 0) { - mode = DECODE_HUFFMAN_LENBITS; - int i = input.PeekBits(neededBits); - if (i < 0) { + case DECODE_HUFFMAN_DIST: + symbol = distTree.GetSymbol(input); + if (symbol < 0) { return false; } - input.DropBits(neededBits); - repLength += i; - } - mode = DECODE_HUFFMAN_DIST; - goto case DECODE_HUFFMAN_DIST; // fall through - - case DECODE_HUFFMAN_DIST: - symbol = distTree.GetSymbol(input); - if (symbol < 0) { - return false; - } - try { - repDist = CPDIST[symbol]; - neededBits = CPDEXT[symbol]; - } catch (Exception) { - throw new SharpZipBaseException("Illegal rep dist code"); - } - - goto case DECODE_HUFFMAN_DISTBITS; // fall through + try { + repDist = CPDIST[symbol]; + neededBits = CPDEXT[symbol]; + } catch (Exception) { + throw new SharpZipBaseException("Illegal rep dist code"); + } - case DECODE_HUFFMAN_DISTBITS: - if (neededBits > 0) { - mode = DECODE_HUFFMAN_DISTBITS; - int i = input.PeekBits(neededBits); - if (i < 0) { - return false; + goto case DECODE_HUFFMAN_DISTBITS; // fall through + + case DECODE_HUFFMAN_DISTBITS: + if (neededBits > 0) { + mode = DECODE_HUFFMAN_DISTBITS; + int i = input.PeekBits(neededBits); + if (i < 0) { + return false; + } + input.DropBits(neededBits); + repDist += i; } - input.DropBits(neededBits); - repDist += i; - } - outputWindow.Repeat(repLength, repDist); - free -= repLength; - mode = DECODE_HUFFMAN; - break; + outputWindow.Repeat(repLength, repDist); + free -= repLength; + mode = DECODE_HUFFMAN; + break; - default: - throw new SharpZipBaseException("Inflater unknown mode"); + default: + throw new SharpZipBaseException("Inflater unknown mode"); } } return true; @@ -428,107 +389,107 @@ private bool DecodeChksum() private bool Decode() { switch (mode) { - case DECODE_HEADER: - return DecodeHeader(); + case DECODE_HEADER: + return DecodeHeader(); - case DECODE_DICT: - return DecodeDict(); + case DECODE_DICT: + return DecodeDict(); - case DECODE_CHKSUM: - return DecodeChksum(); + case DECODE_CHKSUM: + return DecodeChksum(); - case DECODE_BLOCKS: - if (isLastBlock) { - if (noHeader) { - mode = FINISHED; - return false; - } else { - input.SkipToByteBoundary(); - neededBits = 32; - mode = DECODE_CHKSUM; - return true; + case DECODE_BLOCKS: + if (isLastBlock) { + if (noHeader) { + mode = FINISHED; + return false; + } else { + input.SkipToByteBoundary(); + neededBits = 32; + mode = DECODE_CHKSUM; + return true; + } } - } - int type = input.PeekBits(3); - if (type < 0) { - return false; - } - input.DropBits(3); - - isLastBlock |= (type & 1) != 0; - switch (type >> 1) { - case DeflaterConstants.STORED_BLOCK: - input.SkipToByteBoundary(); - mode = DECODE_STORED_LEN1; - break; - case DeflaterConstants.STATIC_TREES: - litlenTree = InflaterHuffmanTree.defLitLenTree; - distTree = InflaterHuffmanTree.defDistTree; - mode = DECODE_HUFFMAN; - break; - case DeflaterConstants.DYN_TREES: - dynHeader = new InflaterDynHeader(); - mode = DECODE_DYN_HEADER; - break; - default: - throw new SharpZipBaseException("Unknown block type " + type); - } - return true; - - case DECODE_STORED_LEN1: { - if ((uncomprLen = input.PeekBits(16)) < 0) { + int type = input.PeekBits(3); + if (type < 0) { return false; } - input.DropBits(16); - mode = DECODE_STORED_LEN2; - } - goto case DECODE_STORED_LEN2; // fall through + input.DropBits(3); + + isLastBlock |= (type & 1) != 0; + switch (type >> 1) { + case DeflaterConstants.STORED_BLOCK: + input.SkipToByteBoundary(); + mode = DECODE_STORED_LEN1; + break; + case DeflaterConstants.STATIC_TREES: + litlenTree = InflaterHuffmanTree.defLitLenTree; + distTree = InflaterHuffmanTree.defDistTree; + mode = DECODE_HUFFMAN; + break; + case DeflaterConstants.DYN_TREES: + dynHeader = new InflaterDynHeader(); + mode = DECODE_DYN_HEADER; + break; + default: + throw new SharpZipBaseException("Unknown block type " + type); + } + return true; - case DECODE_STORED_LEN2: { - int nlen = input.PeekBits(16); - if (nlen < 0) { - return false; + case DECODE_STORED_LEN1: { + if ((uncomprLen = input.PeekBits(16)) < 0) { + return false; + } + input.DropBits(16); + mode = DECODE_STORED_LEN2; } - input.DropBits(16); - if (nlen != (uncomprLen ^ 0xffff)) { - throw new SharpZipBaseException("broken uncompressed block"); + goto case DECODE_STORED_LEN2; // fall through + + case DECODE_STORED_LEN2: { + int nlen = input.PeekBits(16); + if (nlen < 0) { + return false; + } + input.DropBits(16); + if (nlen != (uncomprLen ^ 0xffff)) { + throw new SharpZipBaseException("broken uncompressed block"); + } + mode = DECODE_STORED; } - mode = DECODE_STORED; - } - goto case DECODE_STORED; // fall through - - case DECODE_STORED: { - int more = outputWindow.CopyStored(input, uncomprLen); - uncomprLen -= more; - if (uncomprLen == 0) { - mode = DECODE_BLOCKS; - return true; + goto case DECODE_STORED; // fall through + + case DECODE_STORED: { + int more = outputWindow.CopyStored(input, uncomprLen); + uncomprLen -= more; + if (uncomprLen == 0) { + mode = DECODE_BLOCKS; + return true; + } + return !input.IsNeedingInput; } - return !input.IsNeedingInput; - } - case DECODE_DYN_HEADER: - if (!dynHeader.Decode(input)) { - return false; - } + case DECODE_DYN_HEADER: + if (!dynHeader.Decode(input)) { + return false; + } - litlenTree = dynHeader.BuildLitLenTree(); - distTree = dynHeader.BuildDistTree(); - mode = DECODE_HUFFMAN; - goto case DECODE_HUFFMAN; // fall through + litlenTree = dynHeader.BuildLitLenTree(); + distTree = dynHeader.BuildDistTree(); + mode = DECODE_HUFFMAN; + goto case DECODE_HUFFMAN; // fall through - case DECODE_HUFFMAN: - case DECODE_HUFFMAN_LENBITS: - case DECODE_HUFFMAN_DIST: - case DECODE_HUFFMAN_DISTBITS: - return DecodeHuffman(); + case DECODE_HUFFMAN: + case DECODE_HUFFMAN_LENBITS: + case DECODE_HUFFMAN_DIST: + case DECODE_HUFFMAN_DISTBITS: + return DecodeHuffman(); - case FINISHED: - return false; + case FINISHED: + return false; - default: - throw new SharpZipBaseException("Inflater.Decode unknown mode"); + default: + throw new SharpZipBaseException("Inflater.Decode unknown mode"); } } @@ -745,10 +706,8 @@ public int Inflate(byte[] buffer, int offset, int count) /// You should then call setInput(). /// NOTE: This method also returns true when the stream is finished. /// - public bool IsNeedingInput - { - get - { + public bool IsNeedingInput { + get { return input.IsNeedingInput; } } @@ -756,10 +715,8 @@ public bool IsNeedingInput /// /// Returns true, if a preset dictionary is needed to inflate the input. /// - public bool IsNeedingDictionary - { - get - { + public bool IsNeedingDictionary { + get { return mode == DECODE_DICT && neededBits == 0; } } @@ -768,10 +725,8 @@ public bool IsNeedingDictionary /// Returns true, if the inflater has finished. This means, that no /// input is needed and no output can be produced. /// - public bool IsFinished - { - get - { + public bool IsFinished { + get { return mode == FINISHED && outputWindow.GetAvailable() == 0; } } @@ -785,10 +740,8 @@ public bool IsFinished /// /// the adler checksum. /// - public int Adler - { - get - { + public int Adler { + get { return IsNeedingDictionary ? readAdler : (int)adler.Value; } } @@ -799,10 +752,8 @@ public int Adler /// /// the total number of output bytes. /// - public long TotalOut - { - get - { + public long TotalOut { + get { return totalOut; } } @@ -813,10 +764,8 @@ public long TotalOut /// /// The total number of bytes of processed input bytes. /// - public long TotalIn - { - get - { + public long TotalIn { + get { return totalIn - (long)RemainingInput; } } @@ -829,11 +778,9 @@ public long TotalIn /// /// The number of bytes of the input which have not been processed. /// - public int RemainingInput - { + public int RemainingInput { // TODO: This should be a long? - get - { + get { return input.AvailableBytes; } } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/InflaterDynHeader.cs b/ICSharpCode.SharpZipLib/Zip/Compression/InflaterDynHeader.cs index 5160e3c23..31a366da6 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/InflaterDynHeader.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/InflaterDynHeader.cs @@ -1,48 +1,8 @@ -// InflaterDynHeader.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; - using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.Zip.Compression { - class InflaterDynHeader { #region Constants @@ -65,113 +25,113 @@ public bool Decode(StreamManipulator input) decode_loop: for (;;) { switch (mode) { - case LNUM: - lnum = input.PeekBits(5); - if (lnum < 0) { - return false; - } - lnum += 257; - input.DropBits(5); - // System.err.println("LNUM: "+lnum); - mode = DNUM; - goto case DNUM; // fall through - case DNUM: - dnum = input.PeekBits(5); - if (dnum < 0) { - return false; - } - dnum++; - input.DropBits(5); - // System.err.println("DNUM: "+dnum); - num = lnum + dnum; - litdistLens = new byte[num]; - mode = BLNUM; - goto case BLNUM; // fall through - case BLNUM: - blnum = input.PeekBits(4); - if (blnum < 0) { - return false; - } - blnum += 4; - input.DropBits(4); - blLens = new byte[19]; - ptr = 0; - // System.err.println("BLNUM: "+blnum); - mode = BLLENS; - goto case BLLENS; // fall through - case BLLENS: - while (ptr < blnum) { - int len = input.PeekBits(3); - if (len < 0) { + case LNUM: + lnum = input.PeekBits(5); + if (lnum < 0) { return false; } - input.DropBits(3); - // System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len); - blLens[BL_ORDER[ptr]] = (byte)len; - ptr++; - } - blTree = new InflaterHuffmanTree(blLens); - blLens = null; - ptr = 0; - mode = LENS; - goto case LENS; // fall through - case LENS: { - int symbol; - while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) { - /* Normal case: symbol in [0..15] */ - - // System.err.println("litdistLens["+ptr+"]: "+symbol); - litdistLens[ptr++] = lastLen = (byte)symbol; - - if (ptr == num) { - /* Finished */ - return true; - } + lnum += 257; + input.DropBits(5); + // System.err.println("LNUM: "+lnum); + mode = DNUM; + goto case DNUM; // fall through + case DNUM: + dnum = input.PeekBits(5); + if (dnum < 0) { + return false; } - - /* need more input ? */ - if (symbol < 0) { + dnum++; + input.DropBits(5); + // System.err.println("DNUM: "+dnum); + num = lnum + dnum; + litdistLens = new byte[num]; + mode = BLNUM; + goto case BLNUM; // fall through + case BLNUM: + blnum = input.PeekBits(4); + if (blnum < 0) { return false; } - - /* otherwise repeat code */ - if (symbol >= 17) { - /* repeat zero */ - // System.err.println("repeating zero"); - lastLen = 0; - } else { - if (ptr == 0) { - throw new SharpZipBaseException(); + blnum += 4; + input.DropBits(4); + blLens = new byte[19]; + ptr = 0; + // System.err.println("BLNUM: "+blnum); + mode = BLLENS; + goto case BLLENS; // fall through + case BLLENS: + while (ptr < blnum) { + int len = input.PeekBits(3); + if (len < 0) { + return false; } + input.DropBits(3); + // System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len); + blLens[BL_ORDER[ptr]] = (byte)len; + ptr++; } - repSymbol = symbol - 16; - } - mode = REPS; - goto case REPS; // fall through - case REPS: { - int bits = repBits[repSymbol]; - int count = input.PeekBits(bits); - if (count < 0) { - return false; - } - input.DropBits(bits); - count += repMin[repSymbol]; - // System.err.println("litdistLens repeated: "+count); + blTree = new InflaterHuffmanTree(blLens); + blLens = null; + ptr = 0; + mode = LENS; + goto case LENS; // fall through + case LENS: { + int symbol; + while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) { + /* Normal case: symbol in [0..15] */ + + // System.err.println("litdistLens["+ptr+"]: "+symbol); + litdistLens[ptr++] = lastLen = (byte)symbol; + + if (ptr == num) { + /* Finished */ + return true; + } + } - if (ptr + count > num) { - throw new SharpZipBaseException(); - } - while (count-- > 0) { - litdistLens[ptr++] = lastLen; + /* need more input ? */ + if (symbol < 0) { + return false; + } + + /* otherwise repeat code */ + if (symbol >= 17) { + /* repeat zero */ + // System.err.println("repeating zero"); + lastLen = 0; + } else { + if (ptr == 0) { + throw new SharpZipBaseException(); + } + } + repSymbol = symbol - 16; } + mode = REPS; + goto case REPS; // fall through + case REPS: { + int bits = repBits[repSymbol]; + int count = input.PeekBits(bits); + if (count < 0) { + return false; + } + input.DropBits(bits); + count += repMin[repSymbol]; + // System.err.println("litdistLens repeated: "+count); + + if (ptr + count > num) { + throw new SharpZipBaseException(); + } + while (count-- > 0) { + litdistLens[ptr++] = lastLen; + } - if (ptr == num) { - /* Finished */ - return true; + if (ptr == num) { + /* Finished */ + return true; + } } - } - mode = LENS; - goto decode_loop; + mode = LENS; + goto decode_loop; } } } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs b/ICSharpCode.SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs index 881cfe8cc..152a4029f 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs @@ -1,48 +1,8 @@ -// InflaterHuffmanTree.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; - using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// Huffman tree used for inflation /// diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs b/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs index c1c4db36c..f1f323a5e 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs @@ -1,46 +1,7 @@ -// PendingBuffer.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { - /// /// This class is general purpose class for writing data to a buffer. /// @@ -168,10 +129,8 @@ public void WriteBlock(byte[] block, int offset, int length) /// /// The number of bits written to the buffer /// - public int BitCount - { - get - { + public int BitCount { + get { return bitCount; } } @@ -243,10 +202,8 @@ public void WriteShortMSB(int s) /// /// Indicates if buffer has been flushed /// - public bool IsFlushed - { - get - { + public bool IsFlushed { + get { return end == 0; } } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs index 21d45194a..23f45f2e4 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs @@ -1,44 +1,3 @@ -// DeflaterOutputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 22-12-2009 DavidPierson Added AES support - using System; using System.IO; using System.Security.Cryptography; @@ -168,8 +127,7 @@ public virtual void Finish() /// Get/set flag indicating ownership of the underlying stream. /// When the flag is true will close the underlying stream also. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner_; } set { isStreamOwner_ = value; } } @@ -177,10 +135,8 @@ public bool IsStreamOwner /// /// Allows client to determine if an entry can be patched after its added /// - public bool CanPatchEntries - { - get - { + public bool CanPatchEntries { + get { return baseOutputStream_.CanSeek; } } @@ -202,14 +158,11 @@ public bool CanPatchEntries /// Get/set the password used for encryption. /// /// When set to null or if the password is empty no encryption is performed - public string Password - { - get - { + public string Password { + get { return password; } - set - { + set { if ((value != null) && (value.Length == 0)) { password = null; } else { @@ -296,10 +249,8 @@ protected void Deflate() /// /// Gets value indicating stream can be read from /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return false; } } @@ -308,10 +259,8 @@ public override bool CanRead /// Gets a value indicating if seeking is supported for this stream /// This property always returns false /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -319,10 +268,8 @@ public override bool CanSeek /// /// Get value indicating if this stream supports writing /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return baseOutputStream_.CanWrite; } } @@ -330,10 +277,8 @@ public override bool CanWrite /// /// Get current length of stream /// - public override long Length - { - get - { + public override long Length { + get { return baseOutputStream_.Length; } } @@ -342,14 +287,11 @@ public override long Length /// Gets the current position within the stream. /// /// Any attempt to set position - public override long Position - { - get - { + public override long Position { + get { return baseOutputStream_.Position; } - set - { + set { throw new NotSupportedException("Position property not supported"); } } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs index bb06e9c4d..1ac219d0e 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs @@ -1,51 +1,9 @@ -// InflaterInputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 11-08-2009 GeoffHart T9121 Added Multi-member gzip support - using System; using System.IO; using System.Security.Cryptography; namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { - /// /// An input buffer customised for use by /// @@ -83,10 +41,8 @@ public InflaterInputBuffer(Stream stream, int bufferSize) /// /// Get the length of bytes bytes in the /// - public int RawLength - { - get - { + public int RawLength { + get { return rawLength; } } @@ -95,10 +51,8 @@ public int RawLength /// Get the contents of the raw data buffer. /// /// This may contain encrypted data. - public byte[] RawData - { - get - { + public byte[] RawData { + get { return rawData; } } @@ -106,10 +60,8 @@ public byte[] RawData /// /// Get the number of useable bytes in /// - public int ClearTextLength - { - get - { + public int ClearTextLength { + get { return clearTextLength; } } @@ -117,10 +69,8 @@ public int ClearTextLength /// /// Get the contents of the clear text buffer. /// - public byte[] ClearText - { - get - { + public byte[] ClearText { + get { return clearText; } } @@ -128,8 +78,7 @@ public byte[] ClearText /// /// Get/set the number of bytes available /// - public int Available - { + public int Available { get { return available; } set { available = value; } } @@ -295,10 +244,8 @@ public long ReadLeLong() /// Get/set the to apply to any data. /// /// Set this value to null to have no transform applied. - public ICryptoTransform CryptoTransform - { - set - { + public ICryptoTransform CryptoTransform { + set { cryptoTransform = value; if (cryptoTransform != null) { if (rawData == clearText) { @@ -414,8 +361,7 @@ public InflaterInputStream(Stream baseInputStream, Inflater inflater, int buffer /// /// The default value is true. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } @@ -478,10 +424,8 @@ protected void StopDecrypting() /// Returns 0 once the end of the stream (EOF) has been reached. /// Otherwise returns 1. /// - public virtual int Available - { - get - { + public virtual int Available { + get { return inf.IsFinished ? 0 : 1; } } @@ -508,10 +452,8 @@ protected void Fill() /// /// Gets a value indicating whether the current stream supports reading /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return baseInputStream.CanRead; } } @@ -519,10 +461,8 @@ public override bool CanRead /// /// Gets a value of false indicating seeking is not supported for this stream. /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -530,10 +470,8 @@ public override bool CanSeek /// /// Gets a value of false indicating that this stream is not writeable. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return false; } } @@ -541,10 +479,8 @@ public override bool CanWrite /// /// A value representing the length of the stream in bytes. /// - public override long Length - { - get - { + public override long Length { + get { return inputBuffer.RawLength; } } @@ -554,14 +490,11 @@ public override long Length /// Throws a NotSupportedException when attempting to set the position /// /// Attempting to set the position - public override long Position - { - get - { + public override long Position { + get { return baseInputStream.Position; } - set - { + set { throw new NotSupportedException("InflaterInputStream Position not supported"); } } diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/OutputWindow.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/OutputWindow.cs index 3e0055b92..cd31784c0 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/OutputWindow.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/OutputWindow.cs @@ -1,47 +1,7 @@ -// OutputWindow.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; - namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { - /// /// Contains the output from the Inflation process. /// We need to have a window so that we can refer backwards into the output stream diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs index f055bf864..e73a50c54 100644 --- a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs +++ b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs @@ -1,46 +1,7 @@ -// StreamManipulator.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { - /// /// This class allows us to retrieve a specified number of bits from /// the input buffer, as well as copy big byte blocks. @@ -116,10 +77,8 @@ public int GetBits(int bitCount) /// /// the number of bits available. /// - public int AvailableBits - { - get - { + public int AvailableBits { + get { return bitsInBuffer_; } } @@ -130,10 +89,8 @@ public int AvailableBits /// /// The number of bytes available. /// - public int AvailableBytes - { - get - { + public int AvailableBytes { + get { return windowEnd_ - windowStart_ + (bitsInBuffer_ >> 3); } } @@ -150,10 +107,8 @@ public void SkipToByteBoundary() /// /// Returns true when SetInput can be called /// - public bool IsNeedingInput - { - get - { + public bool IsNeedingInput { + get { return windowStart_ == windowEnd_; } } diff --git a/ICSharpCode.SharpZipLib/Zip/FastZip.cs b/ICSharpCode.SharpZipLib/Zip/FastZip.cs index 0338d2562..53e1288df 100644 --- a/ICSharpCode.SharpZipLib/Zip/FastZip.cs +++ b/ICSharpCode.SharpZipLib/Zip/FastZip.cs @@ -1,38 +1,3 @@ -// FastZip.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; using ICSharpCode.SharpZipLib.Core; @@ -171,8 +136,7 @@ public bool OnProcessDirectory(string directory, bool hasMatchingFiles) /// The minimum period of time between events. /// /// The default interval is three seconds. - public TimeSpan ProgressInterval - { + public TimeSpan ProgressInterval { get { return progressInterval_; } set { progressInterval_ = value; } } @@ -230,8 +194,7 @@ public FastZip(FastZipEvents events) /// /// Get/set a value indicating wether empty directories should be created. /// - public bool CreateEmptyDirectories - { + public bool CreateEmptyDirectories { get { return createEmptyDirectories_; } set { createEmptyDirectories_ = value; } } @@ -239,8 +202,7 @@ public bool CreateEmptyDirectories /// /// Get / set the password value. /// - public string Password - { + public string Password { get { return password_; } set { password_ = value; } } @@ -249,11 +211,9 @@ public string Password /// Get or set the active when creating Zip files. /// /// - public INameTransform NameTransform - { + public INameTransform NameTransform { get { return entryFactory_.NameTransform; } - set - { + set { entryFactory_.NameTransform = value; } } @@ -261,11 +221,9 @@ public INameTransform NameTransform /// /// Get or set the active when creating Zip files. /// - public IEntryFactory EntryFactory - { + public IEntryFactory EntryFactory { get { return entryFactory_; } - set - { + set { if (value == null) { entryFactory_ = new ZipEntryFactory(); } else { @@ -285,8 +243,7 @@ public IEntryFactory EntryFactory /// NOTE: Setting the size for entries before they are added is the best solution! /// By default the EntryFactory used by FastZip will set fhe file size. /// - public UseZip64 UseZip64 - { + public UseZip64 UseZip64 { get { return useZip64_; } set { useZip64_ = value; } } @@ -296,14 +253,11 @@ public UseZip64 UseZip64 /// be restored when extracting files from an archive. /// /// The default value is false. - public bool RestoreDateTimeOnExtract - { - get - { + public bool RestoreDateTimeOnExtract { + get { return restoreDateTimeOnExtract_; } - set - { + set { restoreDateTimeOnExtract_ = value; } } @@ -312,8 +266,7 @@ public bool RestoreDateTimeOnExtract /// Get/set a value indicating wether file attributes should /// be restored during extract operations /// - public bool RestoreAttributesOnExtract - { + public bool RestoreAttributesOnExtract { get { return restoreAttributesOnExtract_; } set { restoreAttributesOnExtract_ = value; } } diff --git a/ICSharpCode.SharpZipLib/Zip/IEntryFactory.cs b/ICSharpCode.SharpZipLib/Zip/IEntryFactory.cs index 30d8cd680..bbe40c4d7 100644 --- a/ICSharpCode.SharpZipLib/Zip/IEntryFactory.cs +++ b/ICSharpCode.SharpZipLib/Zip/IEntryFactory.cs @@ -1,44 +1,3 @@ -// IEntryFactory.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2012-11-29 Z-1684 Added MakeFileEntry(string fileName, string entryName, bool useFileSystem) - using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip diff --git a/ICSharpCode.SharpZipLib/Zip/WindowsNameTransform.cs b/ICSharpCode.SharpZipLib/Zip/WindowsNameTransform.cs index 992dd15e1..86e970917 100644 --- a/ICSharpCode.SharpZipLib/Zip/WindowsNameTransform.cs +++ b/ICSharpCode.SharpZipLib/Zip/WindowsNameTransform.cs @@ -1,42 +1,6 @@ -// WindowsNameTransform.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; using System.Text; - using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip @@ -70,11 +34,9 @@ public WindowsNameTransform() /// /// Gets or sets a value containing the target directory to prefix values with. /// - public string BaseDirectory - { + public string BaseDirectory { get { return _baseDirectory; } - set - { + set { if (value == null) { throw new ArgumentNullException(nameof(value)); } @@ -86,8 +48,7 @@ public string BaseDirectory /// /// Gets or sets a value indicating wether paths on incoming values should be removed. /// - public bool TrimIncomingPaths - { + public bool TrimIncomingPaths { get { return _trimIncomingPaths; } set { _trimIncomingPaths = value; } } @@ -229,11 +190,9 @@ public static string MakeValidName(string name, char replacement) /// /// Gets or set the character to replace invalid characters during transformations. /// - public char Replacement - { + public char Replacement { get { return _replacementChar; } - set - { + set { for (int i = 0; i < InvalidEntryChars.Length; ++i) { if (InvalidEntryChars[i] == value) { throw new ArgumentException("invalid path character"); diff --git a/ICSharpCode.SharpZipLib/Zip/ZipConstants.cs b/ICSharpCode.SharpZipLib/Zip/ZipConstants.cs index 2702ac1c8..850254e11 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipConstants.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipConstants.cs @@ -1,51 +1,9 @@ -// ZipConstants.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 22-12-2009 DavidPierson Added AES support - using System; using System.Text; using System.Threading; namespace ICSharpCode.SharpZipLib.Zip { - #region Enumerations /// @@ -482,14 +440,11 @@ public sealed class ZipConstants /// there are many variable factors, codepage 850 is often a good choice for /// European users, however be careful about compatability. /// - public static int DefaultCodePage - { - get - { + public static int DefaultCodePage { + get { return defaultCodePage; } - set - { + set { if ((value < 0) || (value > 65535) || (value == 1) || (value == 2) || (value == 3) || (value == 42)) { throw new ArgumentOutOfRangeException(nameof(value)); diff --git a/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs b/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs index feb86a39b..07645b589 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs @@ -1,53 +1,8 @@ -// ZipEntry.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2009-12-22 Z-1649 Added AES support -// 2010-02-02 DavidP Changed NTFS Extra Data min length to 4 -// 2012-06-03 Z-1744 Use only the low order byte of "Version Needed to Extract" -// 2012-07-18 Z-1676 Translate to forward slashes and remove drive from name in constructor - using System; using System.IO; namespace ICSharpCode.SharpZipLib.Zip { - /// /// Defines known values for the property. /// @@ -281,10 +236,8 @@ public ZipEntry(ZipEntry entry) /// /// Get a value indicating wether the entry has a CRC value available. /// - public bool HasCrc - { - get - { + public bool HasCrc { + get { return (known & Known.Crc) != 0; } } @@ -294,14 +247,11 @@ public bool HasCrc /// A simple helper routine to aid interpretation of flags /// /// This is an assistant that interprets the flags property. - public bool IsCrypted - { - get - { + public bool IsCrypted { + get { return (flags & 1) != 0; } - set - { + set { if (value) { flags |= 1; } else { @@ -315,14 +265,11 @@ public bool IsCrypted /// encoded in unicode UTF8. /// /// This is an assistant that interprets the flags property. - public bool IsUnicodeText - { - get - { + public bool IsUnicodeText { + get { return (flags & (int)GeneralBitFlags.UnicodeText) != 0; } - set - { + set { if (value) { flags |= (int)GeneralBitFlags.UnicodeText; } else { @@ -334,15 +281,12 @@ public bool IsUnicodeText /// /// Value used during password checking for PKZIP 2.0 / 'classic' encryption. /// - internal byte CryptoCheckValue - { - get - { + internal byte CryptoCheckValue { + get { return cryptoCheckValue_; } - set - { + set { cryptoCheckValue_ = value; } } @@ -378,14 +322,11 @@ internal byte CryptoCheckValue /// /// /// - public int Flags - { - get - { + public int Flags { + get { return flags; } - set - { + set { flags = value; } } @@ -394,14 +335,11 @@ public int Flags /// Get/Set index of this entry in Zip file /// /// This is only valid when the entry is part of a - public long ZipFileIndex - { - get - { + public long ZipFileIndex { + get { return zipFileIndex; } - set - { + set { zipFileIndex = value; } } @@ -409,14 +347,11 @@ public long ZipFileIndex /// /// Get/set offset for use in central header /// - public long Offset - { - get - { + public long Offset { + get { return offset; } - set - { + set { offset = value; } } @@ -426,10 +361,8 @@ public long Offset /// The values of this are operating system dependant see /// HostSystem for details /// - public int ExternalFileAttributes - { - get - { + public int ExternalFileAttributes { + get { if ((known & Known.ExternalAttributes) == 0) { return -1; } else { @@ -437,8 +370,7 @@ public int ExternalFileAttributes } } - set - { + set { externalFileAttributes = value; known |= Known.ExternalAttributes; } @@ -449,10 +381,8 @@ public int ExternalFileAttributes /// The value / 10 indicates the major version number, and /// the value mod 10 is the minor version number /// - public int VersionMadeBy - { - get - { + public int VersionMadeBy { + get { return (versionMadeBy & 0xff); } } @@ -460,10 +390,8 @@ public int VersionMadeBy /// /// Get a value indicating this entry is for a DOS/Windows system. /// - public bool IsDOSEntry - { - get - { + public bool IsDOSEntry { + get { return ((HostSystem == (int)HostSystemID.Msdos) || (HostSystem == (int)HostSystemID.WindowsNT)); } @@ -525,15 +453,12 @@ bool HasDosAttributes(int attributes) /// remainder - unused /// /// - public int HostSystem - { - get - { + public int HostSystem { + get { return (versionMadeBy >> 8) & 0xff; } - set - { + set { versionMadeBy &= 0xff; versionMadeBy |= (ushort)((value & 0xff) << 8); } @@ -569,10 +494,8 @@ public int HostSystem /// 6.3 - File is encrypted using Twofish
/// /// - public int Version - { - get - { + public int Version { + get { // Return recorded version if known. if (versionToExtract != 0) { return versionToExtract & 0x00ff; // Only lower order byte. High order is O/S file system. @@ -601,10 +524,8 @@ public int Version /// /// This is based on the and /// wether the compression method is supported. - public bool CanDecompress - { - get - { + public bool CanDecompress { + get { return (Version <= ZipConstants.VersionMadeBy) && ((Version == 10) || (Version == 11) || @@ -637,10 +558,8 @@ public bool IsZip64Forced() /// to store the full entry values. /// /// A value of true if a local header requires Zip64 extensions; false if not. - public bool LocalHeaderRequiresZip64 - { - get - { + public bool LocalHeaderRequiresZip64 { + get { bool result = forceZip64_; if (!result) { @@ -664,10 +583,8 @@ public bool LocalHeaderRequiresZip64 /// /// Get a value indicating wether the central directory entry requires Zip64 extensions to be stored. /// - public bool CentralHeaderRequiresZip64 - { - get - { + public bool CentralHeaderRequiresZip64 { + get { return LocalHeaderRequiresZip64 || (offset >= uint.MaxValue); } } @@ -678,10 +595,8 @@ public bool CentralHeaderRequiresZip64 /// /// The MS-DOS date format can only represent dates between 1/1/1980 and 12/31/2107. /// - public long DosTime - { - get - { + public long DosTime { + get { if ((known & Known.Time) == 0) { return 0; } else { @@ -689,8 +604,7 @@ public long DosTime } } - set - { + set { unchecked { dosTime = (uint)value; } @@ -709,8 +623,7 @@ public DateTime DateTime { get { return dateTime; } - set - { + set { var year = (uint)value.Year; var month = (uint)value.Month; var day = (uint)value.Day; @@ -752,10 +665,8 @@ public DateTime DateTime /// Dos device names like C: should also be removed. /// See the class, or /// - public string Name - { - get - { + public string Name { + get { return name; } } @@ -768,14 +679,11 @@ public string Name /// /// Setting the size before adding an entry to an archive can help /// avoid compatability problems with some archivers which dont understand Zip64 extensions. - public long Size - { - get - { + public long Size { + get { return (known & Known.Size) != 0 ? (long)size : -1L; } - set - { + set { this.size = (ulong)value; this.known |= Known.Size; } @@ -787,14 +695,11 @@ public long Size /// /// The compressed entry size or -1 if unknown. /// - public long CompressedSize - { - get - { + public long CompressedSize { + get { return (known & Known.CompressedSize) != 0 ? (long)compressedSize : -1L; } - set - { + set { this.compressedSize = (ulong)value; this.known |= Known.CompressedSize; } @@ -809,14 +714,11 @@ public long CompressedSize /// /// The crc value or -1 if unknown. /// - public long Crc - { - get - { + public long Crc { + get { return (known & Known.Crc) != 0 ? crc & 0xffffffffL : -1L; } - set - { + set { if (((ulong)crc & 0xffffffff00000000L) != 0) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -833,15 +735,12 @@ public long Crc /// /// /// - public CompressionMethod CompressionMethod - { - get - { + public CompressionMethod CompressionMethod { + get { return method; } - set - { + set { if (!IsCompressionMethodSupported(value)) { throw new NotSupportedException("Compression method not supported"); } @@ -854,10 +753,8 @@ public CompressionMethod CompressionMethod /// Returns same value as CompressionMethod except when AES encrypting, which /// places 99 in the method and places the real method in the extra data. /// - internal CompressionMethod CompressionMethodForHeader - { - get - { + internal CompressionMethod CompressionMethodForHeader { + get { return (AESKeySize > 0) ? CompressionMethod.WinZipAES : method; } } @@ -871,18 +768,15 @@ internal CompressionMethod CompressionMethodForHeader /// /// Extra data or null if not set. /// - public byte[] ExtraData - { + public byte[] ExtraData { - get - { + get { // TODO: This is slightly safer but less efficient. Think about wether it should change. // return (byte[]) extra.Clone(); return extra; } - set - { + set { if (value == null) { extra = null; } else { @@ -901,26 +795,35 @@ public byte[] ExtraData /// For AES encrypted files returns or sets the number of bits of encryption (128, 192 or 256). /// When setting, only 0 (off), 128 or 256 is supported. /// - public int AESKeySize - { - get - { + public int AESKeySize { + get { // the strength (1 or 3) is in the entry header switch (_aesEncryptionStrength) { - case 0: return 0; // Not AES - case 1: return 128; - case 2: return 192; // Not used by WinZip - case 3: return 256; - default: throw new ZipException("Invalid AESEncryptionStrength " + _aesEncryptionStrength); + case 0: + return 0; // Not AES + case 1: + return 128; + case 2: + return 192; // Not used by WinZip + case 3: + return 256; + default: + throw new ZipException("Invalid AESEncryptionStrength " + _aesEncryptionStrength); } } - set - { + set { switch (value) { - case 0: _aesEncryptionStrength = 0; break; - case 128: _aesEncryptionStrength = 1; break; - case 256: _aesEncryptionStrength = 3; break; - default: throw new ZipException("AESKeySize must be 0, 128 or 256: " + value); + case 0: + _aesEncryptionStrength = 0; + break; + case 128: + _aesEncryptionStrength = 1; + break; + case 256: + _aesEncryptionStrength = 3; + break; + default: + throw new ZipException("AESKeySize must be 0, 128 or 256: " + value); } } } @@ -929,10 +832,8 @@ public int AESKeySize /// AES Encryption strength for storage in extra data in entry header. /// 1 is 128 bit, 2 is 192 bit, 3 is 256 bit. /// - internal byte AESEncryptionStrength - { - get - { + internal byte AESEncryptionStrength { + get { return (byte)_aesEncryptionStrength; } } @@ -940,10 +841,8 @@ internal byte AESEncryptionStrength /// /// Returns the length of the salt, in bytes /// - internal int AESSaltLen - { - get - { + internal int AESSaltLen { + get { // Key size -> Salt length: 128 bits = 8 bytes, 192 bits = 12 bytes, 256 bits = 16 bytes. return AESKeySize / 16; } @@ -952,10 +851,8 @@ internal int AESSaltLen /// /// Number of extra bytes required to hold the AES Header fields (Salt, Pwd verify, AuthCode) /// - internal int AESOverheadSize - { - get - { + internal int AESOverheadSize { + get { // File format: // Bytes Content // Variable Salt value @@ -1107,14 +1004,11 @@ private void ProcessAESExtraData(ZipExtraData extraData) /// A comment is only available for entries when read via the class. /// The class doesnt have the comment data available. /// - public string Comment - { - get - { + public string Comment { + get { return comment; } - set - { + set { // This test is strictly incorrect as the length is in characters // while the storage limit is in bytes. // While the test is partially correct in that a comment of this length or greater @@ -1140,10 +1034,8 @@ public string Comment /// Currently only dos/windows attributes are tested in this manner. /// The trailing slash convention should always be followed. /// - public bool IsDirectory - { - get - { + public bool IsDirectory { + get { int nameLength = name.Length; bool result = ((nameLength > 0) && @@ -1161,10 +1053,8 @@ public bool IsDirectory /// This only takes account of DOS/Windows attributes. Other operating systems are ignored. /// For linux and others the result may be incorrect. /// - public bool IsFile - { - get - { + public bool IsFile { + get { return !IsDirectory && !HasDosAttributes(8); } } diff --git a/ICSharpCode.SharpZipLib/Zip/ZipEntryFactory.cs b/ICSharpCode.SharpZipLib/Zip/ZipEntryFactory.cs index 1344be7e1..4fdbff8c4 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipEntryFactory.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipEntryFactory.cs @@ -1,47 +1,5 @@ -// ZipEntryFactory.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2012-11-29 Z-1684 Added MakeFileEntry(string fileName, string entryName, bool useFileSystem) - using System; using System.IO; - using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip @@ -133,11 +91,9 @@ public ZipEntryFactory(DateTime time) /// /// Setting this property to null will cause a default name transform to be used. /// - public INameTransform NameTransform - { + public INameTransform NameTransform { get { return nameTransform_; } - set - { + set { if (value == null) { nameTransform_ = new ZipNameTransform(); } else { @@ -149,8 +105,7 @@ public INameTransform NameTransform /// /// Get / set the in use. /// - public TimeSetting Setting - { + public TimeSetting Setting { get { return timeSetting_; } set { timeSetting_ = value; } } @@ -158,11 +113,9 @@ public TimeSetting Setting /// /// Get / set the value to use when is set to /// - public DateTime FixedDateTime - { + public DateTime FixedDateTime { get { return fixedDateTime_; } - set - { + set { if (value.Year < 1970) { throw new ArgumentException("Value is too old to be valid", nameof(value)); } @@ -174,8 +127,7 @@ public DateTime FixedDateTime /// A bitmask defining the attributes to be retrieved from the actual file. /// /// The default is to get all possible attributes from the actual file. - public int GetAttributes - { + public int GetAttributes { get { return getAttributes_; } set { getAttributes_ = value; } } @@ -184,8 +136,7 @@ public int GetAttributes /// A bitmask defining which attributes are to be set on. /// /// By default no attributes are set on. - public int SetAttributes - { + public int SetAttributes { get { return setAttributes_; } set { setAttributes_ = value; } } @@ -193,8 +144,7 @@ public int SetAttributes /// /// Get set a value indicating wether unidoce text should be set on. /// - public bool IsUnicodeText - { + public bool IsUnicodeText { get { return isUnicodeText_; } set { isUnicodeText_ = value; } } @@ -246,36 +196,36 @@ public ZipEntry MakeFileEntry(string fileName, string entryName, bool useFileSys if ((fi != null) && fi.Exists) { switch (timeSetting_) { - case TimeSetting.CreateTime: - result.DateTime = fi.CreationTime; - break; + case TimeSetting.CreateTime: + result.DateTime = fi.CreationTime; + break; - case TimeSetting.CreateTimeUtc: - result.DateTime = fi.CreationTimeUtc; - break; + case TimeSetting.CreateTimeUtc: + result.DateTime = fi.CreationTimeUtc; + break; - case TimeSetting.LastAccessTime: - result.DateTime = fi.LastAccessTime; - break; + case TimeSetting.LastAccessTime: + result.DateTime = fi.LastAccessTime; + break; - case TimeSetting.LastAccessTimeUtc: - result.DateTime = fi.LastAccessTimeUtc; - break; + case TimeSetting.LastAccessTimeUtc: + result.DateTime = fi.LastAccessTimeUtc; + break; - case TimeSetting.LastWriteTime: - result.DateTime = fi.LastWriteTime; - break; + case TimeSetting.LastWriteTime: + result.DateTime = fi.LastWriteTime; + break; - case TimeSetting.LastWriteTimeUtc: - result.DateTime = fi.LastWriteTimeUtc; - break; + case TimeSetting.LastWriteTimeUtc: + result.DateTime = fi.LastWriteTimeUtc; + break; - case TimeSetting.Fixed: - result.DateTime = fixedDateTime_; - break; + case TimeSetting.Fixed: + result.DateTime = fixedDateTime_; + break; - default: - throw new ZipException("Unhandled time setting in MakeFileEntry"); + default: + throw new ZipException("Unhandled time setting in MakeFileEntry"); } result.Size = fi.Length; @@ -330,36 +280,36 @@ public ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem) if ((di != null) && di.Exists) { switch (timeSetting_) { - case TimeSetting.CreateTime: - result.DateTime = di.CreationTime; - break; + case TimeSetting.CreateTime: + result.DateTime = di.CreationTime; + break; - case TimeSetting.CreateTimeUtc: - result.DateTime = di.CreationTimeUtc; - break; + case TimeSetting.CreateTimeUtc: + result.DateTime = di.CreationTimeUtc; + break; - case TimeSetting.LastAccessTime: - result.DateTime = di.LastAccessTime; - break; + case TimeSetting.LastAccessTime: + result.DateTime = di.LastAccessTime; + break; - case TimeSetting.LastAccessTimeUtc: - result.DateTime = di.LastAccessTimeUtc; - break; + case TimeSetting.LastAccessTimeUtc: + result.DateTime = di.LastAccessTimeUtc; + break; - case TimeSetting.LastWriteTime: - result.DateTime = di.LastWriteTime; - break; + case TimeSetting.LastWriteTime: + result.DateTime = di.LastWriteTime; + break; - case TimeSetting.LastWriteTimeUtc: - result.DateTime = di.LastWriteTimeUtc; - break; + case TimeSetting.LastWriteTimeUtc: + result.DateTime = di.LastWriteTimeUtc; + break; - case TimeSetting.Fixed: - result.DateTime = fixedDateTime_; - break; + case TimeSetting.Fixed: + result.DateTime = fixedDateTime_; + break; - default: - throw new ZipException("Unhandled time setting in MakeDirectoryEntry"); + default: + throw new ZipException("Unhandled time setting in MakeDirectoryEntry"); } externalAttributes = ((int)di.Attributes & getAttributes_); diff --git a/ICSharpCode.SharpZipLib/Zip/ZipException.cs b/ICSharpCode.SharpZipLib/Zip/ZipException.cs index 215070147..ebd8f1739 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipException.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipException.cs @@ -1,47 +1,8 @@ -// ZipException.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.Runtime.Serialization; namespace ICSharpCode.SharpZipLib.Zip { - /// /// Represents exception conditions specific to Zip archive handling /// diff --git a/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs b/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs index 63cde0bdb..28deb5f1d 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs @@ -1,38 +1,3 @@ -// ZipExtraData.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; @@ -85,8 +50,7 @@ public RawTaggedData(short tag) /// /// Get the ID for this tagged data value. /// - public short TagID - { + public short TagID { get { return _tag; } set { _tag = value; } } @@ -122,8 +86,7 @@ public byte[] GetData() /// Get /set the binary data representing this instance. /// /// The raw binary data representing this instance. - public byte[] Data - { + public byte[] Data { get { return _data; } set { _data = value; } } @@ -170,8 +133,7 @@ public enum Flags : byte /// /// Get the ID /// - public short TagID - { + public short TagID { get { return 0x5455; } } @@ -270,11 +232,9 @@ public static bool IsValidValue(DateTime value) /// /// /// - public DateTime ModificationTime - { + public DateTime ModificationTime { get { return _modificationTime; } - set - { + set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -289,11 +249,9 @@ public DateTime ModificationTime /// /// /// - public DateTime AccessTime - { + public DateTime AccessTime { get { return _lastAccessTime; } - set - { + set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -308,11 +266,9 @@ public DateTime AccessTime /// /// /// - public DateTime CreateTime - { + public DateTime CreateTime { get { return _createTime; } - set - { + set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -347,8 +303,7 @@ public class NTTaggedData : ITaggedData /// /// Get the ID for this tagged data value. /// - public short TagID - { + public short TagID { get { return 10; } } @@ -430,11 +385,9 @@ public static bool IsValidValue(DateTime value) /// /// Get/set the last modification time. /// - public DateTime LastModificationTime - { + public DateTime LastModificationTime { get { return _lastModificationTime; } - set - { + set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -445,11 +398,9 @@ public DateTime LastModificationTime /// /// Get /set the create time /// - public DateTime CreateTime - { + public DateTime CreateTime { get { return _createTime; } - set - { + set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -460,11 +411,9 @@ public DateTime CreateTime /// /// Get /set the last access time. /// - public DateTime LastAccessTime - { + public DateTime LastAccessTime { get { return _lastAccessTime; } - set - { + set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException(nameof(value)); } @@ -557,8 +506,7 @@ public void Clear() /// /// Gets the current extra data length. /// - public int Length - { + public int Length { get { return _data.Length; } } @@ -597,8 +545,7 @@ public T GetData() /// Get the length of the last value found by /// /// This is only valid if has previously returned true. - public int ValueLength - { + public int ValueLength { get { return _readValueLength; } } @@ -608,18 +555,15 @@ public int ValueLength /// This is only valid if has previously returned true. /// Initially the result will be the index of the first byte of actual data. The value is updated after calls to /// , and . - public int CurrentReadIndex - { + public int CurrentReadIndex { get { return _index; } } /// /// Get the number of bytes remaining to be read for the current value; /// - public int UnreadCount - { - get - { + public int UnreadCount { + get { if ((_readValueStart > _data.Length) || (_readValueStart < 4)) { throw new ZipException("Find must be called before calling a Read method"); diff --git a/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index 03e626c99..6cf11d603 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -1,56 +1,10 @@ -// ZipFile.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2009-12-22 Z-1649 Added AES support -// 2010-03-02 Z-1650 Fixed updating ODT archives in memory. Exposed exceptions in updating. -// 2010-05-25 Z-1663 Fixed exception when testing local header compressed size of -1 -// 2012-11-29 Z-1684 Fixed ZipFile.Add(string fileName, string entryName) losing the file TimeStamp - using System; using System.Collections; using System.IO; using System.Text; using System.Globalization; - using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Encryption; - using ICSharpCode.SharpZipLib.Core; using ICSharpCode.SharpZipLib.Checksum; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; @@ -90,16 +44,14 @@ public KeysRequiredEventArgs(string name, byte[] keyValue) /// /// Gets the name of the file for which keys are required. /// - public string FileName - { + public string FileName { get { return fileName; } } /// /// Gets or sets the key value /// - public byte[] Key - { + public byte[] Key { get { return key; } set { key = value; } } @@ -187,48 +139,42 @@ public TestStatus(ZipFile file) /// /// Get the current in progress. /// - public TestOperation Operation - { + public TestOperation Operation { get { return operation_; } } /// /// Get the this status is applicable to. /// - public ZipFile File - { + public ZipFile File { get { return file_; } } /// /// Get the current/last entry tested. /// - public ZipEntry Entry - { + public ZipEntry Entry { get { return entry_; } } /// /// Get the number of errors detected so far. /// - public int ErrorCount - { + public int ErrorCount { get { return errorCount_; } } /// /// Get the number of bytes tested so far for the current entry. /// - public long BytesTested - { + public long BytesTested { get { return bytesTested_; } } /// /// Get a value indicating wether the last entry test was valid. /// - public bool EntryValid - { + public bool EntryValid { get { return entryValid_; } } #endregion @@ -370,8 +316,7 @@ void OnKeysRequired(string fileName) /// /// Get/set the encryption key value. /// - byte[] Key - { + byte[] Key { get { return key; } set { key = value; } } @@ -380,10 +325,8 @@ byte[] Key /// Password to be used for encrypting/decrypting files. /// /// Set to null if no password is required. - public string Password - { - set - { + public string Password { + set { if (string.IsNullOrEmpty(value)) { key = null; } else { @@ -396,8 +339,7 @@ public string Password /// /// Get a value indicating wether encryption keys are currently available. /// - bool HaveKeys - { + bool HaveKeys { get { return key != null; } } #endregion @@ -601,8 +543,7 @@ public static ZipFile Create(Stream outStream) /// /// The default value is true in all cases. /// - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } @@ -611,8 +552,7 @@ public bool IsStreamOwner /// Get a value indicating wether /// this archive is embedded in another file or not. /// - public bool IsEmbeddedArchive - { + public bool IsEmbeddedArchive { // Not strictly correct in all circumstances currently get { return offsetOfFirstEntry > 0; } } @@ -620,24 +560,21 @@ public bool IsEmbeddedArchive /// /// Get a value indicating that this archive is a new one. /// - public bool IsNewArchive - { + public bool IsNewArchive { get { return isNewArchive_; } } /// /// Gets the comment for the zip file. /// - public string ZipFileComment - { + public string ZipFileComment { get { return comment_; } } /// /// Gets the name of this zip file. /// - public string Name - { + public string Name { get { return name_; } } @@ -648,10 +585,8 @@ public string Name /// The Zip file has been closed. /// [Obsolete("Use the Count property instead")] - public int Size - { - get - { + public int Size { + get { return entries_.Length; } } @@ -659,10 +594,8 @@ public int Size /// /// Get the number of entries contained in this . /// - public long Count - { - get - { + public long Count { + get { return entries_.Length; } } @@ -671,10 +604,8 @@ public long Count /// Indexer property for ZipEntries /// [System.Runtime.CompilerServices.IndexerNameAttribute("EntryByIndex")] - public ZipEntry this[int index] - { - get - { + public ZipEntry this[int index] { + get { return (ZipEntry)entries_[index].Clone(); } } @@ -814,17 +745,17 @@ public Stream GetInputStream(long entryIndex) } switch (method) { - case CompressionMethod.Stored: - // read as is. - break; + case CompressionMethod.Stored: + // read as is. + break; - case CompressionMethod.Deflated: - // No need to worry about ownership and closing as underlying stream close does nothing. - result = new InflaterInputStream(result, new Inflater(true)); - break; + case CompressionMethod.Deflated: + // No need to worry about ownership and closing as underlying stream close does nothing. + result = new InflaterInputStream(result, new Inflater(true)); + break; - default: - throw new ZipException("Unsupported compression method " + method); + default: + throw new ZipException("Unsupported compression method " + method); } return result; @@ -1236,15 +1167,12 @@ enum UpdateCommand /// /// Get / set the to apply to names when updating. /// - public INameTransform NameTransform - { - get - { + public INameTransform NameTransform { + get { return updateEntryFactory_.NameTransform; } - set - { + set { updateEntryFactory_.NameTransform = value; } } @@ -1253,15 +1181,12 @@ public INameTransform NameTransform /// Get/set the used to generate values /// during updates. /// - public IEntryFactory EntryFactory - { - get - { + public IEntryFactory EntryFactory { + get { return updateEntryFactory_; } - set - { + set { if (value == null) { updateEntryFactory_ = new ZipEntryFactory(); } else { @@ -1273,11 +1198,9 @@ public IEntryFactory EntryFactory /// /// Get /set the buffer size to be used when updating this zip file. /// - public int BufferSize - { + public int BufferSize { get { return bufferSize_; } - set - { + set { if (value < 1024) { throw new ArgumentOutOfRangeException(nameof(value), "cannot be below 1024"); } @@ -1292,16 +1215,14 @@ public int BufferSize /// /// Get a value indicating an update has been started. /// - public bool IsUpdating - { + public bool IsUpdating { get { return updates_ != null; } } /// /// Get / set a value indicating how Zip64 Extension usage is determined when adding entries. /// - public UseZip64 UseZip64 - { + public UseZip64 UseZip64 { get { return useZip64_; } set { useZip64_ = value; } } @@ -1853,19 +1774,19 @@ void WriteLocalEntryHeader(ZipUpdate update) } switch (useZip64_) { - case UseZip64.Dynamic: - if (entry.Size < 0) { - entry.ForceZip64(); - } - break; + case UseZip64.Dynamic: + if (entry.Size < 0) { + entry.ForceZip64(); + } + break; - case UseZip64.On: - entry.ForceZip64(); - break; + case UseZip64.On: + entry.ForceZip64(); + break; - case UseZip64.Off: - // Do nothing. The entry itself may be using Zip64 independantly. - break; + case UseZip64.Off: + // Do nothing. The entry itself may be using Zip64 independantly. + break; } } @@ -2310,18 +2231,18 @@ Stream GetOutputStream(ZipEntry entry) } switch (entry.CompressionMethod) { - case CompressionMethod.Stored: - result = new UncompressedStream(result); - break; + case CompressionMethod.Stored: + result = new UncompressedStream(result); + break; - case CompressionMethod.Deflated: - var dos = new DeflaterOutputStream(result, new Deflater(9, true)); - dos.IsStreamOwner = false; - result = dos; - break; + case CompressionMethod.Deflated: + var dos = new DeflaterOutputStream(result, new Deflater(9, true)); + dos.IsStreamOwner = false; + result = dos; + break; - default: - throw new ZipException("Unknown compression method " + entry.CompressionMethod); + default: + throw new ZipException("Unknown compression method " + entry.CompressionMethod); } return result; } @@ -2616,30 +2537,30 @@ void RunUpdates() foreach (ZipUpdate update in updates_) { if (update != null) { switch (update.Command) { - case UpdateCommand.Copy: - if (directUpdate) { - CopyEntryDirect(workFile, update, ref destinationPosition); - } else { - CopyEntry(workFile, update); - } - break; + case UpdateCommand.Copy: + if (directUpdate) { + CopyEntryDirect(workFile, update, ref destinationPosition); + } else { + CopyEntry(workFile, update); + } + break; - case UpdateCommand.Modify: - // TODO: Direct modifying of an entry will take some legwork. - ModifyEntry(workFile, update); - break; + case UpdateCommand.Modify: + // TODO: Direct modifying of an entry will take some legwork. + ModifyEntry(workFile, update); + break; - case UpdateCommand.Add: - if (!IsNewArchive && directUpdate) { - workFile.baseStream_.Position = destinationPosition; - } + case UpdateCommand.Add: + if (!IsNewArchive && directUpdate) { + workFile.baseStream_.Position = destinationPosition; + } - AddEntry(workFile, update); + AddEntry(workFile, update); - if (directUpdate) { - destinationPosition = workFile.baseStream_.Position; - } - break; + if (directUpdate) { + destinationPosition = workFile.baseStream_.Position; + } + break; } } } @@ -2791,18 +2712,15 @@ public ZipUpdate(ZipEntry entry) /// Get the for this update. /// /// This is the source or original entry. - public ZipEntry Entry - { + public ZipEntry Entry { get { return entry_; } } /// /// Get the that will be written to the updated/new file. /// - public ZipEntry OutEntry - { - get - { + public ZipEntry OutEntry { + get { if (outEntry_ == null) { outEntry_ = (ZipEntry)entry_.Clone(); } @@ -2814,24 +2732,21 @@ public ZipEntry OutEntry /// /// Get the command for this update. /// - public UpdateCommand Command - { + public UpdateCommand Command { get { return command_; } } /// /// Get the filename if any for this update. Null if none exists. /// - public string Filename - { + public string Filename { get { return filename_; } } /// /// Get/set the location of the size patch for this update. /// - public long SizePatchOffset - { + public long SizePatchOffset { get { return sizePatchOffset_; } set { sizePatchOffset_ = value; } } @@ -2839,8 +2754,7 @@ public long SizePatchOffset /// /// Get /set the location of the crc patch for this update. /// - public long CrcPatchOffset - { + public long CrcPatchOffset { get { return crcPatchOffset_; } set { crcPatchOffset_ = value; } } @@ -2849,8 +2763,7 @@ public long CrcPatchOffset /// Get/set the size calculated by offset. /// Specifically, the difference between this and next entry's starting offset. /// - public long OffsetBasedSize - { + public long OffsetBasedSize { get { return _offsetBasedSize; } set { _offsetBasedSize = value; } } @@ -3317,18 +3230,15 @@ public ZipString(byte[] rawString) /// Get a value indicating the original source of data for this instance. /// True if the source was a string; false if the source was binary data. /// - public bool IsSourceString - { + public bool IsSourceString { get { return isSourceString_; } } /// /// Get the length of the comment when represented as raw bytes. /// - public int RawLength - { - get - { + public int RawLength { + get { MakeBytesAvailable(); return rawComment_.Length; } @@ -3337,10 +3247,8 @@ public int RawLength /// /// Get the comment in its 'raw' form as plain bytes. /// - public byte[] RawComment - { - get - { + public byte[] RawComment { + get { MakeBytesAvailable(); return (byte[])rawComment_.Clone(); } @@ -3403,10 +3311,8 @@ public ZipEntryEnumerator(ZipEntry[] entries) #endregion #region IEnumerator Members - public object Current - { - get - { + public object Current { + get { return array[index]; } } @@ -3452,10 +3358,8 @@ public override void Close() /// /// Gets a value indicating whether the current stream supports reading. /// - public override bool CanRead - { - get - { + public override bool CanRead { + get { return false; } } @@ -3471,10 +3375,8 @@ public override void Flush() /// /// Gets a value indicating whether the current stream supports writing. /// - public override bool CanWrite - { - get - { + public override bool CanWrite { + get { return baseStream_.CanWrite; } } @@ -3482,10 +3384,8 @@ public override bool CanWrite /// /// Gets a value indicating whether the current stream supports seeking. /// - public override bool CanSeek - { - get - { + public override bool CanSeek { + get { return false; } } @@ -3493,10 +3393,8 @@ public override bool CanSeek /// /// Get the length in bytes of the stream. /// - public override long Length - { - get - { + public override long Length { + get { return 0; } } @@ -3504,14 +3402,11 @@ public override long Length /// /// Gets or sets the position within the current stream. /// - public override long Position - { - get - { + public override long Position { + get { return baseStream_.Position; } - set - { + set { throw new NotImplementedException(); } } @@ -3732,17 +3627,17 @@ public override long Seek(long offset, SeekOrigin origin) long newPos = readPos_; switch (origin) { - case SeekOrigin.Begin: - newPos = start_ + offset; - break; + case SeekOrigin.Begin: + newPos = start_ + offset; + break; - case SeekOrigin.Current: - newPos = readPos_ + offset; - break; + case SeekOrigin.Current: + newPos = readPos_ + offset; + break; - case SeekOrigin.End: - newPos = end_ + offset; - break; + case SeekOrigin.End: + newPos = end_ + offset; + break; } if (newPos < start_) { @@ -3773,11 +3668,9 @@ public override void Flush() /// An I/O error occurs. /// The stream does not support seeking. /// Methods were called after the stream was closed. - public override long Position - { + public override long Position { get { return readPos_ - start_; } - set - { + set { long newPos = start_ + value; if (newPos < start_) { @@ -3798,8 +3691,7 @@ public override long Position /// A long value representing the length of the stream in bytes. /// A class derived from Stream does not support seeking. /// Methods were called after the stream was closed. - public override long Length - { + public override long Length { get { return length_; } } @@ -3808,8 +3700,7 @@ public override long Length /// /// false /// true if the stream supports writing; otherwise, false. - public override bool CanWrite - { + public override bool CanWrite { get { return false; } } @@ -3818,8 +3709,7 @@ public override bool CanWrite /// /// true /// true if the stream supports seeking; otherwise, false. - public override bool CanSeek - { + public override bool CanSeek { get { return true; } } @@ -3828,8 +3718,7 @@ public override bool CanSeek /// /// true. /// true if the stream supports reading; otherwise, false. - public override bool CanRead - { + public override bool CanRead { get { return true; } } @@ -3838,8 +3727,7 @@ public override bool CanRead /// /// /// A value that determines whether the current stream can time out. - public override bool CanTimeout - { + public override bool CanTimeout { get { return baseStream_.CanTimeout; } } #region Instance Fields @@ -4051,10 +3939,8 @@ protected BaseArchiveStorage(FileUpdateMode updateMode) /// Gets the update mode applicable. /// /// The update mode. - public FileUpdateMode UpdateMode - { - get - { + public FileUpdateMode UpdateMode { + get { return updateMode_; } } @@ -4282,8 +4168,7 @@ public MemoryArchiveStorage(FileUpdateMode updateMode) /// /// Get the stream returned by if this was in fact called. /// - public MemoryStream FinalStream - { + public MemoryStream FinalStream { get { return finalStream_; } } diff --git a/ICSharpCode.SharpZipLib/Zip/ZipHelperStream.cs b/ICSharpCode.SharpZipLib/Zip/ZipHelperStream.cs index 45159c027..53a518309 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipHelperStream.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipHelperStream.cs @@ -1,45 +1,9 @@ -// ZipHelperStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - using System; using System.IO; using System.Text; namespace ICSharpCode.SharpZipLib.Zip { - /// /// Holds data pertinent to a data descriptor. /// @@ -48,8 +12,7 @@ public class DescriptorData /// /// Get /set the compressed size of data. /// - public long CompressedSize - { + public long CompressedSize { get { return compressedSize; } set { compressedSize = value; } } @@ -57,8 +20,7 @@ public long CompressedSize /// /// Get / set the uncompressed size of data /// - public long Size - { + public long Size { get { return size; } set { size = value; } } @@ -66,8 +28,7 @@ public long Size /// /// Get /set the crc value. /// - public long Crc - { + public long Crc { get { return crc; } set { crc = (value & 0xffffffff); } } @@ -81,14 +42,12 @@ public long Crc class EntryPatchData { - public long SizePatchOffset - { + public long SizePatchOffset { get { return sizePatchOffset_; } set { sizePatchOffset_ = value; } } - public long CrcPatchOffset - { + public long CrcPatchOffset { get { return crcPatchOffset_; } set { crcPatchOffset_ = value; } } @@ -129,41 +88,34 @@ public ZipHelperStream(Stream stream) /// Get / set a value indicating wether the the underlying stream is owned or not. /// /// If the stream is owned it is closed when this instance is closed. - public bool IsStreamOwner - { + public bool IsStreamOwner { get { return isOwner_; } set { isOwner_ = value; } } #region Base Stream Methods - public override bool CanRead - { + public override bool CanRead { get { return stream_.CanRead; } } - public override bool CanSeek - { + public override bool CanSeek { get { return stream_.CanSeek; } } - public override bool CanTimeout - { + public override bool CanTimeout { get { return stream_.CanTimeout; } } - public override long Length - { + public override long Length { get { return stream_.Length; } } - public override long Position - { + public override long Position { get { return stream_.Position; } set { stream_.Position = value; } } - public override bool CanWrite - { + public override bool CanWrite { get { return stream_.CanWrite; } } diff --git a/ICSharpCode.SharpZipLib/Zip/ZipInputStream.cs b/ICSharpCode.SharpZipLib/Zip/ZipInputStream.cs index 24541b229..d097824a9 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipInputStream.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipInputStream.cs @@ -1,44 +1,3 @@ -// ZipInputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2010-05-25 Z-1663 Fixed exception when testing local header compressed size of -1 - using System; using System.IO; using ICSharpCode.SharpZipLib.Checksum; @@ -146,14 +105,11 @@ public ZipInputStream(Stream baseInputStream, int bufferSize) /// Optional password used for encryption when non-null /// /// A password for all encrypted entries in this - public string Password - { - get - { + public string Password { + get { return password; } - set - { + set { password = value; } } @@ -166,10 +122,8 @@ public string Password /// The entry can only be decompressed if the library supports the zip features required to extract it. /// See the ZipEntry Version property for more details. /// - public bool CanDecompressEntry - { - get - { + public bool CanDecompressEntry { + get { return (entry != null) && entry.CanDecompress; } } @@ -412,10 +366,8 @@ public void CloseEntry() /// Returns 1 if there is an entry available /// Otherwise returns 0. /// - public override int Available - { - get - { + public override int Available { + get { return entry != null ? 1 : 0; } } @@ -425,10 +377,8 @@ public override int Available /// /// Thrown if the entry size is not known. /// Thrown if no entry is currently available. - public override long Length - { - get - { + public override long Length { + get { if (entry != null) { if (entry.Size >= 0) { return entry.Size; @@ -593,45 +543,45 @@ int BodyRead(byte[] buffer, int offset, int count) bool finished = false; switch (method) { - case (int)CompressionMethod.Deflated: - count = base.Read(buffer, offset, count); - if (count <= 0) { - if (!inf.IsFinished) { - throw new ZipException("Inflater not finished!"); + case (int)CompressionMethod.Deflated: + count = base.Read(buffer, offset, count); + if (count <= 0) { + if (!inf.IsFinished) { + throw new ZipException("Inflater not finished!"); + } + inputBuffer.Available = inf.RemainingInput; + + // A csize of -1 is from an unpatched local header + if ((flags & 8) == 0 && + (inf.TotalIn != csize && csize != 0xFFFFFFFF && csize != -1 || inf.TotalOut != size)) { + throw new ZipException("Size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut); + } + inf.Reset(); + finished = true; } - inputBuffer.Available = inf.RemainingInput; + break; - // A csize of -1 is from an unpatched local header - if ((flags & 8) == 0 && - (inf.TotalIn != csize && csize != 0xFFFFFFFF && csize != -1 || inf.TotalOut != size)) { - throw new ZipException("Size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut); + case (int)CompressionMethod.Stored: + if ((count > csize) && (csize >= 0)) { + count = (int)csize; } - inf.Reset(); - finished = true; - } - break; - case (int)CompressionMethod.Stored: - if ((count > csize) && (csize >= 0)) { - count = (int)csize; - } - - if (count > 0) { - count = inputBuffer.ReadClearTextBuffer(buffer, offset, count); if (count > 0) { - csize -= count; - size -= count; + count = inputBuffer.ReadClearTextBuffer(buffer, offset, count); + if (count > 0) { + csize -= count; + size -= count; + } } - } - if (csize == 0) { - finished = true; - } else { - if (count < 0) { - throw new ZipException("EOF in stored block"); + if (csize == 0) { + finished = true; + } else { + if (count < 0) { + throw new ZipException("EOF in stored block"); + } } - } - break; + break; } if (count > 0) { diff --git a/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs b/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs index 4d62eb945..e2315a298 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs @@ -1,43 +1,6 @@ -// ZipNameTransform.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - - using System; using System.IO; using System.Text; - using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip @@ -153,11 +116,9 @@ public string TransformFile(string name) /// /// The prefix is trimmed before any conversion from /// a windows path is done. - public string TrimPrefix - { + public string TrimPrefix { get { return trimPrefix_; } - set - { + set { trimPrefix_ = value; if (trimPrefix_ != null) { trimPrefix_ = trimPrefix_.ToLower(); diff --git a/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs b/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs index 96570ee71..a370c13ec 100644 --- a/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs +++ b/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs @@ -1,50 +1,6 @@ -// ZipOutputStream.cs -// -// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 22-12-2009 Z-1649 Added AES support -// 22-02-2010 Z-1648 Zero byte entries would create invalid zip files -// 27-07-2012 Z-1724 Compressed size was incorrect in local header when CRC and Size are known - using System; using System.IO; using System.Collections; - using ICSharpCode.SharpZipLib.Checksum; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; @@ -123,10 +79,8 @@ public ZipOutputStream(Stream baseOutputStream, int bufferSize) /// Gets a flag value of true if the central header has been added for this archive; false if it has not been added. /// /// No further entries can be added once this has been done. - public bool IsFinished - { - get - { + public bool IsFinished { + get { return entries == null; } } @@ -181,8 +135,7 @@ public int GetLevel() /// If backwards compatability is an issue be careful when adding entries to an archive. /// Setting this property to off is workable but less desirable as in those circumstances adding a file /// larger then 4GB will fail. - public UseZip64 UseZip64 - { + public UseZip64 UseZip64 { get { return useZip64_; } set { useZip64_ = value; } } @@ -636,17 +589,17 @@ public override void Write(byte[] buffer, int offset, int count) size += count; switch (curMethod) { - case CompressionMethod.Deflated: - base.Write(buffer, offset, count); - break; + case CompressionMethod.Deflated: + base.Write(buffer, offset, count); + break; - case CompressionMethod.Stored: - if (Password != null) { - CopyAndEncrypt(buffer, offset, count); - } else { - baseOutputStream_.Write(buffer, offset, count); - } - break; + case CompressionMethod.Stored: + if (Password != null) { + CopyAndEncrypt(buffer, offset, count); + } else { + baseOutputStream_.Write(buffer, offset, count); + } + break; } } diff --git a/ICSharpCode.SharpZipLib/ZipArchiveMode.cs b/ICSharpCode.SharpZipLib/ZipArchiveMode.cs deleted file mode 100644 index eb6fc5a55..000000000 --- a/ICSharpCode.SharpZipLib/ZipArchiveMode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace ICSharpCode.SharpZipLib -{ - public enum ZipArchiveMode - { - /// - /// Only reading entries from the archive is permitted. - /// If the underlying file or stream is seekable, then files will be read from the archive on-demand as they are requested. - /// If the underlying file or stream is not seekable, the entire archive will be held in memory. - /// Requires that the underlying file or stream is readable. - /// - Read, - /// - /// Only supports the creation of new archives. - /// Only writing to newly created entries in the archive is permitted. - /// Each entry in the archive can only be opened for writing once. - /// If only one entry is written to at a time, data will be written to the underlying stream or file as soon as it is available. - /// The underlying stream must be writable, but need not be seekable. - /// - Create, - /// - /// Reading and writing from entries in the archive is permitted. - /// Requires that the contents of the entire archive be held in memory. - /// The underlying file or stream must be readable, writable and seekable. - /// No data will be written to the underlying file or stream until the archive is disposed. - /// - Update - } -} diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..396840e00 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,17 @@ +Copyright © 2000-2016 SharpZipLib Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 1ad55a722..fb5a54740 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Stories in Ready](https://badge.waffle.io/McNeight/SharpZipLib.png?label=ready&title=Ready)](https://waffle.io/McNeight/SharpZipLib) # SharpZipLib [![Join the chat at https://gitter.im/icsharpcode/SharpZipLib](https://badges.gitter.im/icsharpcode/SharpZipLib.svg)](https://gitter.im/icsharpcode/SharpZipLib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -54,11 +55,9 @@ The [SharpZipLib homepage](http://icsharpcode.github.io/SharpZipLib/) has precom License ------- -This software is released under the [GNU General Public License, version 2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) with an exception which allows linking with non GPL programs. The exception to the GPL is as follows: +This software is now released under the [MIT License](https://opensource.org/licenses/MIT) ->Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. - ->As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. +Previous versions were released under the [GNU General Public License, version 2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) with an [exception](http://www.gnu.org/software/classpath/license.html) which allowed linking with non-GPL programs. Namespace layout ---------------- @@ -80,18 +79,4 @@ Credits SharpZipLib was initially developed by [Mike Krüger](http://www.icsharpcode.net/pub/relations/krueger.aspx). Past maintainers are John Reilly and David Pierson. The current maintainer is Neil McNeight. -Much existing Java code helped to speed the creation of this library. Therefore credits fly out to other people. - -Zip/GZip implementation: - -A Java version of the zlib which was originally created by the [Free Software Foundation (FSF)](http://www.fsf.org). So all credits should go to the FSF and the authors who have worked on this piece of code. - -Without the zlib authors the Java zlib wouldn't be possible: -[Jean-loup Gailly](http://gailly.net/), [Mark Adler](http://en.wikipedia.org/wiki/Mark_Adler), and contributors of zlib. - -[Julian R Seward](julian@bzip.org) for the bzip2 implementation, and the Java port by [Keiron Liddle](keiron@aftexsw.com) of Aftex Software. - -Credits for the tar implementation fly out to : -[Timothy Gerard Endres](time@gjt.org) - -Special thanks to [Christoph Wille](http://www.icsharpcode.net/pub/relations/wille.aspx) for beta testing, suggestions, the setup of the web site, and for his tireless efforts at cat herding. +And thanks to all the people that contributed features, bug fixes and issue reports. diff --git a/appveyor.yml b/appveyor.yml index 13aa8742a..97a4ce3ea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ #---------------------------------# # version format -version: 0.87.{build} +version: 1.0.{build} # you can use {branch} name in version format too # version: 1.0.{build}-{branch}