Compare commits

...

283 Commits

Author SHA1 Message Date
Adam Hathcock
a67d7bc429 Mark for 0.15 2017-01-24 17:25:19 +00:00
Adam Hathcock
079a818c6c Merge pull request #205 from markryd/zip64-extraction
Add zip64 support for ZipArchive extraction
2017-01-24 16:56:42 +00:00
Mark Rydstrom
6be6ef0b5c Add zip64 support for ZipArchive extraction 2017-01-24 13:04:03 +10:00
Adam Hathcock
8e51d9d646 0.14.1 2016-11-30 14:26:18 +00:00
Adam Hathcock
ea206f4f02 Merge pull request #199 from adamhathcock/Issue-198
Gzip entry can't be read multiple times
2016-11-25 09:33:56 +00:00
Adam Hathcock
f175a2a252 Merge branch 'master' into Issue-198 2016-11-25 09:21:44 +00:00
Adam Hathcock
3f7e559b86 Merge pull request #200 from ITnent/bug/Issue-197
Open branch, to fix multiple crashes on repeated zip archives reading…
2016-11-25 09:21:34 +00:00
Vladimir Demidov
2959b4d701 Modified check integrity condition for the encrypted file. 2016-11-24 20:41:08 +03:00
Vladimir Demidov
031286c5eb Fixed defects after review. 2016-11-24 18:01:49 +03:00
Vladimir Demidov
e181fa8c4a Restored original tabs. 2016-11-24 17:11:43 +03:00
Vladimir Demidov
7b035bec5d Fixed some issues after review. 2016-11-24 16:21:02 +03:00
Vladimir Demidov
f39d2bf53a Open branch, to fix multiple crashes on repeated zip archives reading. Added fix. 2016-11-24 15:14:29 +03:00
Adam Hathcock
7c8e407182 Merge branch 'master' into Issue-198 2016-11-21 12:21:29 +00:00
Adam Hathcock
a09136d46b Merge pull request #195 from jskeet/strong-naming
Strong-name both the main and test projects
2016-11-21 12:06:13 +00:00
Adam Hathcock
5fe1363ee1 Gzip entry can't be read multiple times https://github.com/adamhathcock/sharpcompress/issues/198 2016-11-21 12:04:35 +00:00
Jon Skeet
b41823fc10 Strong-name both the main and test projects
It's not clear whether SharpCompress.Test.Portable (as referenced
in AssemblyInfo.cs) still exists, but build.ps1 certainly works.
2016-11-15 18:42:56 +00:00
Adam Hathcock
0a64fe28b0 Oops, removed too much from project.json 2016-10-14 09:03:15 +01:00
Adam Hathcock
e320ccfa9a 0.14.0 2016-10-14 08:59:19 +01:00
Adam Hathcock
9628ff9456 Merge pull request #191 from jskeet/lzip
Initial read-only support for LZip
2016-10-14 08:50:32 +01:00
Jon Skeet
d540f78cfc Initial read-only support for LZip
LZip has no notion of flienames, so an LzipReader wouldn't make very much sense;
I've just implemented the stream, and hooked it into tar support.
2016-10-12 15:08:56 +01:00
Adam Hathcock
66420cd299 Merge pull request #189 from ziaa/master
Remove unbalanced parentheses in code samples
2016-10-08 18:25:30 +01:00
Seyed Zia Azimi
dd0594471f Remove unbalanced parentheses in samples 2016-10-07 19:33:41 +03:30
Adam Hathcock
844ba228ee Make 0.13.1 2016-10-03 13:44:19 +01:00
Adam Hathcock
7efc701b32 Merge pull request #188 from adamhathcock/fix_nulls
Fix null password on ReaderFactory.  Fix null options on SevenZipArchive
2016-10-03 13:41:55 +01:00
Adam Hathcock
d7e29f7c4d Fix occasionally failing test 2016-10-03 13:37:04 +01:00
Adam Hathcock
f26ba91386 Fix null password on ReaderFactory. Fix null options on SevenZipArchive 2016-10-03 13:32:53 +01:00
Adam Hathcock
c73ac2039c Merge pull request #185 from adamhathcock/ppmd_allocation_zipwriter
Make PpmdProperties lazy to avoid unnecessary allocations.
2016-10-03 13:04:14 +01:00
Adam Hathcock
671f9cd0cb Empty commit to kick build 2016-10-03 12:58:23 +01:00
Adam Hathcock
131b5b9714 Can't use Lazy on .NET 3.5 :( 2016-10-03 11:20:29 +01:00
Adam Hathcock
74af0889b9 Make PpmdProperties lazy to avoid unnecessary allocations. 2016-10-03 10:16:26 +01:00
Adam Hathcock
e5ee399045 Merge pull request #181 from claunia/patch-1
Update FORMATS.md
2016-09-30 07:08:52 +01:00
deeb7a0f64 Update FORMATS.md
Add ADC to formats list.
2016-09-29 22:53:51 +01:00
Adam Hathcock
5af3bab1dc Merge pull request #180 from adamhathcock/documenting
Add Markdown files to document things.
2016-09-29 11:58:19 +01:00
Adam Hathcock
28be84d315 For all branches 2016-09-29 11:35:54 +01:00
Adam Hathcock
a0528c737d Trying just to build once 2016-09-29 11:34:50 +01:00
Adam Hathcock
b506e488e8 Add build badge 2016-09-29 11:32:31 +01:00
Adam Hathcock
58eb0e08d6 Don't save artifacts for PRs 2016-09-29 11:22:26 +01:00
Adam Hathcock
562701894f Save nupkgs 2016-09-29 11:13:05 +01:00
Adam Hathcock
54a562273b Incomplete refactoring 2016-09-29 11:10:11 +01:00
Adam Hathcock
3f8c9c4cb0 Update for 0.13.0 2016-09-29 11:03:11 +01:00
Adam Hathcock
3e7d28b043 Can I fix tables? 2016-09-29 10:57:49 +01:00
Adam Hathcock
40b10d4a26 Add Markdown files to document things. 2016-09-29 10:55:04 +01:00
Adam Hathcock
f367630a2a Merge pull request #179 from adamhathcock/tar_fix
Allow empty tar header to be read to know there are no more tar heade…
2016-09-28 13:57:09 +01:00
Adam Hathcock
b9e4f00862 Merge branch 'master' into tar_fix 2016-09-28 13:50:45 +01:00
Adam Hathcock
d6e74d6163 Merge pull request #178 from adamhathcock/7zip_deflate
Allow deflate decoder for 7zip
2016-09-28 13:50:35 +01:00
Adam Hathcock
4a4522b842 Merge branch 'master' into 7zip_deflate 2016-09-28 13:44:46 +01:00
Adam Hathcock
710ba4423d Merge branch 'master' into tar_fix 2016-09-28 13:43:21 +01:00
Adam Hathcock
2a5494a804 Merge pull request #174 from adamhathcock/redo_options
Redo options
2016-09-28 13:40:54 +01:00
Adam Hathcock
568909800c Allow empty tar header to be read to know there are no more tar headers to read 2016-09-28 12:00:48 +01:00
Adam Hathcock
7513a608b1 Allow deflate decoder 2016-09-28 11:59:31 +01:00
Adam Hathcock
911e9878bd Merge branch 'master' into redo_options 2016-09-27 13:09:07 +01:00
Adam Hathcock
899d7d6e61 Appveyor (#175)
* First pass of Cake build

* Update Cake but still need cake itself to run on full CLR

* Test out appveyor

* 3.5 build fix

* Build master and PRs differently.  Still scared to auto publish to nuget.
2016-09-27 13:08:42 +01:00
Adam Hathcock
260c0ee776 Add SaveTo overload for zip archives 2016-09-27 11:19:52 +01:00
Adam Hathcock
d71520808d Helps if I rename everything 2016-09-27 11:08:54 +01:00
Adam Hathcock
177fc2a12c Flags were a better idea when I was younger. It's not clear though. 2016-09-27 10:50:36 +01:00
Adam Hathcock
5dafcb02d4 Redo options classes 2016-09-27 10:23:35 +01:00
Adam Hathcock
c4fde80c5e Create proper options objects to remove flags from API 2016-09-27 10:14:08 +01:00
Adam Hathcock
06e3486ec4 Bump version 2016-09-26 11:53:35 +01:00
Adam Hathcock
bd7c783aaf Test fixes 2016-09-26 11:51:35 +01:00
Adam Hathcock
d732e3cfa4 Renamespace for proper pluralization 2016-09-26 11:49:49 +01:00
Adam Hathcock
c24cdc66ed Clean up from clean up 2016-09-26 11:03:15 +01:00
Adam Hathcock
efa6f7a82e Huge Resharper clean up. Fixed up test project.json 2016-09-26 10:55:52 +01:00
ddbbc3b847 Adds support for Apple Data Compression. (#168) 2016-09-12 17:41:31 +01:00
Adam Hathcock
7037161c07 Update README 2016-08-12 12:15:45 +01:00
Adam Hathcock
b0b62fcf91 Try to fix frameworks again by matching JSON.NET 2016-08-12 12:14:22 +01:00
Adam Hathcock
bd8ba7b854 Test with ForwardOnlyStream. RewindableStream shouldn't corrupt a ForwardOnlyStream (#161) 2016-08-12 11:56:49 +01:00
Adam Hathcock
3a52c68270 0.12.3 2016-07-22 16:50:33 +01:00
Adam Hathcock
89fd778bd8 Make all framework assemblies be build targets as a fix https://github.com/NuGet/Home/issues/3103 2016-07-22 16:47:59 +01:00
Tobias Käs
6e3e8343a8 Ignore unofficial extension of file attributes. (#153)
The high bits may contain posix file attributes when the archive was written by certain third party 7z implementations. These must be removed before we can interpret the attributes as windows (or .NET) file attributes.
2016-07-21 11:06:42 +01:00
Tobias Käs
9224237a99 Fix for issue #73 (#154)
7z archives may require alternating reads from multiple substreams so it is important to seek before reading from the underlying stream. To keep performance at an acceptable level it is necessary to perform buffering because seeking on every single one-byte-read will destroy performance.
2016-07-21 11:06:25 +01:00
Adam Hathcock
8d16925662 Add Profile259 2016-07-18 14:37:39 +01:00
Adam Hathcock
ef0bf2758e Add Silverlight 5 2016-07-13 13:26:01 +01:00
Adam Hathcock
351a7552b9 0.12.0 2016-07-13 10:01:32 +01:00
Adam Hathcock
9dcc127454 .NET Core RTM 2016-07-13 09:58:13 +01:00
Adam Hathcock
81ff334aae Fix line endings 2016-07-13 09:54:42 +01:00
Pawel Pabich
e76ed60483 Tar long paths (#147)
* Now we can handle long file names

* Refactored code a bit
2016-07-06 09:57:52 +01:00
Adam Hathcock
04d04576bf Merge pull request #84 from adamhathcock/dnx
Using DNX and project.json
2016-06-06 10:04:02 -04:00
Adam Hathcock
dbd713756f Introducing the lock again for tests 2016-06-06 14:59:28 +01:00
Adam Hathcock
6d821dffa6 Everything builds and basically runs 2016-06-06 14:35:33 +01:00
Adam Hathcock
40e559e608 First pass. Doesn't work yet. 2016-05-20 17:31:35 +01:00
Adam Hathcock
b3fe26fc56 Merge branch 'master' into dnx
Conflicts:
	NuGet/sharpcompress.nuspec
	SharpCompress/VersionInfo.cs
	src/SharpCompress/Common/Tar/Headers/TarHeader.cs
	src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs
	src/SharpCompress/Compressor/BZip2/BZip2Stream.cs
	src/SharpCompress/Reader/ReaderFactory.cs
	src/SharpCompress/Writer/GZip/GZipWriter.cs
	src/SharpCompress/Writer/Tar/TarWriter.cs
	src/SharpCompress/Writer/WriterFactory.cs
	src/SharpCompress/Writer/Zip/ZipCentralDirectoryEntry.cs
	src/SharpCompress/Writer/Zip/ZipWriter.cs
	test/SharpCompress.Test/WriterTests.cs
2016-05-20 17:19:43 +01:00
Adam Hathcock
bb930da2f1 0.11.6 packaging 2016-04-07 09:44:28 +01:00
Adam Hathcock
732e352261 Merge pull request #138 from adamhathcock/leaveopen_writers
Leave open writers
2016-04-06 08:17:09 +01:00
Adam Hathcock
8f2ada3f20 Update README.md 2016-03-31 10:10:20 +01:00
Adam Hathcock
762381fac6 Explicit finish for BZip2 writing 2016-03-31 08:54:23 +01:00
Adam Hathcock
c440fdf88d Give writers leaveOpen option 2016-03-30 20:18:46 +01:00
Adam Hathcock
7f3f6bb135 Merge pull request #136 from zentron/master
Fix for `System.IO.Compression` created empty directory in zip
2016-03-03 13:13:59 +00:00
Rob
cb7853174d Fix for System.IO.Compression created empty directory in zip 2016-03-03 14:40:14 +10:00
Adam Hathcock
ef8575a107 Matching 77b034cbe7 to have 20 as the version made by 2016-02-26 09:22:23 +00:00
Adam Hathcock
6f3f82e0ad Merge pull request #129 from benshoof/tar-globalextendedheader
Support tars with global extended headers
2016-02-18 07:18:55 +00:00
benshoof
7b1609abe2 Support tars with global extended headers 2016-02-17 15:39:17 -09:00
Adam Hathcock
691c44a3b5 Clean up targets 2016-02-13 19:59:05 +00:00
Adam Hathcock
98c629c789 Fix tests and DataConverter compile issue 2016-02-13 19:56:20 +00:00
Adam Hathcock
8367bff9fe Fix up DataConverter...removed pack 2016-02-13 09:42:59 +00:00
Adam Hathcock
ff22cd774e Merge branch 'master' into dnx
Conflicts:
	NuGet/sharpcompress.nuspec
	SharpCompress/Common/Zip/WinzipAesCryptoStream.Portable.cs
	SharpCompress/Common/Zip/WinzipAesEncryptionData.Portable.cs
	SharpCompress/Crypto/PBKDF2.cs
	SharpCompress/SharpCompress.Portable.csproj
	SharpCompress/SharpCompress.PortableTest.csproj
	SharpCompress/SharpCompress.Unsigned.csproj
	SharpCompress/SharpCompress.WindowsStore.csproj
	SharpCompress/SharpCompress.csproj
	src/SharpCompress/Archive/ArchiveFactory.cs
	src/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs
	src/SharpCompress/Archive/Rar/RarArchive.cs
	src/SharpCompress/Archive/Rar/RarArchiveEntry.cs
	src/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs
	src/SharpCompress/Common/GZip/GZipFilePart.cs
	src/SharpCompress/Common/GZip/GZipVolume.cs
	src/SharpCompress/Common/Rar/Headers/MarkHeader.cs
	src/SharpCompress/Common/Rar/Headers/RarHeaderFactory.cs
	src/SharpCompress/Common/SevenZip/ArchiveReader.cs
	src/SharpCompress/Common/SevenZip/DataReader.cs
	src/SharpCompress/Common/Tar/Headers/TarHeader.cs
	src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs
	src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs
	src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs
	src/SharpCompress/Common/Zip/ZipFilePart.cs
	src/SharpCompress/Compressor/Deflate/GZipStream.cs
	src/SharpCompress/Compressor/Deflate/Inflate.cs
	src/SharpCompress/Compressor/Deflate/ZlibBaseStream.cs
	src/SharpCompress/Compressor/LZMA/Bcj2DecoderStream.cs
	src/SharpCompress/Compressor/LZMA/LzmaStream.cs
	src/SharpCompress/Compressor/PPMd/H/FreqData.cs
	src/SharpCompress/Compressor/PPMd/H/PPMContext.cs
	src/SharpCompress/Compressor/PPMd/H/RarMemBlock.cs
	src/SharpCompress/Compressor/PPMd/H/RarNode.cs
	src/SharpCompress/Compressor/PPMd/H/State.cs
	src/SharpCompress/Compressor/PPMd/PpmdProperties.cs
	src/SharpCompress/Compressor/Rar/VM/RarVM.cs
	src/SharpCompress/EnumExtensions.cs
	src/SharpCompress/IO/MarkingBinaryReader.cs
	src/SharpCompress/Reader/ReaderFactory.cs
	src/SharpCompress/Utility.cs
	src/SharpCompress/Writer/IWriter.Extensions.cs
	src/SharpCompress/Writer/Zip/ZipCentralDirectoryEntry.cs
	src/SharpCompress/Writer/Zip/ZipWriter.cs
	test/SharpCompress.Test/Tar/TarArchiveTests.cs
	test/SharpCompress.Test/Tar/TarReaderTests.cs
2016-02-13 09:24:44 +00:00
Adam Hathcock
ee5e3fbc1d Update to 0.11.5 2016-02-13 09:17:29 +00:00
Adam Hathcock
d13b2ad073 Do less than equals 2016-02-13 09:16:43 +00:00
Adam Hathcock
e9a7efc371 Merge pull request #127 from eklann/bugfix-incomplete-rar
Fixed bug triggered by incomplete rar file.
2016-02-10 19:38:10 +00:00
Josef Eklann
9b8ddda191 Fixed bug triggered by incomplete rar file. 2016-02-10 14:56:05 +01:00
Adam Hathcock
1fc14e1075 Update to 0.11.4 2016-02-07 10:17:45 +00:00
Adam Hathcock
b3a5204e74 Bug fix for previous PR 2016-02-07 10:14:07 +00:00
Adam Hathcock
0fab1ff976 Merge pull request #125 from kenkendk/set_compression_info_on_stream
Fix setting compressioninfo on Zip streams
2016-02-04 10:00:20 +00:00
Kenneth Skovhede
a05b692fc3 More whitespace fix 2016-02-04 10:39:58 +01:00
Kenneth Skovhede
ed7f140364 Whitespace fix 2016-02-04 10:39:02 +01:00
Kenneth Skovhede
a4b594121e Added code to forward the compression info to the stream, such that it is possible to override the compression level and method on a per-stream basis. 2016-02-04 10:35:36 +01:00
Adam Hathcock
fe8da55c95 Merge pull request #122 from benshoof/net35_compat
Added support for .NET 3.5
2016-01-26 21:00:20 +00:00
benshoof
42c4eab4be Fix conflicts 2016-01-26 09:56:54 -09:00
Adam Hathcock
2e8844c896 This doesn't work :) 2016-01-26 11:57:40 +00:00
Adam Hathcock
aed7ff003d Merge pull request #121 from benshoof/rar_detection_fix
Fix false positives in Rar file detection
2016-01-26 11:54:07 +00:00
Adam Hathcock
681b28f654 Merge pull request #119 from benshoof/endian-neutral
SharpCompress now endian neutral
2016-01-26 11:51:30 +00:00
Adam Hathcock
0de64b1551 Use ExtractAllEntries if archives are SOLID types 2016-01-26 11:49:57 +00:00
Adam Hathcock
526df2404e Merge pull request #123 from kenkendk/remove_warnings
Fix various warnings
2016-01-26 09:21:03 +00:00
Kenneth Skovhede
f20274aac7 Removed debug comments 2016-01-26 10:18:23 +01:00
Kenneth Skovhede
08b899fdac Deleted unused variables 2016-01-26 10:18:13 +01:00
Kenneth Skovhede
7b91b6e7c8 Commented out various unused fields that cause warnings and makes the WarningsAsErrors directive abort the build 2016-01-26 09:48:00 +01:00
benshoof
1661b7ec36 Added support for .NET 3.5
SharpCompress can now be compiled for .NET 3.5 by defining symbol NET35
2016-01-25 09:02:19 -09:00
benshoof
e5ab9dc883 Fix false positives in Rar file detection 2016-01-25 08:03:40 -09:00
Adam Hathcock
25d22e33a7 Merge pull request #118 from kenkendk/master
Bugfix for inflate algorithm cutting of the end of certain blocks
2016-01-23 10:24:50 +00:00
benshoof
8ceac9000c SharpCompress now endian neutral
SharpCompress can now be used on machines with big endian architecture
such as powerpc. All byte conversions now run through Mono's
DataConverter (or a portable version for builds that don't allow unsafe
code) instead of BitConverter, as BitConverter's behavior depends on the
host cpu.
2016-01-22 14:32:35 -09:00
Kenneth Skovhede
ecceec8e1a Tabs -> spaces fix 2016-01-22 15:06:55 +01:00
Kenneth Skovhede
d5c88ebab3 Bugfix for inflate algorithm cutting of the end of certain blocks 2016-01-22 14:51:05 +01:00
Adam Hathcock
0a2adbc205 Merge pull request #115 from maxpiva/master
Adds Non Lineal "Solid Rar" Extraction to RarArchive.
2016-01-17 13:54:24 +00:00
mpiva
3be7f9da37 Adds Non Lineal "Solid Rar" Extraction to RarArchive. 2016-01-17 02:31:55 -03:00
Adam Hathcock
3f2ca67416 Forgot the file overload 2016-01-15 10:04:28 +00:00
Adam Hathcock
21087323af Make Tar last in detection as it contains other files 2016-01-09 13:29:29 +00:00
Adam Hathcock
505838a32a Fixes from last merge 2016-01-04 21:08:30 +00:00
Adam Hathcock
fd3f9eb382 Merge remote-tracking branch 'origin/master' into dnx
Conflicts:
	SharpCompress/SharpCompress.PortableTest.csproj
	SharpCompress/SharpCompress.Unsigned.csproj
	SharpCompress/SharpCompress.csproj
	src/SharpCompress/Archive/IArchiveEntry.Extensions.cs
	src/SharpCompress/Reader/IReader.Extensions.cs
2016-01-04 21:01:12 +00:00
Adam Hathcock
05f92018c3 Merge pull request #113 from zentron/master
Preserve File Timestamps with IReader
2016-01-04 12:04:05 +00:00
Rob
b8fc4a2415 Preserve File Timestamps with IReader 2016-01-04 16:26:43 +10:00
Adam Hathcock
ccd2fc6568 Merge branch 'master' into dnx
Conflicts:
	src/SharpCompress/Archive/Rar/RarArchive.cs
2016-01-03 11:19:04 +00:00
Adam Hathcock
a30872809d Merge pull request #99 from Rovak/rarreader-add-password
Add password when opening RarReader
2016-01-03 03:18:12 -08:00
Adam Hathcock
7abf2ed58b Update README 2016-01-03 11:15:36 +00:00
Adam Hathcock
4822f571c3 Add explicit target for NET 4.5 2016-01-02 15:04:04 +00:00
Adam Hathcock
b0fdac3e6f Have NO_CRYPTO and add Profile259 2016-01-02 15:02:45 +00:00
Adam Hathcock
df62c1d3b2 NO_FILE tag 2016-01-02 14:57:05 +00:00
Adam Hathcock
56912ade7a reorg test project.json 2016-01-01 12:37:37 +00:00
Adam Hathcock
43698b41a7 Need RijndaelEngine for some reason 2016-01-01 12:21:23 +00:00
Adam Hathcock
fd2beeab48 trying to fix RarRijndael 2016-01-01 11:47:38 +00:00
Adam Hathcock
5647a424e7 Fix test execution 2016-01-01 11:23:01 +00:00
Adam Hathcock
a0a418e90b Remove bad character 2016-01-01 11:16:42 +00:00
Adam Hathcock
75e09b24c0 Remove bouncy castle code 2016-01-01 11:06:14 +00:00
Adam Hathcock
0b06023b82 Moved tests and fixed up nuget metadata 2015-12-30 16:59:27 +00:00
Adam Hathcock
49707498a5 move files around 2015-12-30 11:19:42 +00:00
Adam Hathcock
a4c2d27985 tests run...need parallel none 2015-12-30 11:04:16 +00:00
Adam Hathcock
9fac34fb21 intermediate checkin of xunit conversion 2015-12-29 15:26:38 +00:00
Adam Hathcock
d4b22936af fix net 35 2015-12-29 14:06:35 +00:00
Adam Hathcock
f0d0143be0 Remove csproj and start converting tests 2015-12-29 13:52:55 +00:00
Adam Hathcock
7d1593e887 Support NET3.5+ and DNXCORE50 and DOTNET 5.1 + 2015-12-28 23:40:33 +00:00
Adam Hathcock
2588444948 Using DOTNET51 and DNXCORE50 targets 2015-12-28 23:33:18 +00:00
Adam Hathcock
69abb8446f Merge branch 'master' into dnx 2015-12-28 18:47:12 +00:00
Adam Hathcock
bec2662d23 Update version 2015-12-28 18:40:35 +00:00
Adam Hathcock
dd35052de9 Merge pull request #105 from benshoof/fix-tests-release-build
Fix Release build of Tests
2015-12-17 08:54:31 +00:00
Adam Hathcock
2a630e04b2 Merge pull request #107 from benshoof/fix-nonzip-perf-regression
Fixed serious performance regression (revert 0f12a073af)
2015-12-15 16:33:06 +00:00
benshoof
231b78e096 Revert 0f12a073af
Revert commit that caused all non-zip files to be read entirely upon
opening.
IsZipArchive() would read and process the entire file looking for a zip
header.
2015-12-15 07:28:50 -09:00
Adam Hathcock
ce6e1d26f4 Merge pull request #104 from benshoof/fix-vs2013-build
Fix VS2013 compiler warnings (errors)
2015-12-15 09:10:49 +00:00
benshoof
69a25cd142 Fix Release build of Tests
Fixes release builds of SharpCompress.Test and
SharpCompress.Test.Portable. The UNSIGNED symbol was missing from the
Release configurations of SharpCompress.Unsigned and
SharpCompress.PortableTest
2015-12-14 15:32:49 -09:00
benshoof
cc2ad7d8d5 Fix VS2013 compiler warnings (errors)
Fixes broken build in VS2013 introduced by
18bd810228. That commit attempted to fix a
compiler warning from VS2015, but this turns out to be a compiler bug:
https://github.com/dotnet/roslyn/issues/4027 . That commit added code
which VS2013 correctly treats as a compiler warning, breaking the VS2013
build.
I have reverted this unnecessary change to the deflate code, fixing the
VS2013 build, and disabled warning CS0675 on send_bits() which will
satisfy VS2015.
2015-12-14 15:24:33 -09:00
Adam Hathcock
1aa0498e5d update nuspec 2015-11-30 19:40:24 +00:00
Adam Hathcock
1ce5e15fd2 Minor cleanup 2015-11-30 19:40:16 +00:00
Adam Hathcock
b40131736a Merge pull request #103 from pappe82/android-compatibility
Zip entry header version for Deflate compression set to 20
2015-11-30 19:37:38 +00:00
pappe82
c2b15b9c09 Zip entry header version for Deflate compression set to 20
The java runtime on Android cannot process file entries with the fixed
version 63 - it can only process entries up to version 20, which should
be fine if the entry was compressed using deflate.
2015-11-30 14:43:28 +01:00
Adam Hathcock
6fee1f6dc3 Merge branch 'master' into dnx 2015-11-28 15:35:09 +00:00
Adam Hathcock
27a4f78712 version 0.11.2 2015-11-20 18:59:43 +00:00
Adam Hathcock
2b5ee6e8cb resharper update 2015-11-20 18:59:29 +00:00
Adam Hathcock
cd8ea28576 last write time shouldn't equal...right? 2015-11-20 18:59:15 +00:00
Adam Hathcock
b2b6934499 Merge pull request #101 from twirpx/master
Non-compilable statements + zip archive handling
2015-11-19 16:46:26 +00:00
twirpx
0f12a073af Eliminated "throw - catch all" logic in ZipArchive 2015-11-19 21:08:55 +05:00
twirpx
18bd810228 Fixed non-compilable statements 2015-11-19 21:07:52 +05:00
twirpx
13bbb202c7 Changed MAX_ITERATIONS_FOR_DIRECTORY_HEADER to deal with archives that have larger comments 2015-11-19 21:06:56 +05:00
Roy van Kaathoven
6e0f4ecbc9 Add password when opening RarReader 2015-10-27 18:52:06 +01:00
Adam Hathcock
9a638e7aa5 Merge pull request #97 from Icenium/natanasova/add-explicit-compressioninfo
Add explicit compressioninfo when writing file to zip
2015-10-01 09:33:26 -07:00
Adam Hathcock
7a11dc4385 Merge pull request #96 from Icenium/natanasova/fix-extract-options-as-flag
Use enum as flag correctly
2015-10-01 09:30:46 -07:00
Nadya Atanasova
66816ce390 Add explicit compressioninfo when writing file to zip 2015-10-01 17:15:37 +03:00
Nadya Atanasova
5d8bd7b69b Use enum as flag correctly
Check PreserveFileTime when file times are initialized.
2015-10-01 17:02:58 +03:00
Adam Hathcock
0132c85ec7 Merge pull request #83 from haykpetros/issue_80
Added additional check to make sure that data is properly copied to a…
2015-08-30 09:46:38 +01:00
Adam Hathcock
e5d10e3dba Use only dotnet 2015-08-22 21:36:05 +01:00
Adam Hathcock
0ba87b6c62 Trying to get netcore45 in 2015-08-06 15:42:31 +01:00
Adam Hathcock
da47306f04 Use bouncy Sha256Digest 2015-08-06 14:51:36 +01:00
Adam Hathcock
1930126a59 Add Sha256Digest and Update other classes 2015-08-06 14:46:36 +01:00
Adam Hathcock
baf9f391f1 Setup bouncy castle crypto for dnx core 2015-08-06 14:46:07 +01:00
Adam Hathcock
979703dd1f ignore lock file 2015-08-06 14:25:54 +01:00
Adam Hathcock
ab9e8063dc remove lock file 2015-08-06 14:24:00 +01:00
Adam Hathcock
68c09d7221 Making a pass at DNX 2015-08-05 14:21:34 +01:00
haykpetros
9bf5df72a6 Added additional check to make sure that data is properly copied to array regardless fo computer/CPU platform (little-endian or big-endian). In case of big-endian platform intermediate array will be reversed prior to copying to destination array. 2015-08-05 05:27:30 -07:00
Adam Hathcock
91fc241358 Merge pull request #82 from haykpetros/issue_79
Issue 79
2015-08-04 15:05:37 +01:00
haykpetros
35a8b444b8 I feel there is no need to use unsafe version, so conditional compilation has been removed and only safe version kept. 2015-08-04 03:47:09 -07:00
haykpetros
2e928e86fd Removed unused method. 2015-08-04 03:24:59 -07:00
Adam Hathcock
6648f33c4e Merge pull request #81 from haykpetros/issue_78
Move closing parentheses to where they should be, so build does not b…
2015-08-04 10:05:17 +01:00
haykpetros
2a70ec8100 Move closing parentheses to where they should be, so build does not break for non-DEBUG configurations. 2015-08-03 13:11:13 -07:00
Adam Hathcock
05e0d591a5 Merge pull request #72 from hodm/master
Extract Options And Total Sizes
2015-07-27 10:07:22 +01:00
Adam Hathcock
1d30a1b51d Update README 2015-07-27 10:03:39 +01:00
Adam Hathcock
315c138c05 Removing .NET 2.0 support and LinqBridge dies a firey death 2015-07-27 09:48:36 +01:00
hodm
b0c514d87c Extract Options And Total Sizes
Fixed TotalSize For 7z
added TotalUncompressSize Tested for 7z
this enables to show progress for the entire archive
Added 2 Extract Options: PreserveFileTime And PreserveAttributes.
Put All the Log Command under DEBUG Condition.
2015-07-26 23:36:28 +03:00
Adam Hathcock
8e5cb77af2 Merge pull request #69 from pnewman8/master
Skip entry stream on dispose
2015-07-20 16:27:55 +01:00
Paul Newman
8faebc78d0 Cancel moved from EntryStream to Reader
Relates to previous commit. Following discussion with Adam, moved the Cancel() to the reader.

Example:

while (reader.MoveToNextEntry())
{
  using (var data = new StreamReader(reader.OpenEntryStream()))
  {
    try
    {
      DoSomething(data.ReadLine());
    }
    catch
    {
      reader.Cancel();
      throw;
    }
  }
}
2015-07-15 18:13:46 +01:00
Paul Newman
afff386622 Skip entry stream on dispose
Until now the caller had to completely consume each entry stream, or call SkipEntry(), before disposing the stream. If not, exception was thrown: "EntryStream has not been fully consumed". Hugely inconvenient; a user-thrown exception inside a "using (EntryStream)" block would be discarded.

Now automatically skips the entry on dispose.

Added method EntryStream.Cancel(). Call this if entry stream is unfinished, and no further entries are required. Helps with efficiency, as it avoids reading data that is not needed.
2015-07-15 13:44:20 +01:00
Adam Hathcock
9eb43156e8 Update license URL 2015-06-12 12:06:21 +01:00
Adam Hathcock
5dd9994d34 Update for 0.11 2015-06-12 12:03:03 +01:00
Adam Hathcock
f18771904e Made unsigned csproj for testing. Sign the main DLL again. 2015-06-12 11:59:31 +01:00
Adam Hathcock
ff1cdbfff2 Fix portable tests 2015-06-12 11:53:37 +01:00
Adam Hathcock
332d71d40d UTF8 is the default encoding for all platforms 2015-06-12 11:37:42 +01:00
Adam Hathcock
d9c31dace8 Fixing lingering build issues 2015-06-12 11:31:04 +01:00
Adam Hathcock
33c83e3893 Merge pull request #63 from mrgleba/master
ZipWriter: use ArchiveEncoding.Default
2015-06-11 09:30:05 +01:00
mrgleba
c7fc5f8819 ZipWriter: use ArchiveEncoding.Default
ShaprCompress is used internally in Mono to implement
System.IO.Compression, which allows the user to specify path encoding.
The change allows for specifying the encoding via
ArchiveEncoding.Default.
2015-06-11 08:36:33 +02:00
Adam Hathcock
8df6243807 Merge pull request #59 from KOLANICH/ZipFileEntry-LoadExtra-ArrayOverflowFix
Zip file entry load extra array overflow fix
2015-05-22 08:52:04 +01:00
Adam Hathcock
8bf5c99386 Merge pull request #56 from KOLANICH/test-path-fix
Improved testability
2015-05-22 08:51:44 +01:00
KOLANICH
83eae05e0c Fixed oveflow Zip/Headers/ZipFileEntry.cs 2015-05-22 00:07:32 +03:00
KOLANICH
7c70a7aafd Improved testability
1) disabled requirement of signature
2) added runtime discovery of folder with archives
3) disabled signing of test assembly
2015-05-22 00:00:59 +03:00
Adam Hathcock
dae13c782f Merge pull request #55 from benshoof/rar_protect_header
Added read support for RARs with Protect Headers
2015-05-08 13:58:05 +01:00
benshoof
ae1e37cde6 Added read support for RARs with Protect Headers
Some RARs with recovery records contain Protect Headers, I've added
support for parsing them so that RARs containing them can be read,
instead of an invalid-header exception being thrown. Parsing logic taken
from unrar reference source.
2015-05-07 18:20:05 -08:00
Adam Hathcock
94f4d35663 Merge pull request #53 from benshoof/master
Fixed .NET2 Release build
2015-05-05 09:19:51 +01:00
benshoof
5144104fef Fixed .NET2 Release build
The .NET2 project only built in Debug configuration due to not including
the compilation symbol NET2 in the Release configuration.
2015-05-02 20:40:34 -08:00
Adam Hathcock
f87e6672f2 Merge pull request #51 from sander2/fix-tar.bz2-compression
Fixed bug where tar.bz2 compression did not work
2015-04-09 13:39:38 +01:00
Adam Hathcock
312b53398c Merge pull request #52 from sander2/tar-long-name-support
Tar long name support
2015-04-09 13:39:21 +01:00
Sander Bosma
26ddc09c6a add unit test for writing tar archives containing long filenames 2015-04-07 21:43:45 +02:00
Sander Bosma
3113500229 don't write trailing zero in WriteOctalBytes
this fixes a bug where the trailing zero of the CRC overwrote the entrytype
2015-04-07 21:43:45 +02:00
Sander Bosma
ef72829f1c Fixed bug where tar.bz2 compression did not work 2015-04-06 17:09:55 +02:00
Sander Bosma
088644240a Tar: Support for writing long filenames (>100 chars) using longlink 2015-04-06 14:38:57 +02:00
Adam Hathcock
065ed29600 Merge pull request #47 from norvegec/master
fixed: .NET2 project is not compiling
2015-03-16 11:02:46 +00:00
Adam Hathcock
ee8c1f7904 Merge pull request #45 from catester/master
Made the assembly CLSCompliant.
2015-03-16 10:55:21 +00:00
catester
5d6a83578c Made the assembly CLSCompliant.
Added attribute [assembly: CLSCompliant(true)] and changed type of
public Crc properties from uint to long to satisfy CLS compliance.
2015-03-16 12:29:21 +02:00
Adam Hathcock
37d8d34601 Merge pull request #44 from catester/master
Added IWritableArchive interface
2015-03-16 09:43:28 +00:00
Norvegec
492f64053b fixed: .NET2 project is not compiling 2015-03-15 02:10:06 +03:00
catester
988fe5eac0 Replaced NotImplementedException for streams
This commit is more correct, it covers all stream types now.
2015-03-14 14:45:04 +02:00
catester
c48a47c9b2 Revert "Revert "Replaced NotImplementedException for streams""
This reverts commit abed9eb2c9.
2015-03-14 14:22:55 +02:00
catester
abed9eb2c9 Revert "Replaced NotImplementedException for streams"
This reverts commit 391663ac67.
2015-03-14 13:31:02 +02:00
catester
391663ac67 Replaced NotImplementedException for streams
Especially for streams, it is more appropriate to throw
NotSupportedException instead of NotImplementedException. Usually
consumers of streams expect NotSupportedException to handle errors.
There are other places that also use NotImplementedException but I
didn't examine them for now. I only modified stream classes in
SharpCompress.IO. For reference about this best practise, please see
these articles:
http://blogs.msdn.com/b/brada/archive/2004/07/29/201354.aspx

http://blogs.msdn.com/b/jaredpar/archive/2008/12/12/notimplementedexception-vs-notsupportedexception.aspx
2015-03-14 12:46:34 +02:00
catester
a8c055b990 Added IWritableArchive interface
So that when working with ArchiveFactory, you can cast the opened
archive to IWritableArchive for accessing AddEntry, RemoveEntry and
SaveTo methods without having to know what type of archive is opened
underhood. Also moved extension methods from AbstractWritableArchive to
this new interface. Also added GZipArchive to ArchiveFactory.Create as
it is one of the 3 writable archive types (zip, tar, gzip), not sure why
it was omitted.
2015-03-13 22:38:33 +02:00
Adam Hathcock
7ee885e7d5 Merge pull request #41 from mattbab/patch-1
Fixed simple typo
2015-01-21 08:02:48 +00:00
M.Babcock
ed05bd721f Fixed simple typo 2015-01-20 20:24:22 -06:00
Adam Hathcock
e52c183f1a Merge pull request #40 from Strachu/master
Inconsistent time format
2015-01-14 14:25:57 +00:00
Adam Hathcock
ed6ad6ac6d Merge pull request #39 from hrasyid/master
Fix typo
2015-01-14 14:24:51 +00:00
Strachu
62f198b532 All archive types now consistently return times as local time. 2015-01-14 14:23:59 +01:00
Hamdanil Rasyid
9770cfec9b Fix typo 2015-01-11 17:06:02 -08:00
Adam Hathcock
e05f30308c Merge pull request #30 from larvata/fix-zip-ansi-filename
Fix ansi filename decoded as gibberish in zip file
2014-12-24 17:10:30 +00:00
Adam Hathcock
6958347849 Merge pull request #32 from larvata/fix-extractAllEntires
Add EntryExtractionEvent for stream reader
2014-12-24 17:10:08 +00:00
Adam Hathcock
8e6ced6138 Merge pull request #31 from larvata/implement-central-directory-header
implement info-zip unicode path extra field
2014-12-24 17:09:20 +00:00
larvata
0c36ff6082 Fix ansi filename decoded as gibberish in zip file 2014-12-24 13:58:29 +08:00
larvata
f78e839365 implement info-zip unicode path extra field
Winrar won't set 'general purpose bit flag' for unicode filename storage
but use 'extra field:Info-ZIP Unicode Path Extra Field' instead.
2014-12-24 13:51:31 +08:00
larvata
7e3f04e669 add entryExtractionEvent for stream 2014-12-22 16:34:47 +08:00
Adam Hathcock
2d237bfbca Merge pull request #29 from arition/password_fix
Fix error when password is not in English
2014-12-18 23:41:35 +00:00
Adam Hathcock
e6e88dbde0 Merge pull request #28 from Strachu/tar_fix
Fixed bugs related to handling of .tar archives with long names
2014-12-16 14:37:09 +00:00
arition
e558a78354 Fix error when password is not in English 2014-12-16 19:47:13 +08:00
Adam Hathcock
c2df06a746 Merge pull request #27 from Strachu/rar_reorder
Changed the order of detecting whether the archive is in .rar format.
2014-12-16 10:51:47 +00:00
Adam Hathcock
41da844250 Merge pull request #26 from Strachu/7z_mtime
Exposed modification time for .7z archives
2014-12-16 10:47:26 +00:00
Strachu
8fcb0cb7a2 Fixed bug causing entries of non-ustar archive being after one with very long name to be discarded 2014-12-16 11:11:02 +01:00
Strachu
2e533f9fb5 Fixed handling of ustar tar files with long names. 2014-12-15 21:13:57 +01:00
Strachu
ca2778b658 Changed the order of detecting whether the archive is in .rar format.
Its very slow with big archives and shouldn't be done when we got archive in format which can be detected fast.
2014-12-15 20:57:54 +01:00
Strachu
3147ee0f14 Exposed modification time for .7z archives 2014-12-15 20:26:26 +01:00
Adam Hathcock
f72558de9e Merge pull request #23 from pivotal-cf-experimental/master
Adds MIT license.
2014-11-11 17:33:45 +00:00
mavenraven.org
6d69791db1 Adds MIT license. 2014-11-11 08:48:32 -08:00
Adam Hathcock
6e05a20136 Support file sizes larger than int.MaxValue 2014-10-24 09:39:59 +01:00
Adam Hathcock
d36ae445e2 Don't dispose! 2014-07-01 19:33:59 +01:00
Adam Hathcock
022f7ed26b Fix change from previous pull request 2014-04-30 11:27:49 +01:00
Adam Hathcock
d1a64021e1 Check for entry stream null. 2014-04-30 11:26:54 +01:00
Adam Hathcock
9225531f1e Merge pull request #15 from bastianeicher/master
.NET 2.0 version in NuGet package with limited dependency on LinqBridge
2014-04-24 10:16:00 +01:00
Bastian Eicher
650dc6f8bb .NET 2.0 version in NuGet package with limited dependency on LinqBridge 2014-04-16 17:07:41 +02:00
Adam Hathcock
49d6f1f633 Enumerate FILES not DIRECTORIES 2014-04-15 09:41:16 +01:00
Adam Hathcock
505f435f5d Renamed LinqBridge to .NET 2.0 target.
Cleaned up some cross-versioning code.
2014-04-15 09:36:05 +01:00
Adam Hathcock
d9d63fba96 Merge pull request #12 from bastianeicher/master
Added .NET 2.0 version (with LinqBridge)
2014-04-15 09:26:36 +01:00
Bastian Eicher
8c3d260d7c Added .NET 2.0 version (with LinqBridge) 2014-03-18 14:45:48 +01:00
Adam Hathcock
0fd00efada Fixed other projects 2014-02-01 10:36:22 +00:00
Adam Hathcock
71e86cd7e4 Added explicit checks for multi-volume encrypted archives to throw an error 2014-02-01 10:29:01 +00:00
Adam Hathcock
c64a96398d RarArchives now have password support 2014-02-01 09:01:15 +00:00
Adam Hathcock
efa9805fe4 Fixing Windows Store project to be Windows 8.1 with newest files 2014-02-01 07:57:50 +00:00
Adam Hathcock
2100d49cef Little more clean up 2013-12-23 12:29:41 +00:00
Adam Hathcock
66ffc82d41 Entries don't have FilePaths, they have keys 2013-12-23 12:20:06 +00:00
Adam Hathcock
e58ec599f0 Cleaning up some FileInfo non-usage and fixing tests. 2013-12-23 12:15:57 +00:00
Adam Hathcock
4eda2043df Moved ExtractTo to common logic 2013-12-23 11:42:08 +00:00
Adam Hathcock
afd65a7505 Removed unimplemented Close 2013-12-23 11:12:07 +00:00
Adam Hathcock
25148a9bf8 No expected exception 2013-12-22 09:37:35 +00:00
Adam Hathcock
97bc1865dc When using writable entries, reset stream on entry stream access. 2013-12-21 17:37:54 +00:00
Adam Hathcock
865afbfbf0 Throw exception when adding duplicate entry 2013-12-21 17:29:36 +00:00
Adam Hathcock
c59e6a8c99 AddEntry should return the added entry. 2013-12-21 17:14:41 +00:00
Adam Hathcock
be9111630e Fix for some type management problems 2013-12-21 09:34:40 +00:00
Adam Hathcock
d46de85ca2 Allow multiple saves of an archive. New entry streams must be seekable and resetable. 2013-12-20 15:50:29 +00:00
Adam Hathcock
c1562c5829 new entry streams must be readable and seekable 2013-12-20 15:33:20 +00:00
Adam Hathcock
f862cc6947 Remove redundant test from previous change 2013-12-20 15:32:57 +00:00
Adam Hathcock
cc3848aea5 Remove write check as I never actually write to any of the read streams 2013-12-20 15:00:17 +00:00
Adam Hathcock
46fc663e90 Fixed issue where adding a new entry then removing it wouldn't actually remove it. 2013-12-20 12:28:17 +00:00
Adam Hathcock
84ed6bc7f0 More Can* implemented 2013-12-19 11:05:39 +00:00
Adam Hathcock
fe5895d373 Implement Can* 2013-12-19 10:35:15 +00:00
Adam Hathcock
770e2d6e75 Resharper 8.1 2013-12-19 10:34:59 +00:00
468 changed files with 49250 additions and 51680 deletions

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# need original files to be windows
test/TestArchives/Original/*.txt eol=crlf

26
.gitignore vendored
View File

@@ -1,10 +1,16 @@
**/bin/*
**/obj/*
_ReSharper.SharpCompress/
bin/
*.suo
*.user
TestArchives/Scratch/
TestArchives/Scratch2/
TestResults/
*.nupkg
**/bin/*
**/obj/*
_ReSharper.SharpCompress/
bin/
*.suo
*.user
TestArchives/Scratch/
TestArchives/Scratch2/
TestResults/
*.nupkg
packages/*/
project.lock.json
test/TestArchives/Scratch
.vs
tools
.vscode

33
FORMATS.md Normal file
View File

@@ -0,0 +1,33 @@
# Archive Formats
## Accessing Archives
Archive classes allow random access to a seekable stream.
Reader classes allow forward-only reading
Writer classes allow forward-only Writing
## Supported Format Table
| Archive Format | Compression Format(s) | Compress/Decompress | Archive API | Reader API | Writer API |
| --- | --- | --- | --- | --- | --- |
| Rar | Rar | Decompress (1) | RarArchive | RarReader | N/A |
| Zip (2) | None, DEFLATE, BZip2, LZMA/LZMA2, PPMd | Both | ZipArchive | ZipReader | ZipWriter |
| Tar | None, BZip2, GZip, LZip | Both | TarArchive | TarReader | TarWriter (3) |
| GZip (single file) | GZip | Both | GZipArchive | GZipReader | GZipWriter |
| 7Zip (4) | LZMA, LZMA2, BZip2, PPMd, BCJ, BCJ2, Deflate | Decompress | SevenZipArchive | N/A | N/A |
1. SOLID Rars are only supported in the RarReader API.
2. Zip format supports pkware and WinzipAES encryption. However, encrypted LZMA is not supported. Zip64 reading is supported with the Archive API
3. The Tar format requires a file size in the header. If no size is specified to the TarWriter and the stream is not seekable, then an exception will be thrown.
4. The 7Zip format doesn't allow for reading as a forward-only stream so 7Zip is only supported through the Archive API
## Compressors
For those who want to directly compress/decompress bits
| Compressor | Compress/Decompress |
| --- | --- |
| BZip2Stream | Both |
| GZipStream | Both |
| DeflateStream | Both |
| LZMAStream | Both |
| PPMdStream | Both |
| ADCStream | Decompress |
| LZipStream | Decompress |

21
LICENSE.txt Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Adam Hathcock
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.

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>sharpcompress</id>
<version>0.10.3</version>
<title>SharpCompress - Pure C# Decompression/Compression</title>
<authors>Adam Hathcock</authors>
<owners>Adam Hathcock</owners>
<licenseUrl>http://sharpcompress.codeplex.com/license</licenseUrl>
<projectUrl>https://github.com/adamhathcock/sharpcompress</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>SharpCompress is a compression library for .NET/Mono/Silverlight/WP7/WindowsStore that can unrar, decompress 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.</description>
<releaseNotes />
<language>en-US</language>
<tags>rar unrar zip unzip bzip2 gzip tar 7zip</tags>
</metadata>
<files>
<file src="..\bin\Full\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
<file src="..\bin\WindowsStore\SharpCompress.dll" target="lib\netcore45\SharpCompress.dll" />
<file src="..\bin\Portable\SharpCompress.dll" target="lib\portable-net4+sl5+wp8+win8\SharpCompress.dll" />
</files>
</package>

141
README.md
View File

@@ -1,50 +1,131 @@
SharpCompress
=============
# SharpCompress
Github mirror of http://sharpcompress.codeplex.com
SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.
SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented.
The major feature is support for non-seekable streams so large files can be processed on the fly (i.e. download stream).
A Simple Request
[![Build status](https://ci.appveyor.com/api/projects/status/voxg971oemmvxh1e/branch/master?svg=true)](https://ci.appveyor.com/project/adamhathcock/sharpcompress/branch/master)
## Need Help?
Post Issues on Github!
Check the [Supported Formats](FORMATS.md) and [Basic Usage.](USAGE.md)
## A Simple Request
Hi everyone. I hope you're using SharpCompress and finding it useful. Please give me feedback on what you'd like to see changed especially as far as usability goes. New feature suggestions are always welcome as well. I would also like to know what projects SharpCompress is being used in. I like seeing how it is used to give me ideas for future versions. Thanks!
Want to contribute?
Please do not email me directly to ask for help. If you think there is a real issue, please report it here.
## Want to contribute?
I'm always looking for help or ideas. Please submit code or email with ideas. Unfortunately, just letting me know you'd like to help is not enough because I really have no overall plan of what needs to be done. I'll definitely accept code submissions and add you as a member of the project!
TODOs (always lots):
## TODOs (always lots)
* RAR 5 support
* 7Zip writing
* Zip64
* Zip64 (Need writing and extend Reading)
* Multi-volume Zip support.
* RAR5 support
Version 0.10.3:
==============
- Finally fixed Disposal issue when creating a new archive with the Archive API
## Version Log
Version 0.10.2:
==============
- Fixed Rar Header reading for invalid extended time headers.
- Windows Store assembly is now strong named
- Known issues with Long Tar names being worked on
- Updated to VS2013
- Portable targets SL5 and Windows Phone 8 (up from SL4 and WP7)
### Version 0.15.0
Version 0.10.1:
==============
- Fixed 7Zip extraction performance problem
* [Add zip64 support for ZipArchive extraction](https://github.com/adamhathcock/sharpcompress/pull/205)
Version 0.10:
==============
- Added support for RAR Decryption (thanks to https://github.com/hrasyid)
- Embedded some BouncyCastle crypto classes to allow RAR Decryption and Winzip AES Decryption in Portable and Windows Store DLLs
- Built in Release (I think)
### Version 0.14.1
Some Help/Discussion:
https://sharpcompress.codeplex.com/discussions
* [.NET Assemblies aren't strong named](https://github.com/adamhathcock/sharpcompress/issues/158)
* [Pkware encryption for Zip files didn't allow for multiple reads of an entry](https://github.com/adamhathcock/sharpcompress/issues/197)
* [GZip Entry couldn't be read multiple times](https://github.com/adamhathcock/sharpcompress/issues/198)
### Version 0.14.0
* [Support for LZip reading in for Tars](https://github.com/adamhathcock/sharpcompress/pull/191)
### Version 0.13.1
* [Fix null password on ReaderFactory. Fix null options on SevenZipArchive](https://github.com/adamhathcock/sharpcompress/pull/188)
* [Make PpmdProperties lazy to avoid unnecessary allocations.](https://github.com/adamhathcock/sharpcompress/pull/185)
### Version 0.13.0
* Breaking change: Big refactor of Options on API.
* 7Zip supports Deflate
### Version 0.12.4
* Forward only zip issue fix https://github.com/adamhathcock/sharpcompress/issues/160
* Try to fix frameworks again by copying targets from JSON.NET
### Version 0.12.3
* 7Zip fixes https://github.com/adamhathcock/sharpcompress/issues/73
* Maybe all profiles will work with project.json now
### Version 0.12.2
* Support Profile 259 again
### Version 0.12.1
* Support Silverlight 5
### Version 0.12.0
* .NET Core RTM!
* Bug fix for Tar long paths
### Version 0.11.6
* Bug fix for global header in Tar
* Writers now have a leaveOpen `bool` overload. They won't close streams if not-requested to.
### Version 0.11.5
* Bug fix in Skip method
### Version 0.11.4
* SharpCompress is now endian neutral (matters for Mono platforms)
* Fix for Inflate (need to change implementation)
* Fixes for RAR detection
### Version 0.11.1
* Added Cancel on IReader
* Removed .NET 2.0 support and LinqBridge dependency
### Version 0.11
* Been over a year, contains mainly fixes from contributors!
* Possible breaking change: ArchiveEncoding is UTF8 by default now.
* TAR supports writing long names using longlink
* RAR Protect Header added
### Version 0.10.3
* Finally fixed Disposal issue when creating a new archive with the Archive API
### Version 0.10.2
* Fixed Rar Header reading for invalid extended time headers.
* Windows Store assembly is now strong named
* Known issues with Long Tar names being worked on
* Updated to VS2013
* Portable targets SL5 and Windows Phone 8 (up from SL4 and WP7)
### Version 0.10.1
* Fixed 7Zip extraction performance problem
### Version 0.10:
* Added support for RAR Decryption (thanks to https://github.com/hrasyid)
* Embedded some BouncyCastle crypto classes to allow RAR Decryption and Winzip AES Decryption in Portable and Windows Store DLLs
* Built in Release (I think)
7Zip implementation based on: https://code.google.com/p/managed-lzma/
@@ -55,4 +136,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
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.
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.

View File

@@ -1,61 +0,0 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Archive;
using SharpCompress.Archive.GZip;
namespace SharpCompress.Test
{
[TestClass]
public class GZipArchiveTests : ArchiveTests
{
public GZipArchiveTests()
{
UseExtensionInsteadOfNameToVerify = true;
}
[TestMethod]
public void GZip_Archive_Generic()
{
ResetScratch();
using (Stream stream = File.Open(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"), FileMode.Open))
using (var archive = ArchiveFactory.Open(stream))
{
var entry = archive.Entries.First();
entry.WriteToFile(Path.Combine(SCRATCH_FILES_PATH, entry.FilePath));
}
CompareArchivesByPath(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar"),
Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar"));
}
[TestMethod]
public void GZip_Archive()
{
ResetScratch();
using (Stream stream = File.Open(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"), FileMode.Open))
using (var archive = GZipArchive.Open(stream))
{
var entry = archive.Entries.First();
entry.WriteToFile(Path.Combine(SCRATCH_FILES_PATH, entry.FilePath));
}
CompareArchivesByPath(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar"),
Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar"));
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void GZip_Archive_NoAdd()
{
string jpg = Path.Combine(ORIGINAL_FILES_PATH, "jpg\\test.jpg");
ResetScratch();
using (Stream stream = File.Open(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"), FileMode.Open))
using (var archive = GZipArchive.Open(stream))
{
archive.AddEntry("jpg\\test.jpg", jpg);
archive.SaveTo(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"));
}
}
}
}

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SharpCompress.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("SharpCompress.Test")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f01fddfb-445f-4548-9f69-88b69a8b71b0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,63 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SharpCompress.Test.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpCompress.Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SharpCompress.Test.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -1,188 +0,0 @@
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Archive;
using SharpCompress.Archive.Rar;
using SharpCompress.Common;
namespace SharpCompress.Test
{
[TestClass]
public class RarArchiveTests : ArchiveTests
{
[TestMethod]
public void Rar_None_ArchiveStreamRead()
{
ArchiveStreamRead("Rar.none.rar");
}
[TestMethod]
public void Rar_ArchiveStreamRead()
{
ArchiveStreamRead("Rar.rar");
}
[TestMethod]
public void Rar_test_invalid_exttime_ArchiveStreamRead()
{
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "test_invalid_exttime.rar")))
{
using (var archive = ArchiveFactory.Open(stream))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
}
}
[TestMethod]
public void Rar_Jpg_ArchiveStreamRead()
{
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "RarJpeg.jpg")))
{
using (var archive = RarArchive.Open(stream, Options.LookForHeader))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(SCRATCH_FILES_PATH,
ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
VerifyFiles();
}
}
[TestMethod]
public void Rar_IsSolidArchiveCheck()
{
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.rar")))
{
using (var archive = RarArchive.Open(stream))
{
Assert.IsFalse(archive.IsSolidArchive());
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(SCRATCH_FILES_PATH,
ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
}
VerifyFiles();
}
[TestMethod]
[ExpectedException(typeof(InvalidFormatException))]
public void Rar_Solid_ArchiveStreamRead()
{
ArchiveStreamRead("Rar.solid.rar");
}
[TestMethod]
public void Rar_Solid_StreamRead_Extract_All()
{
ArchiveStreamReadExtractAll("Rar.solid.rar", CompressionType.Rar);
}
[TestMethod]
public void Rar_Multi_ArchiveStreamRead()
{
var testArchives = new string[] { "Rar.multi.part01.rar",
"Rar.multi.part02.rar",
"Rar.multi.part03.rar",
"Rar.multi.part04.rar",
"Rar.multi.part05.rar",
"Rar.multi.part06.rar"};
ResetScratch();
using (var archive = RarArchive.Open(testArchives.Select(s => Path.Combine(TEST_ARCHIVES_PATH, s))
.Select(p => File.OpenRead(p))))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
VerifyFiles();
}
[TestMethod]
public void RarNoneArchiveFileRead()
{
ArchiveFileRead("Rar.none.rar");
}
[TestMethod]
public void Rar_ArchiveFileRead()
{
ArchiveFileRead("Rar.rar");
}
[TestMethod]
public void Rar_ArchiveFileRead_HasDirectories()
{
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.rar")))
{
using (var archive = RarArchive.Open(stream))
{
Assert.IsFalse(archive.IsSolidArchive());
Assert.IsTrue(archive.Entries.Any(entry => entry.IsDirectory));
}
}
}
[TestMethod]
public void Rar_Jpg_ArchiveFileRead()
{
ResetScratch();
using (var archive = RarArchive.Open(Path.Combine(TEST_ARCHIVES_PATH, "RarJpeg.jpg"), Options.LookForHeader))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
VerifyFiles();
}
[TestMethod]
[ExpectedException(typeof(InvalidFormatException))]
public void Rar_Solid_ArchiveFileRead()
{
ArchiveFileRead("Rar.solid.rar");
}
[TestMethod]
public void Rar_Multi_ArchiveFileRead()
{
ArchiveFileRead("Rar.multi.part01.rar");
}
[TestMethod]
public void Rar_IsFirstVolume_True()
{
using (var archive = RarArchive.Open(Path.Combine(TEST_ARCHIVES_PATH, "Rar.multi.part01.rar")))
{
Assert.IsTrue(archive.IsMultipartVolume());
Assert.IsTrue(archive.IsFirstVolume());
}
}
[TestMethod]
public void Rar_IsFirstVolume_False()
{
using (var archive = RarArchive.Open(Path.Combine(TEST_ARCHIVES_PATH, "Rar.multi.part03.rar")))
{
Assert.IsTrue(archive.IsMultipartVolume());
Assert.IsFalse(archive.IsFirstVolume());
}
}
}
}

View File

@@ -1,84 +0,0 @@
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.IO;
namespace SharpCompress.Test
{
[TestClass]
public class RewindableStreamTest
{
[TestMethod]
public void TestRewind()
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
bw.Write(1);
bw.Write(2);
bw.Write(3);
bw.Write(4);
bw.Write(5);
bw.Write(6);
bw.Write(7);
bw.Flush();
ms.Position = 0;
RewindableStream stream = new RewindableStream(ms);
stream.StartRecording();
BinaryReader br = new BinaryReader(stream);
Assert.AreEqual(br.ReadInt32(), 1);
Assert.AreEqual(br.ReadInt32(), 2);
Assert.AreEqual(br.ReadInt32(), 3);
Assert.AreEqual(br.ReadInt32(), 4);
stream.Rewind(true);
stream.StartRecording();
Assert.AreEqual(br.ReadInt32(), 1);
Assert.AreEqual(br.ReadInt32(), 2);
Assert.AreEqual(br.ReadInt32(), 3);
Assert.AreEqual(br.ReadInt32(), 4);
Assert.AreEqual(br.ReadInt32(), 5);
Assert.AreEqual(br.ReadInt32(), 6);
Assert.AreEqual(br.ReadInt32(), 7);
stream.Rewind(true);
stream.StartRecording();
Assert.AreEqual(br.ReadInt32(), 1);
Assert.AreEqual(br.ReadInt32(), 2);
Assert.AreEqual(br.ReadInt32(), 3);
Assert.AreEqual(br.ReadInt32(), 4);
}
[TestMethod]
public void TestIncompleteRewind()
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
bw.Write(1);
bw.Write(2);
bw.Write(3);
bw.Write(4);
bw.Write(5);
bw.Write(6);
bw.Write(7);
bw.Flush();
ms.Position = 0;
RewindableStream stream = new RewindableStream(ms);
stream.StartRecording();
BinaryReader br = new BinaryReader(stream);
Assert.AreEqual(br.ReadInt32(), 1);
Assert.AreEqual(br.ReadInt32(), 2);
Assert.AreEqual(br.ReadInt32(), 3);
Assert.AreEqual(br.ReadInt32(), 4);
stream.Rewind(true);
Assert.AreEqual(br.ReadInt32(), 1);
Assert.AreEqual(br.ReadInt32(), 2);
stream.StartRecording();
Assert.AreEqual(br.ReadInt32(), 3);
Assert.AreEqual(br.ReadInt32(), 4);
Assert.AreEqual(br.ReadInt32(), 5);
stream.Rewind(true);
Assert.AreEqual(br.ReadInt32(), 3);
Assert.AreEqual(br.ReadInt32(), 4);
Assert.AreEqual(br.ReadInt32(), 5);
Assert.AreEqual(br.ReadInt32(), 6);
Assert.AreEqual(br.ReadInt32(), 7);
}
}
}

View File

@@ -1,113 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E9C3C94B-FB27-4B4F-B225-57513C254D37}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress.Test</RootNamespace>
<AssemblyName>SharpCompress.Test.Portable</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<RestorePackages>true</RestorePackages>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\DebugPortable\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\SharpCompress\SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArchiveTests.cs" />
<Compile Include="GZip\GZipWriterTests.cs" />
<Compile Include="GZip\GZipArchiveTests.cs" />
<Compile Include="Rar\RarHeaderFactoryTest.cs" />
<Compile Include="SevenZip\SevenZipArchiveTests.cs" />
<Compile Include="Streams\StreamTests.cs" />
<Compile Include="Tar\TarWriterTests.cs" />
<Compile Include="Tar\TarReaderTests.cs" />
<Compile Include="Zip\ZipWriterTests.cs" />
<Compile Include="WriterTests.cs" />
<Compile Include="Rar\RarReaderTests.cs" />
<Compile Include="ReaderTests.cs" />
<Compile Include="Tar\TarArchiveTests.cs" />
<Compile Include="Zip\ZipArchiveTests.cs" />
<Compile Include="Rar\RarArchiveTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RewindableStreamTest.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestStream.cs" />
<Compile Include="Zip\ZipReaderTests.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="..\SharpCompress\SharpCompress.pfx">
<Link>SharpCompress.pfx</Link>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharpCompress\SharpCompress.PortableTest.csproj">
<Project>{efdcaf57-fd4d-4e5d-a3d5-f26b875817ed}</Project>
<Name>SharpCompress.PortableTest</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,113 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress.Test</RootNamespace>
<AssemblyName>SharpCompress.Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<RestorePackages>true</RestorePackages>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\SharpCompress\SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArchiveTests.cs" />
<Compile Include="GZip\GZipWriterTests.cs" />
<Compile Include="GZip\GZipArchiveTests.cs" />
<Compile Include="Rar\RarHeaderFactoryTest.cs" />
<Compile Include="SevenZip\SevenZipArchiveTests.cs" />
<Compile Include="Streams\StreamTests.cs" />
<Compile Include="Tar\TarWriterTests.cs" />
<Compile Include="Tar\TarReaderTests.cs" />
<Compile Include="Zip\ZipWriterTests.cs" />
<Compile Include="WriterTests.cs" />
<Compile Include="Rar\RarReaderTests.cs" />
<Compile Include="ReaderTests.cs" />
<Compile Include="Tar\TarArchiveTests.cs" />
<Compile Include="Zip\ZipArchiveTests.cs" />
<Compile Include="Rar\RarArchiveTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RewindableStreamTest.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestStream.cs" />
<Compile Include="Zip\ZipReaderTests.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="..\SharpCompress\SharpCompress.pfx">
<Link>SharpCompress.pfx</Link>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharpCompress\SharpCompress.csproj">
<Project>{10A689CF-76A2-4A4F-96E4-553C33398438}</Project>
<Name>SharpCompress</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,91 +0,0 @@
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Archive;
using SharpCompress.Archive.Tar;
using SharpCompress.Common;
namespace SharpCompress.Test
{
[TestClass]
public class TarArchiveTests : ArchiveTests
{
public TarArchiveTests()
{
UseExtensionInsteadOfNameToVerify = true;
}
[TestMethod]
public void TarArchiveStreamRead()
{
ArchiveStreamRead("Tar.tar");
}
[TestMethod]
public void TarArchivePathRead()
{
ArchiveFileRead("Tar.tar");
}
[TestMethod]
public void TarArchivePathReadLongName()
{
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "very long filename.tar");
using (var archive = TarArchive.Open(unmodified))
{
Assert.AreEqual(2, archive.Entries.Count);
Assert.AreEqual(archive.Entries.Last().FilePath, @"very long filename/very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename.jpg");
}
}
[TestMethod]
public void Tar_Create_New()
{
string scratchPath = Path.Combine(SCRATCH_FILES_PATH, "Tar.tar");
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.noEmptyDirs.tar");
base.ResetScratch();
using (var archive = TarArchive.Create())
{
archive.AddAllFromDirectory(ORIGINAL_FILES_PATH);
archive.SaveTo(scratchPath, CompressionType.None);
}
CompareArchivesByPath(unmodified, scratchPath);
}
[TestMethod]
public void Tar_Random_Write_Add()
{
string jpg = Path.Combine(ORIGINAL_FILES_PATH, "jpg\\test.jpg");
string scratchPath = Path.Combine(SCRATCH_FILES_PATH, "Tar.mod.tar");
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.mod.tar");
string modified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.noEmptyDirs.tar");
base.ResetScratch();
using (var archive = TarArchive.Open(unmodified))
{
archive.AddEntry("jpg\\test.jpg", jpg);
archive.SaveTo(scratchPath, CompressionType.None);
}
CompareArchivesByPath(modified, scratchPath);
}
[TestMethod]
public void Tar_Random_Write_Remove()
{
string scratchPath = Path.Combine(SCRATCH_FILES_PATH, "Tar.mod.tar");
string modified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.mod.tar");
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.noEmptyDirs.tar");
base.ResetScratch();
using (var archive = TarArchive.Open(unmodified))
{
var entry = archive.Entries.Where(x => x.FilePath.EndsWith("jpg")).Single();
archive.RemoveEntry(entry);
archive.SaveTo(scratchPath, CompressionType.None);
}
CompareArchivesByPath(modified, scratchPath);
}
}
}

View File

@@ -1,167 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Common;
using SharpCompress.Reader;
namespace SharpCompress.Test
{
public class TestBase
{
protected const string TEST_BASE_PATH = @"C:\Git\sharpcompress";
protected static readonly string TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
protected static readonly string ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
protected static readonly string MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
protected static readonly string SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
protected static readonly string SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");
protected static IEnumerable<string> GetRarArchives()
{
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.none.rar");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.rar");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.solid.rar");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.multi.part01.rar");
}
protected static IEnumerable<string> GetZipArchives()
{
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.dd.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.dd-.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.dd.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.lzma.dd.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.lzma.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.none.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.ppmd.dd.zip");
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.ppmd.zip");
}
protected static IEnumerable<string> GetTarArchives()
{
yield return Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar");
}
protected static IEnumerable<string> GetTarBz2Archives()
{
yield return Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.bz2");
}
protected static IEnumerable<string> GetTarGzArchives()
{
yield return Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz");
}
public void ResetScratch()
{
if (Directory.Exists(SCRATCH_FILES_PATH))
{
Directory.Delete(SCRATCH_FILES_PATH, true);
}
Directory.CreateDirectory(SCRATCH_FILES_PATH);
if (Directory.Exists(SCRATCH2_FILES_PATH))
{
Directory.Delete(SCRATCH2_FILES_PATH, true);
}
Directory.CreateDirectory(SCRATCH2_FILES_PATH);
}
public void VerifyFiles()
{
if (UseExtensionInsteadOfNameToVerify)
{
VerifyFilesByExtension();
}
else
{
VerifyFilesByName();
}
}
protected void VerifyFilesByName()
{
var extracted =
Directory.EnumerateFiles(SCRATCH_FILES_PATH, "*.*", SearchOption.AllDirectories)
.ToLookup(path => path.Substring(SCRATCH_FILES_PATH.Length));
var original =
Directory.EnumerateFiles(ORIGINAL_FILES_PATH, "*.*", SearchOption.AllDirectories)
.ToLookup(path => path.Substring(ORIGINAL_FILES_PATH.Length));
Assert.AreEqual(extracted.Count, original.Count);
foreach (var orig in original)
{
Assert.IsTrue(extracted.Contains(orig.Key));
CompareFilesByPath(orig.Single(), extracted[orig.Key].Single());
}
}
protected bool UseExtensionInsteadOfNameToVerify { get; set; }
protected void VerifyFilesByExtension()
{
var extracted =
Directory.EnumerateFiles(SCRATCH_FILES_PATH, "*.*", SearchOption.AllDirectories)
.ToLookup(path => Path.GetExtension(path));
var original =
Directory.EnumerateFiles(ORIGINAL_FILES_PATH, "*.*", SearchOption.AllDirectories)
.ToLookup(path => Path.GetExtension(path));
Assert.AreEqual(extracted.Count, original.Count);
foreach (var orig in original)
{
Assert.IsTrue(extracted.Contains(orig.Key));
CompareFilesByPath(orig.Single(), extracted[orig.Key].Single());
}
}
protected void CompareFilesByPath(string file1, string file2)
{
using (var file1Stream = File.OpenRead(file1))
using (var file2Stream = File.OpenRead(file2))
{
Assert.AreEqual(file1Stream.Length, file2Stream.Length);
int byte1 = 0;
int byte2 = 0;
for (int counter = 0; byte1 != -1; counter++)
{
byte1 = file1Stream.ReadByte();
byte2 = file2Stream.ReadByte();
if (byte1 != byte2)
Assert.AreEqual(byte1, byte2, string.Format("Byte {0} differ between {1} and {2}",
counter, file1, file2));
}
}
}
protected void CompareArchivesByPath(string file1, string file2)
{
using (var archive1 = ReaderFactory.Open(File.OpenRead(file1), Options.None))
using (var archive2 = ReaderFactory.Open(File.OpenRead(file2), Options.None))
{
while (archive1.MoveToNextEntry())
{
Assert.IsTrue(archive2.MoveToNextEntry());
Assert.AreEqual(archive1.Entry.FilePath, archive2.Entry.FilePath);
}
Assert.IsFalse(archive2.MoveToNextEntry());
}
}
private static readonly object testLock = new object();
[TestInitialize]
public void TestSetup()
{
Monitor.Enter(testLock);
}
[TestCleanup]
public void TestCleanup()
{
Monitor.Exit(testLock);
}
}
}

View File

@@ -1,36 +0,0 @@
using System.IO;
using SharpCompress.Common;
using SharpCompress.Reader;
using SharpCompress.Writer;
namespace SharpCompress.Test
{
public class WriterTests : TestBase
{
private ArchiveType type;
protected WriterTests(ArchiveType type)
{
this.type = type;
}
protected void Write(CompressionType compressionType, string archive, string archiveToVerifyAgainst)
{
ResetScratch();
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH2_FILES_PATH, archive)))
using (var writer = WriterFactory.Open(stream, type, compressionType))
{
writer.WriteAll(ORIGINAL_FILES_PATH, "*", SearchOption.AllDirectories);
}
CompareArchivesByPath(Path.Combine(SCRATCH2_FILES_PATH, archive),
Path.Combine(TEST_ARCHIVES_PATH, archiveToVerifyAgainst));
using (Stream stream = File.OpenRead(Path.Combine(SCRATCH2_FILES_PATH, archive)))
using (var reader = ReaderFactory.Open(stream))
{
reader.WriteAllToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath);
}
VerifyFiles();
}
}
}

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<!-- The configuration and platform will be used to determine which
assemblies to include from solution and project documentation
sources -->
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{a226cac9-f2c4-4cc2-94f9-163b3e221817}</ProjectGuid>
<SHFBSchemaVersion>1.9.3.0</SHFBSchemaVersion>
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName>
<RootNamespace>Documentation</RootNamespace>
<Name>Documentation</Name>
<!-- SHFB properties -->
<OutputPath>.\Help\</OutputPath>
<HtmlHelpName>sharpcompress</HtmlHelpName>
<Language>en-US</Language>
<RootNamespaceTitle>SharpCompress</RootNamespaceTitle>
<SandcastlePath>..\..\Program Files (x86)\Sandcastle\</SandcastlePath>
<DocumentationSources>
<DocumentationSource sourceFile="bin\SharpCompress.dll" />
<DocumentationSource sourceFile="bin\SharpCompress.xml" />
</DocumentationSources>
<HelpTitle>SharpCompress</HelpTitle>
<PresentationStyle>Prototype</PresentationStyle>
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
<MissingTags>AutoDocumentCtors, AutoDocumentDispose</MissingTags>
</PropertyGroup>
<!-- There are no properties for these groups. AnyCPU needs to appear in
order for Visual Studio to perform the build. The others are optional
common platform types that may appear. -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
</PropertyGroup>
<!-- Import the SHFB build targets -->
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
</Project>

Binary file not shown.

View File

@@ -1,64 +1,44 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F18F1765-4A02-42FD-9BEF-F0E2FCBD9D17}"
ProjectSection(SolutionItems) = preProject
NuGet\sharpcompress.nuspec = NuGet\sharpcompress.nuspec
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress", "SharpCompress\SharpCompress.csproj", "{10A689CF-76A2-4A4F-96E4-553C33398438}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Test", "SharpCompress.Test\SharpCompress.Test.csproj", "{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Portable", "SharpCompress\SharpCompress.Portable.csproj", "{7FA7D133-1417-4F85-9998-4C618AC8FEDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.WindowsStore", "SharpCompress\SharpCompress.WindowsStore.csproj", "{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.PortableTest", "SharpCompress\SharpCompress.PortableTest.csproj", "{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Test.Portable", "SharpCompress.Test\SharpCompress.Test.Portable.csproj", "{E9C3C94B-FB27-4B4F-B225-57513C254D37}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.Build.0 = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.Build.0 = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.Build.0 = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.Build.0 = Release|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}.Release|Any CPU.Build.0 = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9C3C94B-FB27-4B4F-B225-57513C254D37}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
{E9C3C94B-FB27-4B4F-B225-57513C254D37} = {932BBFCC-76E3-45FF-90CA-6BE4FBF4A097}
EndGlobalSection
EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F18F1765-4A02-42FD-9BEF-F0E2FCBD9D17}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SharpCompress", "src\SharpCompress\SharpCompress.xproj", "{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C5BE746-03E5-4895-9988-0B57F162F86C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0F0901FF-E8D9-426A-B5A2-17C7F47C1529}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SharpCompress.Test", "test\SharpCompress.Test\SharpCompress.Test.xproj", "{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}"
ProjectSection(ProjectDependencies) = postProject
{FD19DDD8-72B2-4024-8665-0D1F7A2AA998} = {FD19DDD8-72B2-4024-8665-0D1F7A2AA998}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}.Release|Any CPU.Build.0 = Release|Any CPU
{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FD19DDD8-72B2-4024-8665-0D1F7A2AA998} = {3C5BE746-03E5-4895-9988-0B57F162F86C}
{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5} = {0F0901FF-E8D9-426A-B5A2-17C7F47C1529}
EndGlobalSection
EndGlobal

View File

@@ -1,6 +1,119 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=181069325DAB1C4287CD564D6CDDEDB3/AbsolutePath/@EntryValue">D:\Git\sharpcompress\SharpCompress\sharpcompress.DotSettings</s:String>
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=181069325DAB1C4287CD564D6CDDEDB3/RelativePath/@EntryValue">..\SharpCompress\sharpcompress.DotSettings</s:String>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=181069325DAB1C4287CD564D6CDDEDB3/@KeyIndexDefined">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File181069325DAB1C4287CD564D6CDDEDB3/@KeyIndexDefined">True</s:Boolean>
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File181069325DAB1C4287CD564D6CDDEDB3/RelativePriority/@EntryValue">1</s:Double></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleNamedExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Fdowhile/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Ffixed/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Ffor/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Fforeach/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Fifelse/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Flock/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Fusing/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeBraces_005Fwhile/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodSupportsCancellation/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExplicitParamsArrayCreation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Basic_0020Clean/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Basic Clean"&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="False" ArrangeTypeMemberAccessModifier="False" SortModifiers="False" RemoveRedundantParentheses="False" AddMissingParentheses="False" ArrangeBraces="True" ArrangeAttributes="False" ArrangeArgumentsStyle="False" /&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Basic Clean</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/APPLY_ON_COMPLETION/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_NAMED/@EntryValue">Named</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOR/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_FIRST_ARG_BY_PAREN/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_EXPRESSION/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_FOR_STMT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_PARAMETER/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTIPLE_DECLARATION/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_CONSTRAINS/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_LIST/@EntryValue">True</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AFTER_START_COMMENT/@EntryValue">0</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_SINGLE_LINE_COMMENT/@EntryValue">1</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_ATTRIBUTE_STYLE/@EntryValue">SEPARATE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FIXED_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOR_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOREACH_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_ANONYMOUS_METHOD_BLOCK/@EntryValue">True</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CONSTRUCTOR_INITIALIZER_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSORHOLDER_ON_SINGLE_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_INITIALIZER_ON_SINGLE_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_WHILE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_ARROW_OP/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_SIZEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/STICK_COMMENT/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARRAY_INITIALIZER_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_EXTENDS_LIST_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_PARAMETERS_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForSimpleTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FCONSTANT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FCLASS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FCONSTRUCTOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FGLOBAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLABEL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FCONSTRUCTOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FOBJECT_005FPROPERTY_005FOF_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FCLASS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FENUM/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FENUM_005FMEMBER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FINTERFACE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE_005FEXPORTED/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE_005FLOCAL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FTYPE_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FHTML_005FCONTROL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FNAME/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FPREFIX/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=NAMESPACE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

BIN
SharpCompress.snk Normal file

Binary file not shown.

View File

@@ -1,85 +0,0 @@
using System.IO;
using SharpCompress.Common;
namespace SharpCompress.Archive
{
public static class AbstractWritableArchiveExtensions
{
public static void SaveTo<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
Stream stream, CompressionType compressionType)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
writableArchive.SaveTo(stream, new CompressionInfo {Type = compressionType});
}
#if !PORTABLE && !NETFX_CORE
public static void AddEntry<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
string entryPath, string filePath)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
var fileInfo = new FileInfo(filePath);
if (!fileInfo.Exists)
{
throw new FileNotFoundException("Could not AddEntry: " + filePath);
}
writableArchive.AddEntry(entryPath, new FileInfo(filePath).OpenRead(), true, fileInfo.Length,
fileInfo.LastWriteTime);
}
public static void SaveTo<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
string filePath, CompressionType compressionType)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
writableArchive.SaveTo(new FileInfo(filePath), new CompressionInfo {Type = compressionType});
}
public static void SaveTo<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
FileInfo fileInfo, CompressionType compressionType)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
{
writableArchive.SaveTo(stream, new CompressionInfo {Type = compressionType});
}
}
public static void SaveTo<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
string filePath, CompressionInfo compressionInfo)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
writableArchive.SaveTo(new FileInfo(filePath), compressionInfo);
}
public static void SaveTo<TEntry, TVolume>(this AbstractWritableArchive<TEntry, TVolume> writableArchive,
FileInfo fileInfo, CompressionInfo compressionInfo)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
{
writableArchive.SaveTo(stream, compressionInfo);
}
}
public static void AddAllFromDirectory<TEntry, TVolume>(
this AbstractWritableArchive<TEntry, TVolume> writableArchive,
string filePath, string searchPattern = "*.*", SearchOption searchOption = SearchOption.AllDirectories)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
foreach (var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption))
{
var fileInfo = new FileInfo(path);
writableArchive.AddEntry(path.Substring(filePath.Length), fileInfo.OpenRead(), true, fileInfo.Length,
fileInfo.LastWriteTime);
}
}
#endif
}
}

View File

@@ -1,129 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
namespace SharpCompress.Archive
{
public abstract class AbstractWritableArchive<TEntry, TVolume> : AbstractArchive<TEntry, TVolume>
where TEntry : IArchiveEntry
where TVolume : IVolume
{
private readonly List<TEntry> newEntries = new List<TEntry>();
private readonly List<TEntry> removedEntries = new List<TEntry>();
private readonly List<TEntry> modifiedEntries = new List<TEntry>();
private bool hasModifications;
private readonly bool anyNotWritable;
internal AbstractWritableArchive(ArchiveType type)
: base(type)
{
}
internal AbstractWritableArchive(ArchiveType type, IEnumerable<Stream> streams, Options options)
: base(type, streams, options)
{
if (streams.Any(x => !x.CanWrite))
{
anyNotWritable = true;
}
}
#if !PORTABLE && !NETFX_CORE
internal AbstractWritableArchive(ArchiveType type, FileInfo fileInfo, Options options)
: base(type, fileInfo, options)
{
}
#endif
private void CheckWritable()
{
if (anyNotWritable)
{
throw new ArchiveException("All Archive streams must be Writable to use Archive writing functionality.");
}
}
public override ICollection<TEntry> Entries
{
get
{
if (hasModifications)
{
return modifiedEntries;
}
return base.Entries;
}
}
private void RebuildModifiedCollection()
{
hasModifications = true;
modifiedEntries.Clear();
modifiedEntries.AddRange(OldEntries.Concat(newEntries));
}
private IEnumerable<TEntry> OldEntries
{
get { return base.Entries.Where(x => !removedEntries.Contains(x)); }
}
public void RemoveEntry(TEntry entry)
{
CheckWritable();
if (!removedEntries.Contains(entry))
{
removedEntries.Add(entry);
RebuildModifiedCollection();
}
}
public void AddEntry(string filePath, Stream source,
long size = 0, DateTime? modified = null)
{
CheckWritable();
newEntries.Add(CreateEntry(filePath, source, size, modified, false));
RebuildModifiedCollection();
}
public void AddEntry(string filePath, Stream source, bool closeStream,
long size = 0, DateTime? modified = null)
{
CheckWritable();
newEntries.Add(CreateEntry(filePath, source, size, modified, closeStream));
RebuildModifiedCollection();
}
#if !PORTABLE && !NETFX_CORE
public void AddEntry(string filePath, FileInfo fileInfo)
{
if (!fileInfo.Exists)
{
throw new ArgumentException("FileInfo does not exist.");
}
AddEntry(filePath, fileInfo.OpenRead(), true, fileInfo.Length, fileInfo.LastWriteTime);
}
#endif
public void SaveTo(Stream stream, CompressionInfo compressionType)
{
SaveTo(stream, compressionType, OldEntries, newEntries);
}
protected abstract TEntry CreateEntry(string filePath, Stream source, long size, DateTime? modified,
bool closeStream);
protected abstract void SaveTo(Stream stream, CompressionInfo compressionType,
IEnumerable<TEntry> oldEntries, IEnumerable<TEntry> newEntries);
public override void Dispose()
{
base.Dispose();
newEntries.Cast<Entry>().ForEach(x => x.Close());
removedEntries.Cast<Entry>().ForEach(x => x.Close());
modifiedEntries.Cast<Entry>().ForEach(x => x.Close());
}
}
}

View File

@@ -1,41 +0,0 @@
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Common.GZip;
namespace SharpCompress.Archive.GZip
{
public class GZipArchiveEntry : GZipEntry, IArchiveEntry
{
private GZipArchive archive;
internal GZipArchiveEntry(GZipArchive archive, GZipFilePart part)
: base(part)
{
this.archive = archive;
}
public virtual Stream OpenEntryStream()
{
return Parts.Single().GetCompressedStream();
}
#region IArchiveEntry Members
public void WriteTo(Stream streamToWriteTo)
{
if (IsEncrypted)
{
throw new PasswordProtectedException("Entry is password protected and cannot be extracted.");
}
this.Extract(archive, streamToWriteTo);
}
public bool IsComplete
{
get { return true; }
}
#endregion
}
}

View File

@@ -1,102 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using SharpCompress.Common;
using SharpCompress.IO;
namespace SharpCompress.Archive.GZip
{
internal class GZipWritableArchiveEntry : GZipArchiveEntry
{
private string path;
private long size;
private DateTime? lastModified;
private bool closeStream;
internal GZipWritableArchiveEntry(GZipArchive archive, Stream stream,
string path, long size, DateTime? lastModified, bool closeStream)
: base(archive, null)
{
this.Stream = stream;
this.path = path;
this.size = size;
this.lastModified = lastModified;
this.closeStream = closeStream;
}
public override uint Crc
{
get { return 0; }
}
public override string FilePath
{
get { return path; }
}
public override long CompressedSize
{
get { return 0; }
}
public override long Size
{
get { return size; }
}
public override DateTime? LastModifiedTime
{
get { return lastModified; }
}
public override DateTime? CreatedTime
{
get { return null; }
}
public override DateTime? LastAccessedTime
{
get { return null; }
}
public override DateTime? ArchivedTime
{
get { return null; }
}
public override bool IsEncrypted
{
get { return false; }
}
public override bool IsDirectory
{
get { return false; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { throw new NotImplementedException(); }
}
internal Stream Stream { get; private set; }
public override Stream OpenEntryStream()
{
return new NonDisposingStream(Stream);
}
internal override void Close()
{
if (closeStream)
{
Stream.Dispose();
}
}
}
}

View File

@@ -1,61 +0,0 @@
using System.IO;
using SharpCompress.Common;
namespace SharpCompress.Archive
{
public static class IArchiveEntryExtensions
{
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Extract to specific directory, retaining filename
/// </summary>
public static void WriteToDirectory(this IArchiveEntry entry, string destinationDirectory,
ExtractOptions options = ExtractOptions.Overwrite)
{
string destinationFileName = string.Empty;
string file = Path.GetFileName(entry.FilePath);
if (options.HasFlag(ExtractOptions.ExtractFullPath))
{
string folder = Path.GetDirectoryName(entry.FilePath);
string destdir = Path.Combine(destinationDirectory, folder);
if (!Directory.Exists(destdir))
{
Directory.CreateDirectory(destdir);
}
destinationFileName = Path.Combine(destdir, file);
}
else
{
destinationFileName = Path.Combine(destinationDirectory, file);
}
entry.WriteToFile(destinationFileName, options);
}
/// <summary>
/// Extract to specific file
/// </summary>
public static void WriteToFile(this IArchiveEntry entry, string destinationFileName,
ExtractOptions options = ExtractOptions.Overwrite)
{
if (entry.IsDirectory)
{
return;
}
FileMode fm = FileMode.Create;
if (!options.HasFlag(ExtractOptions.Overwrite))
{
fm = FileMode.CreateNew;
}
using (FileStream fs = File.Open(destinationFileName, fm))
// using (Stream entryStream = entry.OpenEntryStream())
{
//entryStream.TransferTo(fs);
entry.WriteTo(fs);
}
}
#endif
}
}

View File

@@ -1,36 +0,0 @@
using System.IO;
using SharpCompress.Common.Rar;
using SharpCompress.Common.Rar.Headers;
namespace SharpCompress.Archive.Rar
{
internal class FileInfoRarFilePart : RarFilePart
{
private FileInfoRarArchiveVolume volume;
internal FileInfoRarFilePart(FileInfoRarArchiveVolume volume, MarkHeader mh, FileHeader fh, FileInfo fi)
: base(mh, fh)
{
this.volume = volume;
FileInfo = fi;
}
internal FileInfo FileInfo { get; private set; }
internal override Stream GetCompressedStream()
{
var stream = volume.Stream;
stream.Position = FileHeader.DataStartPosition;
return stream;
}
internal override string FilePartName
{
get
{
return "Rar File: " + FileInfo.FullName
+ " File Entry: " + FileHeader.FileName;
}
}
}
}

View File

@@ -1,203 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Common.Rar;
using SharpCompress.Common.Rar.Headers;
using SharpCompress.Compressor.Rar;
using SharpCompress.IO;
using SharpCompress.Reader;
using SharpCompress.Reader.Rar;
namespace SharpCompress.Archive.Rar
{
public class RarArchive : AbstractArchive<RarArchiveEntry, RarVolume>
{
private readonly Unpack unpack = new Unpack();
internal Unpack Unpack
{
get { return unpack; }
}
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
internal RarArchive(FileInfo fileInfo, Options options)
: base(ArchiveType.Rar, fileInfo, options)
{
}
protected override IEnumerable<RarVolume> LoadVolumes(FileInfo file, Options options)
{
return RarArchiveVolumeFactory.GetParts(file, options);
}
#endif
/// <summary>
/// Takes multiple seekable Streams for a multi-part archive
/// </summary>
/// <param name="streams"></param>
/// <param name="options"></param>
internal RarArchive(IEnumerable<Stream> streams, Options options)
: base(ArchiveType.Rar, streams, options)
{
}
protected override IEnumerable<RarArchiveEntry> LoadEntries(IEnumerable<RarVolume> volumes)
{
return RarArchiveEntryFactory.GetEntries(this, volumes);
}
protected override IEnumerable<RarVolume> LoadVolumes(IEnumerable<Stream> streams, Options options)
{
return RarArchiveVolumeFactory.GetParts(streams, options);
}
protected override IReader CreateReaderForSolidExtraction()
{
var stream = Volumes.First().Stream;
stream.Position = 0;
return RarReader.Open(stream);
}
public override bool IsSolid
{
get { return Volumes.First().IsSolidArchive; }
}
#region Creation
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
public static RarArchive Open(string filePath)
{
return Open(filePath, Options.None);
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
public static RarArchive Open(FileInfo fileInfo)
{
return Open(fileInfo, Options.None);
}
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
/// <param name="options"></param>
public static RarArchive Open(string filePath, Options options)
{
filePath.CheckNotNullOrEmpty("filePath");
return Open(new FileInfo(filePath), options);
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
public static RarArchive Open(FileInfo fileInfo, Options options)
{
fileInfo.CheckNotNull("fileInfo");
return new RarArchive(fileInfo, options);
}
#endif
/// <summary>
/// Takes a seekable Stream as a source
/// </summary>
/// <param name="stream"></param>
public static RarArchive Open(Stream stream)
{
stream.CheckNotNull("stream");
return Open(stream.AsEnumerable());
}
/// <summary>
/// Takes a seekable Stream as a source
/// </summary>
/// <param name="stream"></param>
/// <param name="options"></param>
public static RarArchive Open(Stream stream, Options options)
{
stream.CheckNotNull("stream");
return Open(stream.AsEnumerable(), options);
}
/// <summary>
/// Takes multiple seekable Streams for a multi-part archive
/// </summary>
/// <param name="streams"></param>
public static RarArchive Open(IEnumerable<Stream> streams)
{
streams.CheckNotNull("streams");
return new RarArchive(streams, Options.KeepStreamsOpen);
}
/// <summary>
/// Takes multiple seekable Streams for a multi-part archive
/// </summary>
/// <param name="streams"></param>
/// <param name="options"></param>
public static RarArchive Open(IEnumerable<Stream> streams, Options options)
{
streams.CheckNotNull("streams");
return new RarArchive(streams, options);
}
#if !PORTABLE && !NETFX_CORE
public static bool IsRarFile(string filePath)
{
return IsRarFile(new FileInfo(filePath));
}
public static bool IsRarFile(FileInfo fileInfo)
{
if (!fileInfo.Exists)
{
return false;
}
using (Stream stream = fileInfo.OpenRead())
{
return IsRarFile(stream);
}
}
#endif
public static bool IsRarFile(Stream stream)
{
return IsRarFile(stream, Options.None);
}
public static bool IsRarFile(Stream stream, Options options)
{
try
{
var headerFactory = new RarHeaderFactory(StreamingMode.Seekable, options);
RarHeader header = headerFactory.ReadHeaders(stream).FirstOrDefault();
if (header == null)
{
return false;
}
return Enum.IsDefined(typeof (HeaderType), header.HeaderType);
}
catch
{
return false;
}
}
#endregion
}
}

View File

@@ -1,105 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Common.Rar;
using SharpCompress.Common.Rar.Headers;
using SharpCompress.Compressor.Rar;
namespace SharpCompress.Archive.Rar
{
public class RarArchiveEntry : RarEntry, IArchiveEntry
{
private readonly ICollection<RarFilePart> parts;
internal RarArchiveEntry(RarArchive archive, IEnumerable<RarFilePart> parts)
{
this.parts = parts.ToList();
Archive = archive;
}
public override CompressionType CompressionType
{
get { return CompressionType.Rar; }
}
private RarArchive Archive { get; set; }
internal override IEnumerable<FilePart> Parts
{
get { return parts.Cast<FilePart>(); }
}
internal override FileHeader FileHeader
{
get { return parts.First().FileHeader; }
}
public override uint Crc
{
get
{
CheckIncomplete();
return parts.Select(fp => fp.FileHeader)
.Where(fh => !fh.FileFlags.HasFlag(FileFlags.SPLIT_AFTER))
.Single().FileCRC;
}
}
public override long Size
{
get
{
CheckIncomplete();
return parts.First().FileHeader.UncompressedSize;
}
}
public override long CompressedSize
{
get
{
CheckIncomplete();
return parts.Aggregate(0L, (total, fp) => { return total + fp.FileHeader.CompressedSize; });
}
}
public Stream OpenEntryStream()
{
return new RarStream(Archive.Unpack, FileHeader,
new MultiVolumeReadOnlyStream(Parts.Cast<RarFilePart>(), Archive));
}
public void WriteTo(Stream streamToWriteTo)
{
CheckIncomplete();
if (Archive.IsSolidArchive())
{
throw new InvalidFormatException("Cannot use Archive random access on SOLID Rar files.");
}
if (IsEncrypted)
{
throw new PasswordProtectedException("Entry is password protected and cannot be extracted.");
}
this.Extract(Archive, streamToWriteTo);
}
public bool IsComplete
{
get { return parts.Select(fp => fp.FileHeader).Any(fh => !fh.FileFlags.HasFlag(FileFlags.SPLIT_AFTER)); }
}
private void CheckIncomplete()
{
if (!IsComplete)
{
throw new IncompleteArchiveException("ArchiveEntry is incomplete and cannot perform this operation.");
}
}
internal override void Close()
{
}
}
}

View File

@@ -1,28 +0,0 @@
using System.IO;
using SharpCompress.Common.Rar;
using SharpCompress.Common.Rar.Headers;
namespace SharpCompress.Archive.Rar
{
internal class SeekableStreamFilePart : RarFilePart
{
internal SeekableStreamFilePart(MarkHeader mh, FileHeader fh, Stream stream)
: base(mh, fh)
{
Stream = stream;
}
internal Stream Stream { get; private set; }
internal override Stream GetCompressedStream()
{
Stream.Position = FileHeader.DataStartPosition;
return Stream;
}
internal override string FilePartName
{
get { return "Unknown Stream - File Entry: " + base.FileHeader.FileName; }
}
}
}

View File

@@ -1,44 +0,0 @@
using System.IO;
using SharpCompress.Common;
using SharpCompress.Common.SevenZip;
namespace SharpCompress.Archive.SevenZip
{
public class SevenZipArchiveEntry : SevenZipEntry, IArchiveEntry
{
private SevenZipArchive archive;
internal SevenZipArchiveEntry(SevenZipArchive archive, SevenZipFilePart part)
: base(part)
{
this.archive = archive;
}
public Stream OpenEntryStream()
{
return FilePart.GetCompressedStream();
}
public void WriteTo(Stream stream)
{
if (IsEncrypted)
{
throw new PasswordProtectedException("Entry is password protected and cannot be extracted.");
}
this.Extract(archive, stream);
}
public bool IsComplete
{
get { return true; }
}
/// <summary>
/// This is a 7Zip Anti item
/// </summary>
public bool IsAnti
{
get { return FilePart.Header.IsAnti; }
}
}
}

View File

@@ -1,102 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using SharpCompress.Common;
using SharpCompress.IO;
namespace SharpCompress.Archive.Tar
{
internal class TarWritableArchiveEntry : TarArchiveEntry
{
private string path;
private long size;
private DateTime? lastModified;
private bool closeStream;
internal TarWritableArchiveEntry(TarArchive archive, Stream stream, CompressionType compressionType,
string path, long size, DateTime? lastModified, bool closeStream)
: base(archive, null, compressionType)
{
this.Stream = stream;
this.path = path;
this.size = size;
this.lastModified = lastModified;
this.closeStream = closeStream;
}
public override uint Crc
{
get { return 0; }
}
public override string FilePath
{
get { return path; }
}
public override long CompressedSize
{
get { return 0; }
}
public override long Size
{
get { return size; }
}
public override DateTime? LastModifiedTime
{
get { return lastModified; }
}
public override DateTime? CreatedTime
{
get { return null; }
}
public override DateTime? LastAccessedTime
{
get { return null; }
}
public override DateTime? ArchivedTime
{
get { return null; }
}
public override bool IsEncrypted
{
get { return false; }
}
public override bool IsDirectory
{
get { return false; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { throw new NotImplementedException(); }
}
internal Stream Stream { get; private set; }
public override Stream OpenEntryStream()
{
return new NonDisposingStream(Stream);
}
internal override void Close()
{
if (closeStream)
{
Stream.Dispose();
}
}
}
}

View File

@@ -1,41 +0,0 @@
using System.IO;
using System.Linq;
using SharpCompress.Common.Zip;
namespace SharpCompress.Archive.Zip
{
public class ZipArchiveEntry : ZipEntry, IArchiveEntry
{
private ZipArchive archive;
internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart part)
: base(part)
{
this.archive = archive;
}
public virtual Stream OpenEntryStream()
{
return Parts.Single().GetCompressedStream();
}
#region IArchiveEntry Members
public void WriteTo(Stream streamToWriteTo)
{
this.Extract(archive, streamToWriteTo);
}
public bool IsComplete
{
get { return true; }
}
#endregion
public string Comment
{
get { return (Parts.Single() as SeekableZipFilePart).Comment; }
}
}
}

View File

@@ -1,104 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using SharpCompress.Common;
using SharpCompress.IO;
namespace SharpCompress.Archive.Zip
{
internal class ZipWritableArchiveEntry : ZipArchiveEntry
{
private readonly string path;
private readonly long size;
private readonly DateTime? lastModified;
private readonly bool closeStream;
private bool isDisposed;
internal ZipWritableArchiveEntry(ZipArchive archive, Stream stream, string path, long size,
DateTime? lastModified, bool closeStream)
: base(archive, null)
{
Stream = stream;
this.path = path;
this.size = size;
this.lastModified = lastModified;
this.closeStream = closeStream;
}
public override uint Crc
{
get { return 0; }
}
public override string FilePath
{
get { return path; }
}
public override long CompressedSize
{
get { return 0; }
}
public override long Size
{
get { return size; }
}
public override DateTime? LastModifiedTime
{
get { return lastModified; }
}
public override DateTime? CreatedTime
{
get { return null; }
}
public override DateTime? LastAccessedTime
{
get { return null; }
}
public override DateTime? ArchivedTime
{
get { return null; }
}
public override bool IsEncrypted
{
get { return false; }
}
public override bool IsDirectory
{
get { return false; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { throw new NotImplementedException(); }
}
internal Stream Stream { get; private set; }
public override Stream OpenEntryStream()
{
return new NonDisposingStream(Stream);
}
internal override void Close()
{
if (closeStream && !isDisposed)
{
Stream.Dispose();
isDisposed = true;
}
}
}
}

View File

@@ -1,19 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#if PORTABLE
[assembly: AssemblyTitle("SharpCompress.Portable")]
[assembly: AssemblyProduct("SharpCompress.Portable")]
#else
[assembly: AssemblyTitle("SharpCompress")]
[assembly: AssemblyProduct("SharpCompress")]
[assembly:
InternalsVisibleTo(
"SharpCompress.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
)]
[assembly:
InternalsVisibleTo(
"SharpCompress.Test.Portable, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
)]
#endif

View File

@@ -1,30 +0,0 @@
using SharpCompress.Compressor.Deflate;
namespace SharpCompress.Common
{
/// <summary>
/// Detailed compression properties when saving.
/// </summary>
public class CompressionInfo
{
public CompressionInfo()
{
DeflateCompressionLevel = CompressionLevel.Default;
}
/// <summary>
/// The algorthm to use. Must be valid for the format type.
/// </summary>
public CompressionType Type { get; set; }
/// <summary>
/// When CompressionType.Deflate is used, this property is referenced. Defaults to CompressionLevel.Default.
/// </summary>
public CompressionLevel DeflateCompressionLevel { get; set; }
public static implicit operator CompressionInfo(CompressionType compressionType)
{
return new CompressionInfo() {Type = compressionType};
}
}
}

View File

@@ -1,20 +0,0 @@
using System;
namespace SharpCompress.Common
{
[Flags]
public enum ExtractOptions
{
None,
/// <summary>
/// overwrite target if it exists
/// </summary>
Overwrite,
/// <summary>
/// extract with internal directory structure
/// </summary>
ExtractFullPath,
}
}

View File

@@ -1,90 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace SharpCompress.Common.GZip
{
public class GZipEntry : Entry
{
private readonly GZipFilePart filePart;
internal GZipEntry(GZipFilePart filePart)
{
this.filePart = filePart;
}
public override CompressionType CompressionType
{
get { return CompressionType.GZip; }
}
public override uint Crc
{
get { return 0; }
}
public override string FilePath
{
get { return filePart.FilePartName; }
}
public override long CompressedSize
{
get { return 0; }
}
public override long Size
{
get { return 0; }
}
public override DateTime? LastModifiedTime
{
get { return filePart.DateModified; }
}
public override DateTime? CreatedTime
{
get { return null; }
}
public override DateTime? LastAccessedTime
{
get { return null; }
}
public override DateTime? ArchivedTime
{
get { return null; }
}
public override bool IsEncrypted
{
get { return false; }
}
public override bool IsDirectory
{
get { return false; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { return filePart.AsEnumerable<FilePart>(); }
}
internal static IEnumerable<GZipEntry> GetEntries(Stream stream)
{
yield return new GZipEntry(new GZipFilePart(stream));
}
internal override void Close()
{
}
}
}

View File

@@ -1,44 +0,0 @@
using System.IO;
namespace SharpCompress.Common.GZip
{
public class GZipVolume : Volume
{
#if !PORTABLE && !NETFX_CORE
private readonly FileInfo fileInfo;
#endif
public GZipVolume(Stream stream, Options options)
: base(stream, options)
{
}
#if !PORTABLE && !NETFX_CORE
public GZipVolume(FileInfo fileInfo, Options options)
: base(fileInfo.OpenRead(), options)
{
this.fileInfo = fileInfo;
}
#endif
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// File that backs this volume, if it not stream based
/// </summary>
public override FileInfo VolumeFile
{
get { return fileInfo; }
}
#endif
public override bool IsFirstVolume
{
get { return true; }
}
public override bool IsMultiVolume
{
get { return true; }
}
}
}

View File

@@ -1,44 +0,0 @@
using System.IO;
namespace SharpCompress.Common
{
public class GenericVolume : Volume
{
#if !PORTABLE && !NETFX_CORE
private FileInfo fileInfo;
#endif
public GenericVolume(Stream stream, Options options)
: base(stream, options)
{
}
#if !PORTABLE && !NETFX_CORE
public GenericVolume(FileInfo fileInfo, Options options)
: base(fileInfo.OpenRead(), options)
{
this.fileInfo = fileInfo;
}
#endif
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// File that backs this volume, if it not stream based
/// </summary>
public override FileInfo VolumeFile
{
get { return fileInfo; }
}
#endif
public override bool IsFirstVolume
{
get { return true; }
}
public override bool IsMultiVolume
{
get { return true; }
}
}
}

View File

@@ -1,17 +0,0 @@
using System;
#if !PORTABLE && !NETFX_CORE
using System.IO;
#endif
namespace SharpCompress.Common
{
public interface IVolume : IDisposable
{
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// File that backs this volume, if it not stream based
/// </summary>
FileInfo VolumeFile { get; }
#endif
}
}

View File

@@ -1,23 +0,0 @@
using System;
namespace SharpCompress.Common
{
[Flags]
public enum Options
{
/// <summary>
/// No options specified
/// </summary>
None = 0,
/// <summary>
/// SharpCompress will keep the supplied streams open
/// </summary>
KeepStreamsOpen = 1,
/// <summary>
/// Look for RarArchive (Check for self-extracting archives or cases where RarArchive isn't at the start of the file)
/// </summary>
LookForHeader = 2,
}
}

View File

@@ -1,59 +0,0 @@
using SharpCompress.IO;
namespace SharpCompress.Common.Rar.Headers
{
internal class MarkHeader : RarHeader
{
protected override void ReadFromReader(MarkingBinaryReader reader)
{
}
internal bool IsValid()
{
if (!(HeadCRC == 0x6152))
{
return false;
}
if (!(HeaderType == HeaderType.MarkHeader))
{
return false;
}
if (!(Flags == 0x1a21))
{
return false;
}
if (!(HeaderSize == BaseBlockSize))
{
return false;
}
return true;
}
internal bool IsSignature()
{
bool valid = false;
/*byte[] d = new byte[BaseBlock.BaseBlockSize];
BinaryWriter writer = new BinaryWriter();
writer.Write(HeadCRC);
writer.Write((byte)HeaderType);
writer.Write(flags);
writer.Write(HeaderSize);
writer.Flush
if (d[0] == 0x52) {
if (d[1]==0x45 && d[2]==0x7e && d[3]==0x5e) {
oldFormat=true;
valid=true;
}
else if (d[1]==0x61 && d[2]==0x72 && d[3]==0x21 && d[4]==0x1a &&
d[5]==0x07 && d[6]==0x00) {
oldFormat=false;
valid=true;
}
}*/
return valid;
}
internal bool OldFormat { get; private set; }
}
}

View File

@@ -1,85 +0,0 @@
using System;
using SharpCompress.Common.Rar.Headers;
namespace SharpCompress.Common.Rar
{
public abstract class RarEntry : Entry
{
internal abstract FileHeader FileHeader { get; }
/// <summary>
/// The File's 32 bit CRC Hash
/// </summary>
public override uint Crc
{
get { return FileHeader.FileCRC; }
}
/// <summary>
/// The path of the file internal to the Rar Archive.
/// </summary>
public override string FilePath
{
get { return FileHeader.FileName; }
}
/// <summary>
/// The entry last modified time in the archive, if recorded
/// </summary>
public override DateTime? LastModifiedTime
{
get { return FileHeader.FileLastModifiedTime; }
}
/// <summary>
/// The entry create time in the archive, if recorded
/// </summary>
public override DateTime? CreatedTime
{
get { return FileHeader.FileCreatedTime; }
}
/// <summary>
/// The entry last accessed time in the archive, if recorded
/// </summary>
public override DateTime? LastAccessedTime
{
get { return FileHeader.FileLastAccessedTime; }
}
/// <summary>
/// The entry time whend archived, if recorded
/// </summary>
public override DateTime? ArchivedTime
{
get { return FileHeader.FileArchivedTime; }
}
/// <summary>
/// Entry is password protected and encrypted and cannot be extracted.
/// </summary>
public override bool IsEncrypted
{
get { return FileHeader.FileFlags.HasFlag(FileFlags.PASSWORD); }
}
/// <summary>
/// Entry is password protected and encrypted and cannot be extracted.
/// </summary>
public override bool IsDirectory
{
get { return FileHeader.FileFlags.HasFlag(FileFlags.DIRECTORY); }
}
public override bool IsSplit
{
get { return FileHeader.FileFlags.HasFlag(FileFlags.SPLIT_AFTER); }
}
public override string ToString()
{
return string.Format("Entry Path: {0} Compressed Size: {1} Uncompressed Size: {2} CRC: {3}",
FilePath, CompressedSize, Size, Crc);
}
}
}

View File

@@ -1,112 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace SharpCompress.Common.Rar
{
internal class RarRijndael : IDisposable
{
internal const int CRYPTO_BLOCK_SIZE = 16;
private readonly string password;
private readonly byte[] salt;
private byte[] aesInitializationVector;
private Rijndael rijndael;
private RarRijndael(string password, byte[] salt)
{
this.password = password;
this.salt = salt;
}
private void Initialize()
{
rijndael = new RijndaelManaged() { Padding = PaddingMode.None };
aesInitializationVector = new byte[CRYPTO_BLOCK_SIZE];
int rawLength = 2 * password.Length;
byte[] rawPassword = new byte[rawLength + 8];
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
for (int i = 0; i < password.Length; i++)
{
rawPassword[i * 2] = passwordBytes[i];
rawPassword[i * 2 + 1] = 0;
}
for (int i = 0; i < salt.Length; i++)
{
rawPassword[i + rawLength] = salt[i];
}
SHA1 sha = new SHA1CryptoServiceProvider();
const int noOfRounds = (1 << 18);
IList<byte> bytes = new List<byte>();
byte[] digest;
//TODO slow code below, find ways to optimize
for (int i = 0; i < noOfRounds; i++)
{
bytes.AddRange(rawPassword);
bytes.AddRange(new[] { (byte)i, (byte)(i >> 8), (byte)(i >> CRYPTO_BLOCK_SIZE) });
if (i % (noOfRounds / CRYPTO_BLOCK_SIZE) == 0)
{
digest = sha.ComputeHash(bytes.ToArray());
aesInitializationVector[i / (noOfRounds / CRYPTO_BLOCK_SIZE)] = digest[19];
}
}
digest = sha.ComputeHash(bytes.ToArray());
//slow code ends
byte[] aesKey = new byte[CRYPTO_BLOCK_SIZE];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
aesKey[i * 4 + j] = (byte)
(((digest[i * 4] * 0x1000000) & 0xff000000 |
(uint)((digest[i * 4 + 1] * 0x10000) & 0xff0000) |
(uint)((digest[i * 4 + 2] * 0x100) & 0xff00) |
(uint)(digest[i * 4 + 3] & 0xff)) >> (j * 8));
rijndael.IV = new byte[CRYPTO_BLOCK_SIZE];
rijndael.Key = aesKey;
rijndael.BlockSize = CRYPTO_BLOCK_SIZE * 8;
}
public static RarRijndael InitializeFrom(string password, byte[] salt)
{
var rijndael = new RarRijndael(password, salt);
rijndael.Initialize();
return rijndael;
}
public byte[] ProcessBlock(byte[] cipherText)
{
var plainText = new byte[CRYPTO_BLOCK_SIZE];
var decryptedBytes = new List<byte>();
var decryptor = rijndael.CreateDecryptor();
using (var msDecrypt = new MemoryStream(cipherText))
{
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
csDecrypt.ReadFully(plainText);
}
}
for (int j = 0; j < plainText.Length; j++)
decryptedBytes.Add((byte)(plainText[j] ^ aesInitializationVector[j % 16])); //32:114, 33:101
for (int j = 0; j < aesInitializationVector.Length; j++)
aesInitializationVector[j] = cipherText[j];
return decryptedBytes.ToArray();
}
public void Dispose()
{
rijndael.Dispose();
}
}
}

View File

@@ -1,84 +0,0 @@
using System;
using System.Collections.Generic;
namespace SharpCompress.Common.SevenZip
{
public class SevenZipEntry : Entry
{
internal SevenZipEntry(SevenZipFilePart filePart)
{
this.FilePart = filePart;
}
internal SevenZipFilePart FilePart { get; private set; }
public override CompressionType CompressionType
{
get { return FilePart.CompressionType; }
}
public override uint Crc
{
get { return FilePart.Header.Crc ?? 0; }
}
public override string FilePath
{
get { return FilePart.Header.Name; }
}
public override long CompressedSize
{
get { return 0; }
}
public override long Size
{
get { return (long) FilePart.Header.Size; }
}
public override DateTime? LastModifiedTime
{
get { throw new NotImplementedException(); }
}
public override DateTime? CreatedTime
{
get { throw new NotImplementedException(); }
}
public override DateTime? LastAccessedTime
{
get { throw new NotImplementedException(); }
}
public override DateTime? ArchivedTime
{
get { throw new NotImplementedException(); }
}
public override bool IsEncrypted
{
get { return false; }
}
public override bool IsDirectory
{
get { return FilePart.Header.IsDir; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { return FilePart.AsEnumerable<FilePart>(); }
}
internal override void Close()
{
}
}
}

View File

@@ -1,19 +0,0 @@
using System.IO;
namespace SharpCompress.Common.SevenZip
{
public class SevenZipVolume : GenericVolume
{
public SevenZipVolume(Stream stream, Options options)
: base(stream, options)
{
}
#if !PORTABLE && !NETFX_CORE
public SevenZipVolume(FileInfo fileInfo, Options options)
: base(fileInfo, options)
{
}
#endif
}
}

View File

@@ -1,108 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using SharpCompress.Common.Tar.Headers;
using SharpCompress.IO;
namespace SharpCompress.Common.Tar
{
public class TarEntry : Entry
{
private readonly TarFilePart filePart;
private readonly CompressionType type;
internal TarEntry(TarFilePart filePart, CompressionType type)
{
this.filePart = filePart;
this.type = type;
}
public override CompressionType CompressionType
{
get { return type; }
}
public override uint Crc
{
get { return 0; }
}
public override string FilePath
{
get { return filePart.Header.Name; }
}
public override long CompressedSize
{
get { return filePart.Header.Size; }
}
public override long Size
{
get { return filePart.Header.Size; }
}
public override DateTime? LastModifiedTime
{
get { return filePart.Header.LastModifiedTime; }
}
public override DateTime? CreatedTime
{
get { return null; }
}
public override DateTime? LastAccessedTime
{
get { return null; }
}
public override DateTime? ArchivedTime
{
get { return null; }
}
public override bool IsEncrypted
{
get { return false; }
}
public override bool IsDirectory
{
get { return filePart.Header.EntryType == EntryType.Directory; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { return filePart.AsEnumerable<FilePart>(); }
}
internal static IEnumerable<TarEntry> GetEntries(StreamingMode mode, Stream stream,
CompressionType compressionType)
{
foreach (TarHeader h in TarHeaderFactory.ReadHeader(mode, stream))
{
if (h != null)
{
if (mode == StreamingMode.Seekable)
{
yield return new TarEntry(new TarFilePart(h, stream), compressionType);
}
else
{
yield return new TarEntry(new TarFilePart(h, null), compressionType);
}
}
}
}
internal override void Close()
{
}
}
}

View File

@@ -1,19 +0,0 @@
using System.IO;
namespace SharpCompress.Common.Tar
{
public class TarVolume : GenericVolume
{
public TarVolume(Stream stream, Options options)
: base(stream, options)
{
}
#if !PORTABLE && !NETFX_CORE
public TarVolume(FileInfo fileInfo, Options options)
: base(fileInfo, options)
{
}
#endif
}
}

View File

@@ -1,170 +0,0 @@
using System;
using System.IO;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace SharpCompress.Common.Zip
{
internal class WinzipAesCryptoStream : Stream
{
private const int BLOCK_SIZE_IN_BYTES = 16;
private readonly IBufferedCipher rijndael;
private readonly byte[] counter = new byte[BLOCK_SIZE_IN_BYTES];
private readonly Stream stream;
private int nonce = 1;
private byte[] counterOut = new byte[BLOCK_SIZE_IN_BYTES];
private bool isFinalBlock;
private long totalBytesLeftToRead;
private bool isDisposed;
internal WinzipAesCryptoStream(Stream stream, WinzipAesEncryptionData winzipAesEncryptionData, long length)
{
this.stream = stream;
totalBytesLeftToRead = length;
rijndael = CreateRijndael(winzipAesEncryptionData);
}
private IBufferedCipher CreateRijndael(WinzipAesEncryptionData winzipAesEncryptionData)
{
var blockCipher = new BufferedBlockCipher(new RijndaelEngine());
var param = new KeyParameter(winzipAesEncryptionData.KeyBytes);
blockCipher.Init(true, param);
return blockCipher;
}
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return false; }
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override long Position
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
protected override void Dispose(bool disposing)
{
if (isDisposed)
{
return;
}
isDisposed = true;
if (disposing)
{
//read out last 10 auth bytes
var ten = new byte[10];
stream.Read(ten, 0, 10);
stream.Dispose();
}
}
public override void Flush()
{
throw new NotImplementedException();
}
public override int Read(byte[] buffer, int offset, int count)
{
if (totalBytesLeftToRead == 0)
{
return 0;
}
int bytesToRead = count;
if (count > totalBytesLeftToRead)
{
bytesToRead = (int)totalBytesLeftToRead;
}
int read = stream.Read(buffer, offset, bytesToRead);
totalBytesLeftToRead -= read;
ReadTransformBlocks(buffer, offset, read);
return read;
}
private int ReadTransformOneBlock(byte[] buffer, int offset, int last)
{
if (isFinalBlock)
{
throw new InvalidOperationException();
}
int bytesRemaining = last - offset;
int bytesToRead = (bytesRemaining > BLOCK_SIZE_IN_BYTES)
? BLOCK_SIZE_IN_BYTES
: bytesRemaining;
// update the counter
Array.Copy(BitConverter.GetBytes(nonce++), 0, counter, 0, 4);
// Determine if this is the final block
if ((bytesToRead == bytesRemaining) && (totalBytesLeftToRead == 0))
{
counterOut = rijndael.DoFinal(counter, 0, BLOCK_SIZE_IN_BYTES);
isFinalBlock = true;
}
else
{
rijndael.ProcessBytes(counter, 0, BLOCK_SIZE_IN_BYTES, counterOut, 0);
}
XorInPlace(buffer, offset, bytesToRead);
return bytesToRead;
}
private void XorInPlace(byte[] buffer, int offset, int count)
{
for (int i = 0; i < count; i++)
{
buffer[offset + i] = (byte)(counterOut[i] ^ buffer[offset + i]);
}
}
private void ReadTransformBlocks(byte[] buffer, int offset, int count)
{
int posn = offset;
int last = count + offset;
while (posn < buffer.Length && posn < last)
{
int n = ReadTransformOneBlock(buffer, posn, last);
posn += n;
}
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,68 +0,0 @@
using System;
using System.Text;
using SharpCompress.Crypto;
namespace SharpCompress.Common.Zip
{
internal class WinzipAesEncryptionData
{
private const int RFC2898_ITERATIONS = 1000;
private byte[] salt;
private WinzipAesKeySize keySize;
private byte[] passwordVerifyValue;
private string password;
private byte[] generatedVerifyValue;
internal WinzipAesEncryptionData(WinzipAesKeySize keySize, byte[] salt, byte[] passwordVerifyValue,
string password)
{
this.keySize = keySize;
this.salt = salt;
this.passwordVerifyValue = passwordVerifyValue;
this.password = password;
Initialize();
}
internal byte[] IvBytes { get; set; }
internal byte[] KeyBytes { get; set; }
private int KeySizeInBytes
{
get { return KeyLengthInBytes(keySize); }
}
internal static int KeyLengthInBytes(WinzipAesKeySize keySize)
{
switch (keySize)
{
case WinzipAesKeySize.KeySize128:
return 16;
case WinzipAesKeySize.KeySize192:
return 24;
case WinzipAesKeySize.KeySize256:
return 32;
}
throw new InvalidOperationException();
}
private void Initialize()
{
var utf8 = new UTF8Encoding(false);
var paramz = new PBKDF2(utf8.GetBytes(password), salt, RFC2898_ITERATIONS);
KeyBytes = paramz.GetBytes(KeySizeInBytes);
IvBytes = paramz.GetBytes(KeySizeInBytes);
generatedVerifyValue = paramz.GetBytes(2);
short verify = BitConverter.ToInt16(passwordVerifyValue, 0);
if (password != null)
{
short generated = BitConverter.ToInt16(generatedVerifyValue, 0);
if (verify != generated)
throw new InvalidFormatException("bad password");
}
}
}
}

View File

@@ -1,120 +0,0 @@
using System;
using System.Collections.Generic;
using SharpCompress.Common.Zip.Headers;
namespace SharpCompress.Common.Zip
{
public class ZipEntry : Entry
{
private readonly ZipFilePart filePart;
private readonly DateTime? lastModifiedTime;
internal ZipEntry(ZipFilePart filePart)
{
if (filePart != null)
{
this.filePart = filePart;
lastModifiedTime = Utility.DosDateToDateTime(filePart.Header.LastModifiedDate,
filePart.Header.LastModifiedTime);
}
}
public override CompressionType CompressionType
{
get
{
switch (filePart.Header.CompressionMethod)
{
case ZipCompressionMethod.BZip2:
{
return CompressionType.BZip2;
}
case ZipCompressionMethod.Deflate:
{
return CompressionType.Deflate;
}
case ZipCompressionMethod.LZMA:
{
return CompressionType.LZMA;
}
case ZipCompressionMethod.PPMd:
{
return CompressionType.PPMd;
}
case ZipCompressionMethod.None:
{
return CompressionType.None;
}
default:
{
return CompressionType.Unknown;
}
}
}
}
public override uint Crc
{
get { return filePart.Header.Crc; }
}
public override string FilePath
{
get { return filePart.Header.Name; }
}
public override long CompressedSize
{
get { return filePart.Header.CompressedSize; }
}
public override long Size
{
get { return filePart.Header.UncompressedSize; }
}
public override DateTime? LastModifiedTime
{
get { return lastModifiedTime; }
}
public override DateTime? CreatedTime
{
get { return null; }
}
public override DateTime? LastAccessedTime
{
get { return null; }
}
public override DateTime? ArchivedTime
{
get { return null; }
}
public override bool IsEncrypted
{
get { return FlagUtility.HasFlag(filePart.Header.Flags, HeaderFlags.Encrypted); }
}
public override bool IsDirectory
{
get { return filePart.Header.IsDirectory; }
}
public override bool IsSplit
{
get { return false; }
}
internal override IEnumerable<FilePart> Parts
{
get { return filePart.AsEnumerable<FilePart>(); }
}
internal override void Close()
{
}
}
}

View File

@@ -1,169 +0,0 @@
using System;
using System.IO;
using System.Linq;
using SharpCompress.Common.Zip.Headers;
using SharpCompress.Compressor;
using SharpCompress.Compressor.BZip2;
using SharpCompress.Compressor.Deflate;
using SharpCompress.Compressor.LZMA;
using SharpCompress.Compressor.PPMd;
using SharpCompress.IO;
namespace SharpCompress.Common.Zip
{
internal abstract class ZipFilePart : FilePart
{
internal ZipFilePart(ZipFileEntry header, Stream stream)
{
Header = header;
header.Part = this;
this.BaseStream = stream;
}
internal Stream BaseStream { get; private set; }
internal ZipFileEntry Header { get; set; }
internal override string FilePartName
{
get { return Header.Name; }
}
internal override Stream GetCompressedStream()
{
if (!Header.HasData)
{
return Stream.Null;
}
Stream decompressionStream = CreateDecompressionStream(GetCryptoStream(CreateBaseStream()));
if (LeaveStreamOpen)
{
return new NonDisposingStream(decompressionStream);
}
return decompressionStream;
}
internal override Stream GetRawStream()
{
if (!Header.HasData)
{
return Stream.Null;
}
return CreateBaseStream();
}
protected abstract Stream CreateBaseStream();
protected bool LeaveStreamOpen
{
get { return FlagUtility.HasFlag(Header.Flags, HeaderFlags.UsePostDataDescriptor); }
}
protected Stream CreateDecompressionStream(Stream stream)
{
switch (Header.CompressionMethod)
{
case ZipCompressionMethod.None:
{
return stream;
}
case ZipCompressionMethod.Deflate:
{
return new DeflateStream(stream, CompressionMode.Decompress);
}
case ZipCompressionMethod.BZip2:
{
return new BZip2Stream(stream, CompressionMode.Decompress);
}
case ZipCompressionMethod.LZMA:
{
if (FlagUtility.HasFlag(Header.Flags, HeaderFlags.Encrypted))
{
throw new NotSupportedException("LZMA with pkware encryption.");
}
var reader = new BinaryReader(stream);
reader.ReadUInt16(); //LZMA version
var props = new byte[reader.ReadUInt16()];
reader.Read(props, 0, props.Length);
return new LzmaStream(props, stream,
Header.CompressedSize > 0 ? Header.CompressedSize - 4 - props.Length : -1,
FlagUtility.HasFlag(Header.Flags, HeaderFlags.Bit1)
? -1
: (long)Header.UncompressedSize);
}
case ZipCompressionMethod.PPMd:
{
var props = new byte[2];
stream.Read(props, 0, props.Length);
return new PpmdStream(new PpmdProperties(props), stream, false);
}
case ZipCompressionMethod.WinzipAes:
{
ExtraData data = Header.Extra.Where(x => x.Type == ExtraDataType.WinZipAes).SingleOrDefault();
if (data == null)
{
throw new InvalidFormatException("No Winzip AES extra data found.");
}
if (data.Length != 7)
{
throw new InvalidFormatException("Winzip data length is not 7.");
}
ushort method = BitConverter.ToUInt16(data.DataBytes, 0);
if (method != 0x01 && method != 0x02)
{
throw new InvalidFormatException("Unexpected vendor version number for WinZip AES metadata");
}
ushort vendorId = BitConverter.ToUInt16(data.DataBytes, 2);
if (vendorId != 0x4541)
{
throw new InvalidFormatException("Unexpected vendor ID for WinZip AES metadata");
}
Header.CompressionMethod = (ZipCompressionMethod)BitConverter.ToUInt16(data.DataBytes, 5);
return CreateDecompressionStream(stream);
}
default:
{
throw new NotSupportedException("CompressionMethod: " + Header.CompressionMethod);
}
}
}
protected Stream GetCryptoStream(Stream plainStream)
{
if ((Header.CompressedSize == 0)
#if !PORTABLE && !NETFX_CORE
&& ((Header.PkwareTraditionalEncryptionData != null)
|| (Header.WinzipAesEncryptionData != null)))
#else
&& (Header.PkwareTraditionalEncryptionData != null))
#endif
{
throw new NotSupportedException("Cannot encrypt file with unknown size at start.");
}
if ((Header.CompressedSize == 0)
&& FlagUtility.HasFlag(Header.Flags, HeaderFlags.UsePostDataDescriptor))
{
plainStream = new NonDisposingStream(plainStream); //make sure AES doesn't close
}
else
{
plainStream = new ReadOnlySubStream(plainStream, Header.CompressedSize); //make sure AES doesn't close
}
if (Header.PkwareTraditionalEncryptionData != null)
{
return new PkwareTraditionalCryptoStream(plainStream, Header.PkwareTraditionalEncryptionData,
CryptoMode.Decrypt);
}
#if !PORTABLE && !NETFX_CORE
if (Header.WinzipAesEncryptionData != null)
{
//only read 10 less because the last ten are auth bytes
return new WinzipAesCryptoStream(plainStream, Header.WinzipAesEncryptionData, Header.CompressedSize - 10);
}
#endif
return plainStream;
}
}
}

View File

@@ -1,187 +0,0 @@
using System;
using System.IO;
using SharpCompress.Common.Zip.Headers;
using SharpCompress.IO;
#if !PORTABLE
using System.Linq;
#endif
namespace SharpCompress.Common.Zip
{
internal class ZipHeaderFactory
{
internal const uint ENTRY_HEADER_BYTES = 0x04034b50;
internal const uint POST_DATA_DESCRIPTOR = 0x08074b50;
internal const uint DIRECTORY_START_HEADER_BYTES = 0x02014b50;
internal const uint DIRECTORY_END_HEADER_BYTES = 0x06054b50;
internal const uint DIGITAL_SIGNATURE = 0x05054b50;
internal const uint SPLIT_ARCHIVE_HEADER_BYTES = 0x30304b50;
private const uint ZIP64_END_OF_CENTRAL_DIRECTORY = 0x06064b50;
private const uint ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR = 0x07064b50;
protected LocalEntryHeader lastEntryHeader;
private string password;
private StreamingMode mode;
protected ZipHeaderFactory(StreamingMode mode, string password)
{
this.mode = mode;
this.password = password;
}
protected ZipHeader ReadHeader(uint headerBytes, BinaryReader reader)
{
switch (headerBytes)
{
case ENTRY_HEADER_BYTES:
{
var entryHeader = new LocalEntryHeader();
entryHeader.Read(reader);
LoadHeader(entryHeader, reader.BaseStream);
lastEntryHeader = entryHeader;
return entryHeader;
}
case DIRECTORY_START_HEADER_BYTES:
{
var entry = new DirectoryEntryHeader();
entry.Read(reader);
return entry;
}
case POST_DATA_DESCRIPTOR:
{
if (FlagUtility.HasFlag(lastEntryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
{
lastEntryHeader.Crc = reader.ReadUInt32();
lastEntryHeader.CompressedSize = reader.ReadUInt32();
lastEntryHeader.UncompressedSize = reader.ReadUInt32();
}
else
{
reader.ReadUInt32();
reader.ReadUInt32();
reader.ReadUInt32();
}
return null;
}
case DIGITAL_SIGNATURE:
return null;
case DIRECTORY_END_HEADER_BYTES:
{
var entry = new DirectoryEndHeader();
entry.Read(reader);
return entry;
}
case SPLIT_ARCHIVE_HEADER_BYTES:
{
return new SplitHeader();
}
case ZIP64_END_OF_CENTRAL_DIRECTORY:
case ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR:
{
var entry = new IgnoreHeader(ZipHeaderType.Ignore);
entry.Read(reader);
return entry;
}
default:
throw new NotSupportedException("Unknown header: " + headerBytes);
}
}
internal static bool IsHeader(uint headerBytes)
{
switch (headerBytes)
{
case ENTRY_HEADER_BYTES:
case DIRECTORY_START_HEADER_BYTES:
case POST_DATA_DESCRIPTOR:
case DIGITAL_SIGNATURE:
case DIRECTORY_END_HEADER_BYTES:
case SPLIT_ARCHIVE_HEADER_BYTES:
case ZIP64_END_OF_CENTRAL_DIRECTORY:
case ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR:
return true;
default:
return false;
}
}
private void LoadHeader(ZipFileEntry entryHeader, Stream stream)
{
if (FlagUtility.HasFlag(entryHeader.Flags, HeaderFlags.Encrypted))
{
if (!entryHeader.IsDirectory &&
entryHeader.CompressedSize == 0 &&
FlagUtility.HasFlag(entryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
{
throw new NotSupportedException(
"SharpCompress cannot currently read non-seekable Zip Streams with encrypted data that has been written in a non-seekable manner.");
}
if (password == null)
{
throw new CryptographicException("No password supplied for encrypted zip.");
}
if (entryHeader.CompressionMethod != ZipCompressionMethod.WinzipAes)
{
byte[] buffer = new byte[12];
stream.Read(buffer, 0, 12);
entryHeader.PkwareTraditionalEncryptionData = PkwareTraditionalEncryptionData.ForRead(password,
entryHeader,
buffer);
entryHeader.CompressedSize -= 12;
}
else
{
#if PORTABLE || NETFX_CORE
throw new NotSupportedException("Cannot decrypt Winzip AES with Silverlight or WP7.");
#else
var data = entryHeader.Extra.Where(x => x.Type == ExtraDataType.WinZipAes).SingleOrDefault();
WinzipAesKeySize keySize = (WinzipAesKeySize) data.DataBytes[4];
byte[] salt = new byte[WinzipAesEncryptionData.KeyLengthInBytes(keySize)/2];
byte[] passwordVerifyValue = new byte[2];
stream.Read(salt, 0, salt.Length);
stream.Read(passwordVerifyValue, 0, 2);
entryHeader.WinzipAesEncryptionData = new WinzipAesEncryptionData(keySize, salt, passwordVerifyValue,
password);
entryHeader.CompressedSize -= (uint) (salt.Length + 2);
#endif
}
}
if (entryHeader.IsDirectory)
{
return;
}
//if (FlagUtility.HasFlag(entryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
//{
// entryHeader.PackedStream = new ReadOnlySubStream(stream);
//}
//else
//{
switch (mode)
{
case StreamingMode.Seekable:
{
entryHeader.DataStartPosition = stream.Position;
stream.Position += entryHeader.CompressedSize;
}
break;
case StreamingMode.Streaming:
{
entryHeader.PackedStream = stream;
}
break;
default:
{
throw new InvalidFormatException("Invalid StreamingMode");
}
}
//}
}
}
}

View File

@@ -1,21 +0,0 @@
using System.IO;
namespace SharpCompress.Common.Zip
{
public class ZipVolume : GenericVolume
{
public ZipVolume(Stream stream, Options options)
: base(stream, options)
{
}
#if !PORTABLE && !NETFX_CORE
public ZipVolume(FileInfo fileInfo, Options options)
: base(fileInfo, options)
{
}
#endif
public string Comment { get; internal set; }
}
}

View File

@@ -1,101 +0,0 @@
/*
* Copyright 2001,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* This package is based on the work done by Keiron Liddle, Aftex Software
* <keiron@aftexsw.com> to whom the Ant project is very grateful for his
* great code.
*/
namespace SharpCompress.Compressor.BZip2
{
/**
* Base class for both the compress and decompress classes.
* Holds common arrays, and static data.
*
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
*/
internal class BZip2Constants
{
public const int baseBlockSize = 100000;
public const int MAX_ALPHA_SIZE = 258;
public const int MAX_CODE_LEN = 23;
public const int RUNA = 0;
public const int RUNB = 1;
public const int N_GROUPS = 6;
public const int G_SIZE = 50;
public const int N_ITERS = 4;
public const int MAX_SELECTORS = (2 + (900000/G_SIZE));
public const int NUM_OVERSHOOT_BYTES = 20;
public static int[] rNums =
{
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638
};
}
}

View File

@@ -1,203 +0,0 @@
/*
* Copyright 2001,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* This package is based on the work done by Keiron Liddle), Aftex Software
* <keiron@aftexsw.com> to whom the Ant project is very grateful for his
* great code.
*/
namespace SharpCompress.Compressor.BZip2
{
/**
* A simple class the hold and calculate the CRC for sanity checking
* of the data.
*
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
*/
internal class CRC
{
public static int[] crc32Table =
{
unchecked((int) 0x00000000), unchecked((int) 0x04c11db7), unchecked((int) 0x09823b6e),
unchecked((int) 0x0d4326d9),
unchecked((int) 0x130476dc), unchecked((int) 0x17c56b6b), unchecked((int) 0x1a864db2),
unchecked((int) 0x1e475005),
unchecked((int) 0x2608edb8), unchecked((int) 0x22c9f00f), unchecked((int) 0x2f8ad6d6),
unchecked((int) 0x2b4bcb61),
unchecked((int) 0x350c9b64), unchecked((int) 0x31cd86d3), unchecked((int) 0x3c8ea00a),
unchecked((int) 0x384fbdbd),
unchecked((int) 0x4c11db70), unchecked((int) 0x48d0c6c7), unchecked((int) 0x4593e01e),
unchecked((int) 0x4152fda9),
unchecked((int) 0x5f15adac), unchecked((int) 0x5bd4b01b), unchecked((int) 0x569796c2),
unchecked((int) 0x52568b75),
unchecked((int) 0x6a1936c8), unchecked((int) 0x6ed82b7f), unchecked((int) 0x639b0da6),
unchecked((int) 0x675a1011),
unchecked((int) 0x791d4014), unchecked((int) 0x7ddc5da3), unchecked((int) 0x709f7b7a),
unchecked((int) 0x745e66cd),
unchecked((int) 0x9823b6e0), unchecked((int) 0x9ce2ab57), unchecked((int) 0x91a18d8e),
unchecked((int) 0x95609039),
unchecked((int) 0x8b27c03c), unchecked((int) 0x8fe6dd8b), unchecked((int) 0x82a5fb52),
unchecked((int) 0x8664e6e5),
unchecked((int) 0xbe2b5b58), unchecked((int) 0xbaea46ef), unchecked((int) 0xb7a96036),
unchecked((int) 0xb3687d81),
unchecked((int) 0xad2f2d84), unchecked((int) 0xa9ee3033), unchecked((int) 0xa4ad16ea),
unchecked((int) 0xa06c0b5d),
unchecked((int) 0xd4326d90), unchecked((int) 0xd0f37027), unchecked((int) 0xddb056fe),
unchecked((int) 0xd9714b49),
unchecked((int) 0xc7361b4c), unchecked((int) 0xc3f706fb), unchecked((int) 0xceb42022),
unchecked((int) 0xca753d95),
unchecked((int) 0xf23a8028), unchecked((int) 0xf6fb9d9f), unchecked((int) 0xfbb8bb46),
unchecked((int) 0xff79a6f1),
unchecked((int) 0xe13ef6f4), unchecked((int) 0xe5ffeb43), unchecked((int) 0xe8bccd9a),
unchecked((int) 0xec7dd02d),
unchecked((int) 0x34867077), unchecked((int) 0x30476dc0), unchecked((int) 0x3d044b19),
unchecked((int) 0x39c556ae),
unchecked((int) 0x278206ab), unchecked((int) 0x23431b1c), unchecked((int) 0x2e003dc5),
unchecked((int) 0x2ac12072),
unchecked((int) 0x128e9dcf), unchecked((int) 0x164f8078), unchecked((int) 0x1b0ca6a1),
unchecked((int) 0x1fcdbb16),
unchecked((int) 0x018aeb13), unchecked((int) 0x054bf6a4), unchecked((int) 0x0808d07d),
unchecked((int) 0x0cc9cdca),
unchecked((int) 0x7897ab07), unchecked((int) 0x7c56b6b0), unchecked((int) 0x71159069),
unchecked((int) 0x75d48dde),
unchecked((int) 0x6b93dddb), unchecked((int) 0x6f52c06c), unchecked((int) 0x6211e6b5),
unchecked((int) 0x66d0fb02),
unchecked((int) 0x5e9f46bf), unchecked((int) 0x5a5e5b08), unchecked((int) 0x571d7dd1),
unchecked((int) 0x53dc6066),
unchecked((int) 0x4d9b3063), unchecked((int) 0x495a2dd4), unchecked((int) 0x44190b0d),
unchecked((int) 0x40d816ba),
unchecked((int) 0xaca5c697), unchecked((int) 0xa864db20), unchecked((int) 0xa527fdf9),
unchecked((int) 0xa1e6e04e),
unchecked((int) 0xbfa1b04b), unchecked((int) 0xbb60adfc), unchecked((int) 0xb6238b25),
unchecked((int) 0xb2e29692),
unchecked((int) 0x8aad2b2f), unchecked((int) 0x8e6c3698), unchecked((int) 0x832f1041),
unchecked((int) 0x87ee0df6),
unchecked((int) 0x99a95df3), unchecked((int) 0x9d684044), unchecked((int) 0x902b669d),
unchecked((int) 0x94ea7b2a),
unchecked((int) 0xe0b41de7), unchecked((int) 0xe4750050), unchecked((int) 0xe9362689),
unchecked((int) 0xedf73b3e),
unchecked((int) 0xf3b06b3b), unchecked((int) 0xf771768c), unchecked((int) 0xfa325055),
unchecked((int) 0xfef34de2),
unchecked((int) 0xc6bcf05f), unchecked((int) 0xc27dede8), unchecked((int) 0xcf3ecb31),
unchecked((int) 0xcbffd686),
unchecked((int) 0xd5b88683), unchecked((int) 0xd1799b34), unchecked((int) 0xdc3abded),
unchecked((int) 0xd8fba05a),
unchecked((int) 0x690ce0ee), unchecked((int) 0x6dcdfd59), unchecked((int) 0x608edb80),
unchecked((int) 0x644fc637),
unchecked((int) 0x7a089632), unchecked((int) 0x7ec98b85), unchecked((int) 0x738aad5c),
unchecked((int) 0x774bb0eb),
unchecked((int) 0x4f040d56), unchecked((int) 0x4bc510e1), unchecked((int) 0x46863638),
unchecked((int) 0x42472b8f),
unchecked((int) 0x5c007b8a), unchecked((int) 0x58c1663d), unchecked((int) 0x558240e4),
unchecked((int) 0x51435d53),
unchecked((int) 0x251d3b9e), unchecked((int) 0x21dc2629), unchecked((int) 0x2c9f00f0),
unchecked((int) 0x285e1d47),
unchecked((int) 0x36194d42), unchecked((int) 0x32d850f5), unchecked((int) 0x3f9b762c),
unchecked((int) 0x3b5a6b9b),
unchecked((int) 0x0315d626), unchecked((int) 0x07d4cb91), unchecked((int) 0x0a97ed48),
unchecked((int) 0x0e56f0ff),
unchecked((int) 0x1011a0fa), unchecked((int) 0x14d0bd4d), unchecked((int) 0x19939b94),
unchecked((int) 0x1d528623),
unchecked((int) 0xf12f560e), unchecked((int) 0xf5ee4bb9), unchecked((int) 0xf8ad6d60),
unchecked((int) 0xfc6c70d7),
unchecked((int) 0xe22b20d2), unchecked((int) 0xe6ea3d65), unchecked((int) 0xeba91bbc),
unchecked((int) 0xef68060b),
unchecked((int) 0xd727bbb6), unchecked((int) 0xd3e6a601), unchecked((int) 0xdea580d8),
unchecked((int) 0xda649d6f),
unchecked((int) 0xc423cd6a), unchecked((int) 0xc0e2d0dd), unchecked((int) 0xcda1f604),
unchecked((int) 0xc960ebb3),
unchecked((int) 0xbd3e8d7e), unchecked((int) 0xb9ff90c9), unchecked((int) 0xb4bcb610),
unchecked((int) 0xb07daba7),
unchecked((int) 0xae3afba2), unchecked((int) 0xaafbe615), unchecked((int) 0xa7b8c0cc),
unchecked((int) 0xa379dd7b),
unchecked((int) 0x9b3660c6), unchecked((int) 0x9ff77d71), unchecked((int) 0x92b45ba8),
unchecked((int) 0x9675461f),
unchecked((int) 0x8832161a), unchecked((int) 0x8cf30bad), unchecked((int) 0x81b02d74),
unchecked((int) 0x857130c3),
unchecked((int) 0x5d8a9099), unchecked((int) 0x594b8d2e), unchecked((int) 0x5408abf7),
unchecked((int) 0x50c9b640),
unchecked((int) 0x4e8ee645), unchecked((int) 0x4a4ffbf2), unchecked((int) 0x470cdd2b),
unchecked((int) 0x43cdc09c),
unchecked((int) 0x7b827d21), unchecked((int) 0x7f436096), unchecked((int) 0x7200464f),
unchecked((int) 0x76c15bf8),
unchecked((int) 0x68860bfd), unchecked((int) 0x6c47164a), unchecked((int) 0x61043093),
unchecked((int) 0x65c52d24),
unchecked((int) 0x119b4be9), unchecked((int) 0x155a565e), unchecked((int) 0x18197087),
unchecked((int) 0x1cd86d30),
unchecked((int) 0x029f3d35), unchecked((int) 0x065e2082), unchecked((int) 0x0b1d065b),
unchecked((int) 0x0fdc1bec),
unchecked((int) 0x3793a651), unchecked((int) 0x3352bbe6), unchecked((int) 0x3e119d3f),
unchecked((int) 0x3ad08088),
unchecked((int) 0x2497d08d), unchecked((int) 0x2056cd3a), unchecked((int) 0x2d15ebe3),
unchecked((int) 0x29d4f654),
unchecked((int) 0xc5a92679), unchecked((int) 0xc1683bce), unchecked((int) 0xcc2b1d17),
unchecked((int) 0xc8ea00a0),
unchecked((int) 0xd6ad50a5), unchecked((int) 0xd26c4d12), unchecked((int) 0xdf2f6bcb),
unchecked((int) 0xdbee767c),
unchecked((int) 0xe3a1cbc1), unchecked((int) 0xe760d676), unchecked((int) 0xea23f0af),
unchecked((int) 0xeee2ed18),
unchecked((int) 0xf0a5bd1d), unchecked((int) 0xf464a0aa), unchecked((int) 0xf9278673),
unchecked((int) 0xfde69bc4),
unchecked((int) 0x89b8fd09), unchecked((int) 0x8d79e0be), unchecked((int) 0x803ac667),
unchecked((int) 0x84fbdbd0),
unchecked((int) 0x9abc8bd5), unchecked((int) 0x9e7d9662), unchecked((int) 0x933eb0bb),
unchecked((int) 0x97ffad0c),
unchecked((int) 0xafb010b1), unchecked((int) 0xab710d06), unchecked((int) 0xa6322bdf),
unchecked((int) 0xa2f33668),
unchecked((int) 0xbcb4666d), unchecked((int) 0xb8757bda), unchecked((int) 0xb5365d03),
unchecked((int) 0xb1f740b4)
};
public CRC()
{
InitialiseCRC();
}
internal void InitialiseCRC()
{
globalCrc = unchecked((int) 0xffffffff);
}
internal int GetFinalCRC()
{
return ~globalCrc;
}
internal int GetGlobalCRC()
{
return globalCrc;
}
internal void SetGlobalCRC(int newCrc)
{
globalCrc = newCrc;
}
internal void UpdateCRC(int inCh)
{
int temp = (globalCrc >> 24) ^ inCh;
if (temp < 0)
{
temp = 256 + temp;
}
globalCrc = (globalCrc << 8) ^ CRC.crc32Table[temp];
}
internal int globalCrc;
}
}

View File

@@ -1,464 +0,0 @@
// Tree.cs
// ------------------------------------------------------------------
//
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
// All rights reserved.
//
// This code module is part of DotNetZip, a zipfile class library.
//
// ------------------------------------------------------------------
//
// This code is licensed under the Microsoft Public License.
// See the file License.txt for the license details.
// More info on: http://dotnetzip.codeplex.com
//
// ------------------------------------------------------------------
//
// last saved (in emacs):
// Time-stamp: <2009-October-28 13:29:50>
//
// ------------------------------------------------------------------
//
// This module defines classes for zlib compression and
// decompression. This code is derived from the jzlib implementation of
// zlib. In keeping with the license for jzlib, the copyright to that
// code is below.
//
// ------------------------------------------------------------------
//
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. 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. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the distribution.
//
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 JCRAFT,
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE 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.
//
// -----------------------------------------------------------------------
//
// This program is based on zlib-1.1.3; credit to authors
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
// and contributors of zlib.
//
// -----------------------------------------------------------------------
using System;
namespace SharpCompress.Compressor.Deflate
{
internal sealed partial class DeflateManager
{
#region Nested type: Tree
private sealed class Tree
{
internal const int Buf_size = 8*2;
private static readonly int HEAP_SIZE = (2*InternalConstants.L_CODES + 1);
internal static readonly sbyte[] bl_order = new sbyte[]
{
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2,
14,
1, 15
};
// The lengths of the bit length codes are sent in order of decreasing
// probability, to avoid transmitting the lengths for unused bit
// length codes.
// see definition of array dist_code below
//internal const int DIST_CODE_LEN = 512;
private static readonly sbyte[] _dist_code = new sbyte[]
{
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15,
0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21,
21, 21,
22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
23, 23,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29
};
internal static readonly sbyte[] LengthCode = new sbyte[]
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15
, 15, 15,
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17
, 17, 17,
18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19
, 19, 19,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
, 20, 20,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21
, 21, 21,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22
, 22, 22,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23
, 23, 23,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
, 24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26
, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26
, 26, 26,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27
, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27
, 27, 28
};
internal static readonly int[] LengthBase = new[]
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0
};
internal static readonly int[] DistanceBase = new[]
{
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128,
192,
256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144
, 8192, 12288, 16384, 24576
};
internal short[] dyn_tree; // the dynamic tree
internal int max_code; // largest code with non zero frequency
internal StaticTree staticTree; // the corresponding static tree
/// <summary>
/// Map from a distance to a distance code.
/// </summary>
/// <remarks>
/// No side effects. _dist_code[256] and _dist_code[257] are never used.
/// </remarks>
internal static int DistanceCode(int dist)
{
return (dist < 256)
? _dist_code[dist]
: _dist_code[256 + SharedUtils.URShift(dist, 7)];
}
// Compute the optimal bit lengths for a tree and update the total bit length
// for the current block.
// IN assertion: the fields freq and dad are set, heap[heap_max] and
// above are the tree nodes sorted by increasing frequency.
// OUT assertions: the field len is set to the optimal bit length, the
// array bl_count contains the frequencies for each bit length.
// The length opt_len is updated; static_len is also updated if stree is
// not null.
internal void gen_bitlen(DeflateManager s)
{
short[] tree = dyn_tree;
short[] stree = staticTree.treeCodes;
int[] extra = staticTree.extraBits;
int base_Renamed = staticTree.extraBase;
int max_length = staticTree.maxLength;
int h; // heap index
int n, m; // iterate over the tree elements
int bits; // bit length
int xbits; // extra bits
short f; // frequency
int overflow = 0; // number of elements with bit length too large
for (bits = 0; bits <= InternalConstants.MAX_BITS; bits++)
s.bl_count[bits] = 0;
// In a first pass, compute the optimal bit lengths (which may
// overflow in the case of the bit length tree).
tree[s.heap[s.heap_max]*2 + 1] = 0; // root of the heap
for (h = s.heap_max + 1; h < HEAP_SIZE; h++)
{
n = s.heap[h];
bits = tree[tree[n*2 + 1]*2 + 1] + 1;
if (bits > max_length)
{
bits = max_length;
overflow++;
}
tree[n*2 + 1] = (short) bits;
// We overwrite tree[n*2+1] which is no longer needed
if (n > max_code)
continue; // not a leaf node
s.bl_count[bits]++;
xbits = 0;
if (n >= base_Renamed)
xbits = extra[n - base_Renamed];
f = tree[n*2];
s.opt_len += f*(bits + xbits);
if (stree != null)
s.static_len += f*(stree[n*2 + 1] + xbits);
}
if (overflow == 0)
return;
// This happens for example on obj2 and pic of the Calgary corpus
// Find the first bit length which could increase:
do
{
bits = max_length - 1;
while (s.bl_count[bits] == 0)
bits--;
s.bl_count[bits]--; // move one leaf down the tree
s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother
s.bl_count[max_length]--;
// The brother of the overflow item also moves one step up,
// but this does not affect bl_count[max_length]
overflow -= 2;
} while (overflow > 0);
for (bits = max_length; bits != 0; bits--)
{
n = s.bl_count[bits];
while (n != 0)
{
m = s.heap[--h];
if (m > max_code)
continue;
if (tree[m*2 + 1] != bits)
{
s.opt_len = (int) (s.opt_len + (bits - (long) tree[m*2 + 1])*tree[m*2]);
tree[m*2 + 1] = (short) bits;
}
n--;
}
}
}
// Construct one Huffman tree and assigns the code bit strings and lengths.
// Update the total bit length for the current block.
// IN assertion: the field freq is set for all tree elements.
// OUT assertions: the fields len and code are set to the optimal bit length
// and corresponding code. The length opt_len is updated; static_len is
// also updated if stree is not null. The field max_code is set.
internal void build_tree(DeflateManager s)
{
short[] tree = dyn_tree;
short[] stree = staticTree.treeCodes;
int elems = staticTree.elems;
int n, m; // iterate over heap elements
int max_code = -1; // largest code with non zero frequency
int node; // new node being created
// Construct the initial heap, with least frequent element in
// heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
// heap[0] is not used.
s.heap_len = 0;
s.heap_max = HEAP_SIZE;
for (n = 0; n < elems; n++)
{
if (tree[n*2] != 0)
{
s.heap[++s.heap_len] = max_code = n;
s.depth[n] = 0;
}
else
{
tree[n*2 + 1] = 0;
}
}
// The pkzip format requires that at least one distance code exists,
// and that at least one bit should be sent even if there is only one
// possible code. So to avoid special checks later on we force at least
// two codes of non zero frequency.
while (s.heap_len < 2)
{
node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);
tree[node*2] = 1;
s.depth[node] = 0;
s.opt_len--;
if (stree != null)
s.static_len -= stree[node*2 + 1];
// node is 0 or 1 so it does not have extra bits
}
this.max_code = max_code;
// The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
// establish sub-heaps of increasing lengths:
for (n = s.heap_len/2; n >= 1; n--)
s.pqdownheap(tree, n);
// Construct the Huffman tree by repeatedly combining the least two
// frequent nodes.
node = elems; // next internal node of the tree
do
{
// n = node of least frequency
n = s.heap[1];
s.heap[1] = s.heap[s.heap_len--];
s.pqdownheap(tree, 1);
m = s.heap[1]; // m = node of next least frequency
s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency
s.heap[--s.heap_max] = m;
// Create a new node father of n and m
tree[node*2] = unchecked((short) (tree[n*2] + tree[m*2]));
s.depth[node] = (sbyte) (Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1);
tree[n*2 + 1] = tree[m*2 + 1] = (short) node;
// and insert the new node in the heap
s.heap[1] = node++;
s.pqdownheap(tree, 1);
} while (s.heap_len >= 2);
s.heap[--s.heap_max] = s.heap[1];
// At this point, the fields freq and dad are set. We can now
// generate the bit lengths.
gen_bitlen(s);
// The field len is now set, we can generate the bit codes
gen_codes(tree, max_code, s.bl_count);
}
// Generate the codes for a given tree and bit counts (which need not be
// optimal).
// IN assertion: the array bl_count contains the bit length statistics for
// the given tree and the field len is set for all tree elements.
// OUT assertion: the field code is set for all tree elements of non
// zero code length.
internal static void gen_codes(short[] tree, int max_code, short[] bl_count)
{
var next_code = new short[InternalConstants.MAX_BITS + 1]; // next code value for each bit length
short code = 0; // running code value
int bits; // bit index
int n; // code index
// The distribution counts are first used to generate the code values
// without bit reversal.
for (bits = 1; bits <= InternalConstants.MAX_BITS; bits++)
unchecked
{
next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1);
}
// Check that the bit counts in bl_count are consistent. The last code
// must be all ones.
//Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
// "inconsistent bit counts");
//Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
for (n = 0; n <= max_code; n++)
{
int len = tree[n*2 + 1];
if (len == 0)
continue;
// Now reverse the bits
tree[n*2] = unchecked((short) (bi_reverse(next_code[len]++, len)));
}
}
// Reverse the first len bits of a code, using straightforward code (a faster
// method would use a table)
// IN assertion: 1 <= len <= 15
internal static int bi_reverse(int code, int len)
{
int res = 0;
do
{
res |= code & 1;
code >>= 1; //SharedUtils.URShift(code, 1);
res <<= 1;
} while (--len > 0);
return res >> 1;
}
}
#endregion
}
}

View File

@@ -1,55 +0,0 @@
namespace SharpCompress.Compressor.LZMA
{
public class LzmaEncoderProperties
{
internal CoderPropID[] propIDs;
internal object[] properties;
public LzmaEncoderProperties()
: this(false)
{
}
public LzmaEncoderProperties(bool eos)
: this(eos, 1 << 20)
{
}
public LzmaEncoderProperties(bool eos, int dictionary)
: this(eos, dictionary, 32)
{
}
public LzmaEncoderProperties(bool eos, int dictionary, int numFastBytes)
{
int posStateBits = 2;
int litContextBits = 3;
int litPosBits = 0;
int algorithm = 2;
string mf = "bt4";
propIDs = new CoderPropID[]
{
CoderPropID.DictionarySize,
CoderPropID.PosStateBits,
CoderPropID.LitContextBits,
CoderPropID.LitPosBits,
CoderPropID.Algorithm,
CoderPropID.NumFastBytes,
CoderPropID.MatchFinder,
CoderPropID.EndMarker
};
properties = new object[]
{
dictionary,
posStateBits,
litContextBits,
litPosBits,
algorithm,
numFastBytes,
mf,
eos
};
}
}
}

View File

@@ -1,8 +0,0 @@
namespace SharpCompress.Compressor.Rar.PPM
{
internal enum BlockTypes
{
BLOCK_LZ = 0,
BLOCK_PPM = 1,
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,46 +0,0 @@
namespace SharpCompress.Compressor.Rar.VM
{
internal class VMCmdFlags
{
public const byte VMCF_OP0 = 0;
public const byte VMCF_OP1 = 1;
public const byte VMCF_OP2 = 2;
public const byte VMCF_OPMASK = 3;
public const byte VMCF_BYTEMODE = 4;
public const byte VMCF_JUMP = 8;
public const byte VMCF_PROC = 16;
public const byte VMCF_USEFLAGS = 32;
public const byte VMCF_CHFLAGS = 64;
public static byte[] VM_CmdFlags = new byte[]
{
VMCF_OP2 | VMCF_BYTEMODE, VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS, VMCF_OP1 | VMCF_JUMP,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS,
VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS, VMCF_OP1, VMCF_OP1,
VMCF_OP1 | VMCF_PROC, VMCF_OP0 | VMCF_PROC, VMCF_OP1 | VMCF_BYTEMODE,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS, VMCF_OP0, VMCF_OP0,
VMCF_OP0 | VMCF_USEFLAGS, VMCF_OP0 | VMCF_CHFLAGS, VMCF_OP2, VMCF_OP2,
VMCF_OP2 | VMCF_BYTEMODE, VMCF_OP2 | VMCF_BYTEMODE,
VMCF_OP2 | VMCF_BYTEMODE,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS,
VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS, VMCF_OP0
};
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,376 +0,0 @@
using System;
namespace Org.BouncyCastle.Crypto
{
/**
* A wrapper class that allows block ciphers to be used to process data in
* a piecemeal fashion. The BufferedBlockCipher outputs a block only when the
* buffer is full and more data is being added, or on a doFinal.
* <p>
* Note: in the case where the underlying cipher is either a CFB cipher or an
* OFB one the last block may not be a multiple of the block size.
* </p>
*/
public class BufferedBlockCipher
: BufferedCipherBase
{
internal byte[] buf;
internal int bufOff;
internal bool forEncryption;
internal IBlockCipher cipher;
/**
* constructor for subclasses
*/
protected BufferedBlockCipher()
{
}
/**
* Create a buffered block cipher without padding.
*
* @param cipher the underlying block cipher this buffering object wraps.
* false otherwise.
*/
public BufferedBlockCipher(
IBlockCipher cipher)
{
if (cipher == null)
throw new ArgumentNullException("cipher");
this.cipher = cipher;
buf = new byte[cipher.GetBlockSize()];
bufOff = 0;
}
public override string AlgorithmName
{
get { return cipher.AlgorithmName; }
}
/**
* initialise the cipher.
*
* @param forEncryption if true the cipher is initialised for
* encryption, if false for decryption.
* @param param the key and other data required by the cipher.
* @exception ArgumentException if the parameters argument is
* inappropriate.
*/
// Note: This doubles as the Init in the event that this cipher is being used as an IWrapper
public override void Init(
bool forEncryption,
ICipherParameters parameters)
{
this.forEncryption = forEncryption;
//if (parameters is ParametersWithRandom)
//{
// parameters = ((ParametersWithRandom) parameters).Parameters;
//}
Reset();
cipher.Init(forEncryption, parameters);
}
/**
* return the blocksize for the underlying cipher.
*
* @return the blocksize for the underlying cipher.
*/
public override int GetBlockSize()
{
return cipher.GetBlockSize();
}
/**
* return the size of the output buffer required for an update
* an input of len bytes.
*
* @param len the length of the input.
* @return the space required to accommodate a call to update
* with len bytes of input.
*/
public override int GetUpdateOutputSize(
int length)
{
int total = length + bufOff;
int leftOver = total % buf.Length;
return total - leftOver;
}
/**
* return the size of the output buffer required for an update plus a
* doFinal with an input of len bytes.
*
* @param len the length of the input.
* @return the space required to accommodate a call to update and doFinal
* with len bytes of input.
*/
public override int GetOutputSize(
int length)
{
// Note: Can assume IsPartialBlockOkay is true for purposes of this calculation
return length + bufOff;
}
/**
* process a single byte, producing an output block if neccessary.
*
* @param in the input byte.
* @param out the space for any output that might be produced.
* @param outOff the offset from which the output will be copied.
* @return the number of output bytes copied to out.
* @exception DataLengthException if there isn't enough space in out.
* @exception InvalidOperationException if the cipher isn't initialised.
*/
public override int ProcessByte(
byte input,
byte[] output,
int outOff)
{
buf[bufOff++] = input;
if (bufOff == buf.Length)
{
if ((outOff + buf.Length) > output.Length)
throw new DataLengthException("output buffer too short");
bufOff = 0;
return cipher.ProcessBlock(buf, 0, output, outOff);
}
return 0;
}
public override byte[] ProcessByte(
byte input)
{
int outLength = GetUpdateOutputSize(1);
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
int pos = ProcessByte(input, outBytes, 0);
if (outLength > 0 && pos < outLength)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
return outBytes;
}
public override byte[] ProcessBytes(
byte[] input,
int inOff,
int length)
{
if (input == null)
throw new ArgumentNullException("input");
if (length < 1)
return null;
int outLength = GetUpdateOutputSize(length);
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
int pos = ProcessBytes(input, inOff, length, outBytes, 0);
if (outLength > 0 && pos < outLength)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
return outBytes;
}
/**
* process an array of bytes, producing output if necessary.
*
* @param in the input byte array.
* @param inOff the offset at which the input data starts.
* @param len the number of bytes to be copied out of the input array.
* @param out the space for any output that might be produced.
* @param outOff the offset from which the output will be copied.
* @return the number of output bytes copied to out.
* @exception DataLengthException if there isn't enough space in out.
* @exception InvalidOperationException if the cipher isn't initialised.
*/
public override int ProcessBytes(
byte[] input,
int inOff,
int length,
byte[] output,
int outOff)
{
if (length < 1)
{
if (length < 0)
throw new ArgumentException("Can't have a negative input length!");
return 0;
}
int blockSize = GetBlockSize();
int outLength = GetUpdateOutputSize(length);
if (outLength > 0)
{
if ((outOff + outLength) > output.Length)
{
throw new DataLengthException("output buffer too short");
}
}
int resultLen = 0;
int gapLen = buf.Length - bufOff;
if (length > gapLen)
{
Array.Copy(input, inOff, buf, bufOff, gapLen);
resultLen += cipher.ProcessBlock(buf, 0, output, outOff);
bufOff = 0;
length -= gapLen;
inOff += gapLen;
while (length > buf.Length)
{
resultLen += cipher.ProcessBlock(input, inOff, output, outOff + resultLen);
length -= blockSize;
inOff += blockSize;
}
}
Array.Copy(input, inOff, buf, bufOff, length);
bufOff += length;
if (bufOff == buf.Length)
{
resultLen += cipher.ProcessBlock(buf, 0, output, outOff + resultLen);
bufOff = 0;
}
return resultLen;
}
public override byte[] DoFinal()
{
byte[] outBytes = EmptyBuffer;
int length = GetOutputSize(0);
if (length > 0)
{
outBytes = new byte[length];
int pos = DoFinal(outBytes, 0);
if (pos < outBytes.Length)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
}
else
{
Reset();
}
return outBytes;
}
public override byte[] DoFinal(
byte[] input,
int inOff,
int inLen)
{
if (input == null)
throw new ArgumentNullException("input");
int length = GetOutputSize(inLen);
byte[] outBytes = EmptyBuffer;
if (length > 0)
{
outBytes = new byte[length];
int pos = (inLen > 0)
? ProcessBytes(input, inOff, inLen, outBytes, 0)
: 0;
pos += DoFinal(outBytes, pos);
if (pos < outBytes.Length)
{
byte[] tmp = new byte[pos];
Array.Copy(outBytes, 0, tmp, 0, pos);
outBytes = tmp;
}
}
else
{
Reset();
}
return outBytes;
}
/**
* Process the last block in the buffer.
*
* @param out the array the block currently being held is copied into.
* @param outOff the offset at which the copying starts.
* @return the number of output bytes copied to out.
* @exception DataLengthException if there is insufficient space in out for
* the output, or the input is not block size aligned and should be.
* @exception InvalidOperationException if the underlying cipher is not
* initialised.
* @exception InvalidCipherTextException if padding is expected and not found.
* @exception DataLengthException if the input is not block size
* aligned.
*/
public override int DoFinal(
byte[] output,
int outOff)
{
try
{
if (bufOff != 0)
{
if (!cipher.IsPartialBlockOkay)
{
throw new DataLengthException("data not block size aligned");
}
if (outOff + bufOff > output.Length)
{
throw new DataLengthException("output buffer too short for DoFinal()");
}
// NB: Can't copy directly, or we may write too much output
cipher.ProcessBlock(buf, 0, buf, 0);
Array.Copy(buf, 0, output, outOff, bufOff);
}
return bufOff;
}
finally
{
Reset();
}
}
/**
* Reset the buffer and cipher. After resetting the object is in the same
* state as it was after the last init (if there was one).
*/
public override void Reset()
{
Array.Clear(buf, 0, buf.Length);
bufOff = 0;
cipher.Reset();
}
}
}

View File

@@ -1,113 +0,0 @@
using System;
namespace Org.BouncyCastle.Crypto
{
public abstract class BufferedCipherBase
: IBufferedCipher
{
protected static readonly byte[] EmptyBuffer = new byte[0];
public abstract string AlgorithmName { get; }
public abstract void Init(bool forEncryption, ICipherParameters parameters);
public abstract int GetBlockSize();
public abstract int GetOutputSize(int inputLen);
public abstract int GetUpdateOutputSize(int inputLen);
public abstract byte[] ProcessByte(byte input);
public virtual int ProcessByte(
byte input,
byte[] output,
int outOff)
{
byte[] outBytes = ProcessByte(input);
if (outBytes == null)
return 0;
if (outOff + outBytes.Length > output.Length)
throw new DataLengthException("output buffer too short");
outBytes.CopyTo(output, outOff);
return outBytes.Length;
}
public virtual byte[] ProcessBytes(
byte[] input)
{
return ProcessBytes(input, 0, input.Length);
}
public abstract byte[] ProcessBytes(byte[] input, int inOff, int length);
public virtual int ProcessBytes(
byte[] input,
byte[] output,
int outOff)
{
return ProcessBytes(input, 0, input.Length, output, outOff);
}
public virtual int ProcessBytes(
byte[] input,
int inOff,
int length,
byte[] output,
int outOff)
{
byte[] outBytes = ProcessBytes(input, inOff, length);
if (outBytes == null)
return 0;
if (outOff + outBytes.Length > output.Length)
throw new DataLengthException("output buffer too short");
outBytes.CopyTo(output, outOff);
return outBytes.Length;
}
public abstract byte[] DoFinal();
public virtual byte[] DoFinal(
byte[] input)
{
return DoFinal(input, 0, input.Length);
}
public abstract byte[] DoFinal(
byte[] input,
int inOff,
int length);
public virtual int DoFinal(
byte[] output,
int outOff)
{
byte[] outBytes = DoFinal();
if (outOff + outBytes.Length > output.Length)
throw new DataLengthException("output buffer too short");
outBytes.CopyTo(output, outOff);
return outBytes.Length;
}
public virtual int DoFinal(
byte[] input,
byte[] output,
int outOff)
{
return DoFinal(input, 0, input.Length, output, outOff);
}
public virtual int DoFinal(
byte[] input,
int inOff,
int length,
byte[] output,
int outOff)
{
int len = ProcessBytes(input, inOff, length, output, outOff);
len += DoFinal(output, outOff + len);
return len;
}
public abstract void Reset();
}
}

View File

@@ -1,115 +0,0 @@
using System;
namespace Org.BouncyCastle.Crypto.Digests
{
public abstract class GeneralDigest
: IDigest
{
private const int BYTE_LENGTH = 64;
private byte[] xBuf;
private int xBufOff;
private long byteCount;
internal GeneralDigest()
{
xBuf = new byte[4];
}
internal GeneralDigest(GeneralDigest t)
{
xBuf = new byte[t.xBuf.Length];
Array.Copy(t.xBuf, 0, xBuf, 0, t.xBuf.Length);
xBufOff = t.xBufOff;
byteCount = t.byteCount;
}
public void Update(byte input)
{
xBuf[xBufOff++] = input;
if (xBufOff == xBuf.Length)
{
ProcessWord(xBuf, 0);
xBufOff = 0;
}
byteCount++;
}
public void BlockUpdate(
byte[] input,
int inOff,
int length)
{
//
// fill the current word
//
while ((xBufOff != 0) && (length > 0))
{
Update(input[inOff]);
inOff++;
length--;
}
//
// process whole words.
//
while (length > xBuf.Length)
{
ProcessWord(input, inOff);
inOff += xBuf.Length;
length -= xBuf.Length;
byteCount += xBuf.Length;
}
//
// load in the remainder.
//
while (length > 0)
{
Update(input[inOff]);
inOff++;
length--;
}
}
public void Finish()
{
long bitLength = (byteCount << 3);
//
// add the pad bytes.
//
Update((byte)128);
while (xBufOff != 0)
Update((byte)0);
ProcessLength(bitLength);
ProcessBlock();
}
public virtual void Reset()
{
byteCount = 0;
xBufOff = 0;
Array.Clear(xBuf, 0, xBuf.Length);
}
public int GetByteLength()
{
return BYTE_LENGTH;
}
internal abstract void ProcessWord(byte[] input, int inOff);
internal abstract void ProcessLength(long bitLength);
internal abstract void ProcessBlock();
public abstract string AlgorithmName { get; }
public abstract int GetDigestSize();
public abstract int DoFinal(byte[] output, int outOff);
}
}

View File

@@ -1,134 +0,0 @@
using System;
using System.Collections;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
namespace Org.BouncyCastle.Crypto.Macs
{
/**
* HMAC implementation based on RFC2104
*
* H(K XOR opad, H(K XOR ipad, text))
*/
public class HMac
: IMac
{
private const byte IPAD = (byte)0x36;
private const byte OPAD = (byte)0x5C;
private readonly IDigest digest;
private readonly int digestSize;
private readonly int blockLength;
private readonly byte[] inputPad;
private readonly byte[] outputPad;
public HMac(
IDigest digest)
{
this.digest = digest;
this.digestSize = digest.GetDigestSize();
this.blockLength = digest.GetByteLength();
this.inputPad = new byte[blockLength];
this.outputPad = new byte[blockLength];
}
public string AlgorithmName
{
get { return digest.AlgorithmName + "/HMAC"; }
}
public IDigest GetUnderlyingDigest()
{
return digest;
}
public void Init(
ICipherParameters parameters)
{
digest.Reset();
byte[] key = ((KeyParameter)parameters).GetKey();
int keyLength = key.Length;
if (keyLength > blockLength)
{
digest.BlockUpdate(key, 0, key.Length);
digest.DoFinal(inputPad, 0);
keyLength = digestSize;
}
else
{
Array.Copy(key, 0, inputPad, 0, keyLength);
}
Array.Clear(inputPad, keyLength, blockLength - keyLength);
Array.Copy(inputPad, 0, outputPad, 0, blockLength);
xor(inputPad, IPAD);
xor(outputPad, OPAD);
// Initialise the digest
digest.BlockUpdate(inputPad, 0, inputPad.Length);
}
public int GetMacSize()
{
return digestSize;
}
public void Update(
byte input)
{
digest.Update(input);
}
public void BlockUpdate(
byte[] input,
int inOff,
int len)
{
digest.BlockUpdate(input, inOff, len);
}
public int DoFinal(
byte[] output,
int outOff)
{
byte[] tmp = new byte[digestSize];
digest.DoFinal(tmp, 0);
digest.BlockUpdate(outputPad, 0, outputPad.Length);
digest.BlockUpdate(tmp, 0, tmp.Length);
int len = digest.DoFinal(output, outOff);
// Initialise the digest
digest.BlockUpdate(inputPad, 0, inputPad.Length);
return len;
}
/**
* Reset the mac generator.
*/
public void Reset()
{
// Reset underlying digest
digest.Reset();
// Initialise the digest
digest.BlockUpdate(inputPad, 0, inputPad.Length);
}
private static void xor(byte[] a, byte n)
{
for (int i = 0; i < a.Length; ++i)
{
a[i] ^= n;
}
}
}
}

View File

@@ -1,44 +0,0 @@
using System;
namespace Org.BouncyCastle.Crypto
{
/// <remarks>Block cipher engines are expected to conform to this interface.</remarks>
public interface IBufferedCipher
{
/// <summary>The name of the algorithm this cipher implements.</summary>
string AlgorithmName { get; }
/// <summary>Initialise the cipher.</summary>
/// <param name="forEncryption">If true the cipher is initialised for encryption,
/// if false for decryption.</param>
/// <param name="parameters">The key and other data required by the cipher.</param>
void Init(bool forEncryption, ICipherParameters parameters);
int GetBlockSize();
int GetOutputSize(int inputLen);
int GetUpdateOutputSize(int inputLen);
byte[] ProcessByte(byte input);
int ProcessByte(byte input, byte[] output, int outOff);
byte[] ProcessBytes(byte[] input);
byte[] ProcessBytes(byte[] input, int inOff, int length);
int ProcessBytes(byte[] input, byte[] output, int outOff);
int ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff);
byte[] DoFinal();
byte[] DoFinal(byte[] input);
byte[] DoFinal(byte[] input, int inOff, int length);
int DoFinal(byte[] output, int outOff);
int DoFinal(byte[] input, byte[] output, int outOff);
int DoFinal(byte[] input, int inOff, int length, byte[] output, int outOff);
/// <summary>
/// Reset the cipher. After resetting the cipher is in the same state
/// as it was after the last init (if there was one).
/// </summary>
void Reset();
}
}

View File

@@ -1,56 +0,0 @@
namespace Org.BouncyCastle.Crypto
{
public interface IDigest
{
/**
* return the algorithm name
*
* @return the algorithm name
*/
string AlgorithmName { get; }
/**
* return the size, in bytes, of the digest produced by this message digest.
*
* @return the size, in bytes, of the digest produced by this message digest.
*/
int GetDigestSize();
/**
* return the size, in bytes, of the internal buffer used by this digest.
*
* @return the size, in bytes, of the internal buffer used by this digest.
*/
int GetByteLength();
/**
* update the message digest with a single byte.
*
* @param inByte the input byte to be entered.
*/
void Update(byte input);
/**
* update the message digest with a block of bytes.
*
* @param input the byte array containing the data.
* @param inOff the offset into the byte array where the data starts.
* @param len the length of the data.
*/
void BlockUpdate(byte[] input, int inOff, int length);
/**
* Close the digest, producing the final digest value. The doFinal
* call leaves the digest reset.
*
* @param output the array the digest is to be copied into.
* @param outOff the offset into the out array the digest is to start at.
*/
int DoFinal(byte[] output, int outOff);
/**
* reset the digest back to it's initial state.
*/
void Reset();
}
}

View File

@@ -1,64 +0,0 @@
namespace Org.BouncyCastle.Crypto
{
public interface IMac
{
/**
* Initialise the MAC.
*
* @param param the key and other data required by the MAC.
* @exception ArgumentException if the parameters argument is
* inappropriate.
*/
void Init(ICipherParameters parameters);
/**
* Return the name of the algorithm the MAC implements.
*
* @return the name of the algorithm the MAC implements.
*/
string AlgorithmName { get; }
/**
* Return the block size for this MAC (in bytes).
*
* @return the block size for this MAC in bytes.
*/
int GetMacSize();
/**
* add a single byte to the mac for processing.
*
* @param in the byte to be processed.
* @exception InvalidOperationException if the MAC is not initialised.
*/
void Update(byte input);
/**
* @param in the array containing the input.
* @param inOff the index in the array the data begins at.
* @param len the length of the input starting at inOff.
* @exception InvalidOperationException if the MAC is not initialised.
* @exception DataLengthException if there isn't enough data in in.
*/
void BlockUpdate(byte[] input, int inOff, int len);
/**
* Compute the final stage of the MAC writing the output to the out
* parameter.
* <p>
* doFinal leaves the MAC in the same state it was after the last init.
* </p>
* @param out the array the MAC is to be output to.
* @param outOff the offset into the out buffer the output is to start at.
* @exception DataLengthException if there isn't enough space in out.
* @exception InvalidOperationException if the MAC is not initialised.
*/
int DoFinal(byte[] output, int outOff);
/**
* Reset the MAC. At the end of resetting the MAC should be in the
* in the same state it was after the last init (if there was one).
*/
void Reset();
}
}

View File

@@ -1,119 +0,0 @@
using System;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Macs;
using Org.BouncyCastle.Crypto.Parameters;
namespace SharpCompress.Crypto
{
//Gathered from:
//http://stackoverflow.com/questions/3210795/pbkdf2-in-bouncy-castle-c-sharp and Rfc2898DeriveBytes
internal class PBKDF2
{
private readonly IMac hMac = new HMac(new Sha1Digest());
private readonly byte[] state = new byte[20];
private int endIndex;
private int startIndex;
private uint block = 1u;
private readonly byte[] password;
private readonly byte[] salt;
private readonly int iterations;
public PBKDF2(byte[] password, byte[] salt, int iterations)
{
this.password = password;
this.salt = salt;
this.iterations = iterations;
}
public byte[] GetBytes(int cb)
{
if (cb <= 0)
{
throw new ArgumentOutOfRangeException("cb");
}
byte[] array = new byte[cb];
int i = 0;
int num = endIndex - startIndex;
if (num > 0)
{
if (cb < num)
{
Buffer.BlockCopy(state, startIndex, array, 0, cb);
startIndex += cb;
return array;
}
Buffer.BlockCopy(state, startIndex, array, 0, num);
startIndex = (endIndex = 0);
i += num;
}
while (i < cb)
{
byte[] src = Hash();
int num2 = cb - i;
if (num2 <= 20)
{
Buffer.BlockCopy(src, 0, array, i, num2);
i += num2;
Buffer.BlockCopy(src, num2, state, startIndex, 20 - num2);
endIndex += 20 - num2;
return array;
}
Buffer.BlockCopy(src, 0, array, i, 20);
i += 20;
}
return array;
}
private byte[] Hash()
{
byte[] array = UIntToOctet(block);
ICipherParameters param = new KeyParameter(password);
hMac.Init(param);
hMac.BlockUpdate(salt, 0, salt.Length);
hMac.BlockUpdate(array, 0, array.Length);
byte[] array2 = new byte[20];
hMac.DoFinal(array2, 0);
hMac.Init(param);
byte[] array3 = new byte[20];
Buffer.BlockCopy(array2, 0, array3, 0, 20);
int num = 2;
while (num <= (long)((ulong)iterations))
{
hMac.BlockUpdate(array2, 0, array2.Length);
hMac.DoFinal(array2, 0);
for (int i = 0; i < 20; i++)
{
array3[i] ^= array2[i];
}
num++;
}
block += 1u;
return array3;
}
internal static byte[] UIntToOctet(uint i)
{
byte[] bytes = BitConverter.GetBytes(i);
byte[] result = new[]
{
bytes[3],
bytes[2],
bytes[1],
bytes[0]
};
if (!BitConverter.IsLittleEndian)
{
return bytes;
}
return result;
}
}
}

View File

@@ -1,129 +0,0 @@
namespace Org.BouncyCastle.Crypto.Utilities
{
internal sealed class Pack
{
private Pack()
{
}
internal static void UInt32_To_BE(uint n, byte[] bs)
{
bs[0] = (byte)(n >> 24);
bs[1] = (byte)(n >> 16);
bs[2] = (byte)(n >> 8);
bs[3] = (byte)(n);
}
internal static void UInt32_To_BE(uint n, byte[] bs, int off)
{
bs[off] = (byte)(n >> 24);
bs[++off] = (byte)(n >> 16);
bs[++off] = (byte)(n >> 8);
bs[++off] = (byte)(n);
}
internal static uint BE_To_UInt32(byte[] bs)
{
uint n = (uint)bs[0] << 24;
n |= (uint)bs[1] << 16;
n |= (uint)bs[2] << 8;
n |= (uint)bs[3];
return n;
}
internal static uint BE_To_UInt32(byte[] bs, int off)
{
uint n = (uint)bs[off] << 24;
n |= (uint)bs[++off] << 16;
n |= (uint)bs[++off] << 8;
n |= (uint)bs[++off];
return n;
}
internal static ulong BE_To_UInt64(byte[] bs)
{
uint hi = BE_To_UInt32(bs);
uint lo = BE_To_UInt32(bs, 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static ulong BE_To_UInt64(byte[] bs, int off)
{
uint hi = BE_To_UInt32(bs, off);
uint lo = BE_To_UInt32(bs, off + 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static void UInt64_To_BE(ulong n, byte[] bs)
{
UInt32_To_BE((uint)(n >> 32), bs);
UInt32_To_BE((uint)(n), bs, 4);
}
internal static void UInt64_To_BE(ulong n, byte[] bs, int off)
{
UInt32_To_BE((uint)(n >> 32), bs, off);
UInt32_To_BE((uint)(n), bs, off + 4);
}
internal static void UInt32_To_LE(uint n, byte[] bs)
{
bs[0] = (byte)(n);
bs[1] = (byte)(n >> 8);
bs[2] = (byte)(n >> 16);
bs[3] = (byte)(n >> 24);
}
internal static void UInt32_To_LE(uint n, byte[] bs, int off)
{
bs[off] = (byte)(n);
bs[++off] = (byte)(n >> 8);
bs[++off] = (byte)(n >> 16);
bs[++off] = (byte)(n >> 24);
}
internal static uint LE_To_UInt32(byte[] bs)
{
uint n = (uint)bs[0];
n |= (uint)bs[1] << 8;
n |= (uint)bs[2] << 16;
n |= (uint)bs[3] << 24;
return n;
}
internal static uint LE_To_UInt32(byte[] bs, int off)
{
uint n = (uint)bs[off];
n |= (uint)bs[++off] << 8;
n |= (uint)bs[++off] << 16;
n |= (uint)bs[++off] << 24;
return n;
}
internal static ulong LE_To_UInt64(byte[] bs)
{
uint lo = LE_To_UInt32(bs);
uint hi = LE_To_UInt32(bs, 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static ulong LE_To_UInt64(byte[] bs, int off)
{
uint lo = LE_To_UInt32(bs, off);
uint hi = LE_To_UInt32(bs, off + 4);
return ((ulong)hi << 32) | (ulong)lo;
}
internal static void UInt64_To_LE(ulong n, byte[] bs)
{
UInt32_To_LE((uint)(n), bs);
UInt32_To_LE((uint)(n >> 32), bs, 4);
}
internal static void UInt64_To_LE(ulong n, byte[] bs, int off)
{
UInt32_To_LE((uint)(n), bs, off);
UInt32_To_LE((uint)(n >> 32), bs, off + 4);
}
}
}

View File

@@ -1,255 +0,0 @@
using System;
using Org.BouncyCastle.Crypto.Utilities;
namespace Org.BouncyCastle.Crypto.Digests
{
public class Sha1Digest
: GeneralDigest
{
private const int DigestLength = 20;
private uint H1, H2, H3, H4, H5;
private uint[] X = new uint[80];
private int xOff;
public Sha1Digest()
{
Reset();
}
/**
* Copy constructor. This will copy the state of the provided
* message digest.
*/
public Sha1Digest(Sha1Digest t)
: base(t)
{
H1 = t.H1;
H2 = t.H2;
H3 = t.H3;
H4 = t.H4;
H5 = t.H5;
Array.Copy(t.X, 0, X, 0, t.X.Length);
xOff = t.xOff;
}
public override string AlgorithmName
{
get { return "SHA-1"; }
}
public override int GetDigestSize()
{
return DigestLength;
}
internal override void ProcessWord(
byte[] input,
int inOff)
{
X[xOff] = Pack.BE_To_UInt32(input, inOff);
if (++xOff == 16)
{
ProcessBlock();
}
}
internal override void ProcessLength(long bitLength)
{
if (xOff > 14)
{
ProcessBlock();
}
X[14] = (uint)((ulong)bitLength >> 32);
X[15] = (uint)((ulong)bitLength);
}
public override int DoFinal(
byte[] output,
int outOff)
{
Finish();
Pack.UInt32_To_BE(H1, output, outOff);
Pack.UInt32_To_BE(H2, output, outOff + 4);
Pack.UInt32_To_BE(H3, output, outOff + 8);
Pack.UInt32_To_BE(H4, output, outOff + 12);
Pack.UInt32_To_BE(H5, output, outOff + 16);
Reset();
return DigestLength;
}
/**
* reset the chaining variables
*/
public override void Reset()
{
base.Reset();
H1 = 0x67452301;
H2 = 0xefcdab89;
H3 = 0x98badcfe;
H4 = 0x10325476;
H5 = 0xc3d2e1f0;
xOff = 0;
Array.Clear(X, 0, X.Length);
}
//
// Additive constants
//
private const uint Y1 = 0x5a827999;
private const uint Y2 = 0x6ed9eba1;
private const uint Y3 = 0x8f1bbcdc;
private const uint Y4 = 0xca62c1d6;
private static uint F(uint u, uint v, uint w)
{
return (u & v) | (~u & w);
}
private static uint H(uint u, uint v, uint w)
{
return u ^ v ^ w;
}
private static uint G(uint u, uint v, uint w)
{
return (u & v) | (u & w) | (v & w);
}
internal override void ProcessBlock()
{
//
// expand 16 word block into 80 word block.
//
for (int i = 16; i < 80; i++)
{
uint t = X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16];
X[i] = t << 1 | t >> 31;
}
//
// set up working variables.
//
uint A = H1;
uint B = H2;
uint C = H3;
uint D = H4;
uint E = H5;
//
// round 1
//
int idx = 0;
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + F(B, C, D) + E + X[idx++] + Y1
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + F(B, C, D) + X[idx++] + Y1;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + F(A, B, C) + X[idx++] + Y1;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + F(E, A, B) + X[idx++] + Y1;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + F(D, E, A) + X[idx++] + Y1;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + F(C, D, E) + X[idx++] + Y1;
C = C << 30 | (C >> 2);
}
//
// round 2
//
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y2
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + H(B, C, D) + X[idx++] + Y2;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + H(A, B, C) + X[idx++] + Y2;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + H(E, A, B) + X[idx++] + Y2;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + H(D, E, A) + X[idx++] + Y2;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + H(C, D, E) + X[idx++] + Y2;
C = C << 30 | (C >> 2);
}
//
// round 3
//
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + G(B, C, D) + E + X[idx++] + Y3
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + G(B, C, D) + X[idx++] + Y3;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + G(A, B, C) + X[idx++] + Y3;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + G(E, A, B) + X[idx++] + Y3;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + G(D, E, A) + X[idx++] + Y3;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + G(C, D, E) + X[idx++] + Y3;
C = C << 30 | (C >> 2);
}
//
// round 4
//
for (int j = 0; j < 4; j++)
{
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y4
// B = rotateLeft(B, 30)
E += (A << 5 | (A >> 27)) + H(B, C, D) + X[idx++] + Y4;
B = B << 30 | (B >> 2);
D += (E << 5 | (E >> 27)) + H(A, B, C) + X[idx++] + Y4;
A = A << 30 | (A >> 2);
C += (D << 5 | (D >> 27)) + H(E, A, B) + X[idx++] + Y4;
E = E << 30 | (E >> 2);
B += (C << 5 | (C >> 27)) + H(D, E, A) + X[idx++] + Y4;
D = D << 30 | (D >> 2);
A += (B << 5 | (B >> 27)) + H(C, D, E) + X[idx++] + Y4;
C = C << 30 | (C >> 2);
}
H1 += A;
H2 += B;
H3 += C;
H4 += D;
H5 += E;
//
// reset start of the buffer.
//
xOff = 0;
Array.Clear(X, 0, 16);
}
}
}

View File

@@ -1,68 +0,0 @@
using System;
using System.IO;
namespace SharpCompress.IO
{
internal class CountingWritableSubStream : Stream
{
private Stream writableStream;
internal CountingWritableSubStream(Stream stream)
{
writableStream = stream;
}
public uint Count { get; private set; }
public override bool CanRead
{
get { return false; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return true; }
}
public override void Flush()
{
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override long Position
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
writableStream.Write(buffer, offset, count);
Count += (uint) count;
}
}
}

View File

@@ -1,53 +0,0 @@
using System.Collections.Generic;
using SharpCompress.Common;
using SharpCompress.Common.Rar;
using SharpCompress.Common.Rar.Headers;
namespace SharpCompress.Reader.Rar
{
public class RarReaderEntry : RarEntry
{
internal RarReaderEntry(bool solid, RarFilePart part)
{
Part = part;
IsSolid = solid;
}
internal RarFilePart Part { get; private set; }
internal override IEnumerable<FilePart> Parts
{
get { return Part.AsEnumerable<FilePart>(); }
}
internal override FileHeader FileHeader
{
get { return Part.FileHeader; }
}
public override CompressionType CompressionType
{
get { return CompressionType.Rar; }
}
/// <summary>
/// The compressed file size
/// </summary>
public override long CompressedSize
{
get { return Part.FileHeader.CompressedSize; }
}
/// <summary>
/// The uncompressed file size
/// </summary>
public override long Size
{
get { return Part.FileHeader.UncompressedSize; }
}
internal override void Close()
{
}
}
}

View File

@@ -1,328 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7FA7D133-1417-4F85-9998-4C618AC8FEDA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile136</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<BaseIntermediateOutputPath>obj\Portable\</BaseIntermediateOutputPath>
<RestorePackages>true</RestorePackages>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Portable\</OutputPath>
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Portable\</OutputPath>
<DefineConstants>TRACE;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.Extensions.cs" />
<Compile Include="Archive\ArchiveFactory.cs" />
<Compile Include="Archive\GZip\GZipArchive.cs" />
<Compile Include="Archive\GZip\GZipArchiveEntry.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Archive\Rar\RarArchiveEntryFactory.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Archive\Rar\StreamRarArchiveVolume.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchive.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarArchive.cs" />
<Compile Include="Archive\Tar\TarArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipArchive.cs" />
<Compile Include="Archive\Zip\ZipArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipWritableArchiveEntry.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Common\ArchiveEncoding.cs" />
<Compile Include="Common\ArchiveException.cs" />
<Compile Include="Common\ArchiveExtractionEventArgs.cs" />
<Compile Include="Common\ArchiveType.cs" />
<Compile Include="Common\CompressedBytesReadEventArgs.cs" />
<Compile Include="Common\CompressionInfo.cs" />
<Compile Include="Common\CompressionType.cs" />
<Compile Include="Common\CryptographicException.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\EntryStream.cs" />
<Compile Include="Common\ExtractionException.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\FilePartExtractionBeginEventArgs.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\GenericVolume.cs" />
<Compile Include="Common\GZip\GZipEntry.cs" />
<Compile Include="Common\GZip\GZipFilePart.cs" />
<Compile Include="Common\GZip\GZipVolume.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IncompleteArchiveException.cs" />
<Compile Include="Common\InvalidFormatException.cs" />
<Compile Include="Common\IStreamListener.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\MultipartStreamRequiredException.cs" />
<Compile Include="Common\MultiVolumeExtractionException.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Common\PasswordProtectedException.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\RarRijndael.Portable.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
<Compile Include="Common\SevenZip\CBindPair.cs" />
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
<Compile Include="Common\SevenZip\CFileItem.cs" />
<Compile Include="Common\SevenZip\CFolder.cs" />
<Compile Include="Common\SevenZip\CMethodId.cs" />
<Compile Include="Common\SevenZip\CStreamSwitch.cs" />
<Compile Include="Common\SevenZip\DataReader.cs" />
<Compile Include="Common\SevenZip\SevenZipEntry.cs" />
<Compile Include="Common\SevenZip\SevenZipFilePart.cs" />
<Compile Include="Common\SevenZip\SevenZipVolume.cs" />
<Compile Include="Common\Tar\Headers\TarHeader.cs" />
<Compile Include="Common\Tar\TarEntry.cs" />
<Compile Include="Common\Tar\TarFilePart.cs" />
<Compile Include="Common\Tar\TarHeaderFactory.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.Portable.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\HeaderFlags.cs" />
<Compile Include="Common\Zip\Headers\IgnoreHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\SplitHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipFileEntry..cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipHeaderType.cs" />
<Compile Include="Common\Zip\PkwareTraditionalCryptoStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalEncryptionData.cs" />
<Compile Include="Common\Zip\SeekableZipFilePart.cs" />
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
<Compile Include="Compressor\BZip2\BZip2Stream.cs" />
<Compile Include="Compressor\BZip2\CBZip2InputStream.cs" />
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\CompressionMode.cs" />
<Compile Include="Compressor\Deflate\Crc32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Compressor\Filters\BCJ2Filter.cs" />
<Compile Include="Compressor\Filters\BCJFilter.cs" />
<Compile Include="Compressor\Filters\Filter.cs" />
<Compile Include="Compressor\LZMA\Bcj2DecoderStream.cs" />
<Compile Include="Compressor\LZMA\BitVector.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Compressor\LZMA\DecoderStream.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\Log.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBitTree.cs" />
<Compile Include="Compressor\LZMA\Registry.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs" />
<Compile Include="Compressor\LZMA\Utilites\Utils.cs" />
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
<Compile Include="Compressor\PPMd\H\Pointer.cs" />
<Compile Include="Compressor\PPMd\H\PPMContext.cs" />
<Compile Include="Compressor\PPMd\H\RangeCoder.cs" />
<Compile Include="Compressor\PPMd\H\RarMemBlock.cs" />
<Compile Include="Compressor\PPMd\H\RarNode.cs" />
<Compile Include="Compressor\PPMd\H\SEE2Context.cs" />
<Compile Include="Compressor\PPMd\H\State.cs" />
<Compile Include="Compressor\PPMd\H\StateRef.cs" />
<Compile Include="Compressor\PPMd\H\SubAllocator.cs" />
<Compile Include="Compressor\PPMd\I1\Allocator.cs" />
<Compile Include="Compressor\PPMd\I1\Coder.cs" />
<Compile Include="Compressor\PPMd\I1\MemoryNode.cs" />
<Compile Include="Compressor\PPMd\I1\Model.cs" />
<Compile Include="Compressor\PPMd\I1\ModelRestorationMethod.cs" />
<Compile Include="Compressor\PPMd\I1\Pointer.cs" />
<Compile Include="Compressor\PPMd\I1\PpmContext.cs" />
<Compile Include="Compressor\PPMd\I1\PpmState.cs" />
<Compile Include="Compressor\PPMd\I1\See2Context.cs" />
<Compile Include="Compressor\PPMd\PpmdProperties.cs" />
<Compile Include="Compressor\PPMd\PpmdStream.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Compressor\Rar\RarStream.cs" />
<Compile Include="Compressor\Rar\Unpack.cs" />
<Compile Include="Compressor\Rar\Unpack15.cs" />
<Compile Include="Compressor\Rar\Unpack20.cs" />
<Compile Include="Compressor\Rar\UnpackFilter.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Compressor\Rar\VM\BitInput.cs" />
<Compile Include="Compressor\Rar\VM\RarVM.cs" />
<Compile Include="Compressor\Rar\VM\VMCmdFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMCommands.cs" />
<Compile Include="Compressor\Rar\VM\VMFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMOpType.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedCommand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedOperand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Crypto\BufferedBlockCipher.cs" />
<Compile Include="Crypto\BufferedCipherBase.cs" />
<Compile Include="Crypto\CryptoException.cs" />
<Compile Include="Crypto\DataLengthException.cs" />
<Compile Include="Crypto\GeneralDigest.cs" />
<Compile Include="Crypto\HMac.cs" />
<Compile Include="Crypto\IBlockCipher.cs" />
<Compile Include="Crypto\IBufferedCipher.cs" />
<Compile Include="Crypto\ICipherParameters.cs" />
<Compile Include="Crypto\IDigest.cs" />
<Compile Include="Crypto\IMac.cs" />
<Compile Include="Crypto\KeyParameter.cs" />
<Compile Include="Crypto\BigInteger.cs" />
<Compile Include="Crypto\Pack.cs" />
<Compile Include="Crypto\PBKDF2.cs" />
<Compile Include="Crypto\RijndaelEngine.cs" />
<Compile Include="Crypto\Sha1Digest.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="Utility.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="Writer\AbstractWriter.cs" />
<Compile Include="Writer\GZip\GZipWriter.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="Writer\IWriter.Extensions.cs" />
<Compile Include="Writer\Tar\TarWriter.cs" />
<Compile Include="Writer\WriterFactory.cs" />
<Compile Include="Writer\Zip\ZipCentralDirectoryEntry.cs" />
<Compile Include="Writer\Zip\ZipWriter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="SharpCompress.pfx" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,399 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EFDCAF57-FD4D-4E5D-A3D5-F26B875817ED}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress.PortableTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;DISABLE_TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<DocumentationFile>..\bin\SharpCompress.PortableTest.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>..\bin\SharpCompress.PortableTest.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Common\ArchiveEncoding.cs" />
<Compile Include="Archive\AbstractWritableArchive.cs" />
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.Extensions.cs" />
<Compile Include="Archive\ArchiveFactory.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.Extensions.cs" />
<Compile Include="Archive\GZip\GZipArchive.cs" />
<Compile Include="Archive\GZip\GZipArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\Rar\RarArchiveEntryFactory.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\Rar\StreamRarArchiveVolume.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchive.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarArchive.cs" />
<Compile Include="Archive\Tar\TarArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipArchive.cs" />
<Compile Include="Archive\Zip\ZipArchiveEntry.cs" />
<Compile Include="Common\ArchiveException.cs" />
<Compile Include="Common\ArchiveExtractionEventArgs.cs" />
<Compile Include="Common\CompressedBytesReadEventArgs.cs" />
<Compile Include="Common\CompressionInfo.cs" />
<Compile Include="Common\CompressionType.cs" />
<Compile Include="Common\FilePartExtractionBeginEventArgs.cs" />
<Compile Include="Common\GenericVolume.cs" />
<Compile Include="Common\IncompleteArchiveException.cs" />
<Compile Include="Common\MultiVolumeExtractionException.cs" />
<Compile Include="Common\PasswordProtectedException.cs" />
<Compile Include="Common\CryptographicException.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\GZip\GZipEntry.cs" />
<Compile Include="Common\GZip\GZipFilePart.cs" />
<Compile Include="Common\GZip\GZipVolume.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarRijndael.Portable.cs" />
<Compile Include="Common\SevenZip\CBindPair.cs" />
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
<Compile Include="Common\SevenZip\CFileItem.cs" />
<Compile Include="Common\SevenZip\CFolder.cs" />
<Compile Include="Common\SevenZip\CStreamSwitch.cs" />
<Compile Include="Common\SevenZip\DataReader.cs" />
<Compile Include="Common\SevenZip\SevenZipEntry.cs" />
<Compile Include="Common\SevenZip\SevenZipFilePart.cs" />
<Compile Include="Common\SevenZip\SevenZipVolume.cs" />
<Compile Include="Common\Tar\Headers\TarHeader.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Tar\TarEntry.cs" />
<Compile Include="Common\Tar\TarFilePart.cs" />
<Compile Include="Common\Tar\TarHeaderFactory.cs" />
<Compile Include="Common\Zip\Headers\HeaderFlags.cs" />
<Compile Include="Common\Zip\Headers\IgnoreHeader.cs" />
<Compile Include="Common\Zip\Headers\SplitHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipFileEntry..cs" />
<Compile Include="Common\Zip\Headers\ZipHeaderType.cs" />
<Compile Include="Common\Zip\SeekableZipFilePart.cs" />
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
<Compile Include="Compressor\BZip2\BZip2Stream.cs" />
<Compile Include="Compressor\BZip2\CBZip2InputStream.cs" />
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\CompressionMode.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Common\Zip\PkwareTraditionalCryptoStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalEncryptionData.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\Filters\BCJ2Filter.cs" />
<Compile Include="Compressor\Filters\BCJFilter.cs" />
<Compile Include="Compressor\Filters\Filter.cs" />
<Compile Include="Compressor\LZMA\BitVector.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
<Compile Include="Common\SevenZip\CMethodId.cs" />
<Compile Include="Compressor\LZMA\AesDecoderStream.cs" />
<Compile Include="Compressor\LZMA\Bcj2DecoderStream.cs" />
<Compile Include="Compressor\LZMA\DecoderStream.cs" />
<Compile Include="Compressor\LZMA\Registry.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\Log.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBitTree.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\Utils.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
<Compile Include="Compressor\PPMd\H\Pointer.cs" />
<Compile Include="Compressor\PPMd\H\PPMContext.cs" />
<Compile Include="Compressor\PPMd\H\RangeCoder.cs" />
<Compile Include="Compressor\PPMd\H\RarMemBlock.cs" />
<Compile Include="Compressor\PPMd\H\RarNode.cs" />
<Compile Include="Compressor\PPMd\H\SEE2Context.cs" />
<Compile Include="Compressor\PPMd\H\State.cs" />
<Compile Include="Compressor\PPMd\H\StateRef.cs" />
<Compile Include="Compressor\PPMd\H\SubAllocator.cs" />
<Compile Include="Compressor\PPMd\I1\Allocator.cs" />
<Compile Include="Compressor\PPMd\I1\Coder.cs" />
<Compile Include="Compressor\PPMd\I1\MemoryNode.cs" />
<Compile Include="Compressor\PPMd\I1\Model.cs" />
<Compile Include="Compressor\PPMd\I1\ModelRestorationMethod.cs" />
<Compile Include="Compressor\PPMd\I1\Pointer.cs" />
<Compile Include="Compressor\PPMd\I1\PpmContext.cs" />
<Compile Include="Compressor\PPMd\I1\PpmState.cs" />
<Compile Include="Compressor\PPMd\I1\See2Context.cs" />
<Compile Include="Compressor\PPMd\PpmdProperties.cs" />
<Compile Include="Compressor\PPMd\PpmdStream.cs" />
<Compile Include="Compressor\Rar\RarStream.cs" />
<Compile Include="Crypto\BigInteger.cs" />
<Compile Include="Crypto\BufferedBlockCipher.cs" />
<Compile Include="Crypto\BufferedCipherBase.cs" />
<Compile Include="Crypto\CryptoException.cs" />
<Compile Include="Crypto\DataLengthException.cs" />
<Compile Include="Crypto\GeneralDigest.cs" />
<Compile Include="Crypto\HMac.cs" />
<Compile Include="Crypto\IBlockCipher.cs" />
<Compile Include="Crypto\IBufferedCipher.cs" />
<Compile Include="Crypto\ICipherParameters.cs" />
<Compile Include="Crypto\IDigest.cs" />
<Compile Include="Crypto\IMac.cs" />
<Compile Include="Crypto\KeyParameter.cs" />
<Compile Include="Crypto\Pack.cs" />
<Compile Include="Crypto\PBKDF2.cs" />
<Compile Include="Crypto\RijndaelEngine.cs" />
<Compile Include="Crypto\Sha1Digest.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="Common\EntryStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Compressor\Deflate\CRC32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\InvalidFormatException.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="Common\IStreamListener.cs" />
<Compile Include="Common\MultipartStreamRequiredException.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Common\ExtractionException.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Common\ArchiveType.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="Archive\Rar\FileInfoRarFilePart.cs" />
<Compile Include="Archive\Rar\FileInfoRarArchiveVolume.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\Rar\Unpack.cs" />
<Compile Include="Compressor\Rar\Unpack15.cs" />
<Compile Include="Compressor\Rar\Unpack20.cs" />
<Compile Include="Compressor\Rar\UnpackFilter.cs" />
<Compile Include="Compressor\Rar\VM\BitInput.cs" />
<Compile Include="Compressor\Rar\VM\RarVM.cs" />
<Compile Include="Compressor\Rar\VM\VMCmdFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMCommands.cs" />
<Compile Include="Compressor\Rar\VM\VMFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMOpType.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedCommand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedOperand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Utility.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Writer\AbstractWriter.cs" />
<Compile Include="Writer\GZip\GZipWriter.cs" />
<Compile Include="Writer\IWriter.Extensions.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="Writer\Tar\TarWriter.cs" />
<Compile Include="Writer\WriterFactory.cs" />
<Compile Include="Writer\Zip\ZipCentralDirectoryEntry.cs" />
<Compile Include="Writer\Zip\ZipWriter.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="SharpCompress.pfx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,328 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<BaseIntermediateOutputPath>obj\WindowsStore\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\WindowsStore\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\WindowsStore\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.Extensions.cs" />
<Compile Include="Archive\ArchiveFactory.cs" />
<Compile Include="Archive\GZip\GZipArchive.cs" />
<Compile Include="Archive\GZip\GZipArchiveEntry.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\IArchive.Extensions.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Archive\Rar\RarArchiveEntryFactory.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Archive\Rar\StreamRarArchiveVolume.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchive.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarArchive.cs" />
<Compile Include="Archive\Tar\TarArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipArchive.cs" />
<Compile Include="Archive\Zip\ZipArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipWritableArchiveEntry.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Common\ArchiveEncoding.cs" />
<Compile Include="Common\ArchiveException.cs" />
<Compile Include="Common\ArchiveExtractionEventArgs.cs" />
<Compile Include="Common\ArchiveType.cs" />
<Compile Include="Common\CompressedBytesReadEventArgs.cs" />
<Compile Include="Common\CompressionInfo.cs" />
<Compile Include="Common\CompressionType.cs" />
<Compile Include="Common\CryptographicException.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\EntryStream.cs" />
<Compile Include="Common\ExtractionException.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\FilePartExtractionBeginEventArgs.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\GenericVolume.cs" />
<Compile Include="Common\GZip\GZipEntry.cs" />
<Compile Include="Common\GZip\GZipFilePart.cs" />
<Compile Include="Common\GZip\GZipVolume.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IncompleteArchiveException.cs" />
<Compile Include="Common\InvalidFormatException.cs" />
<Compile Include="Common\IStreamListener.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\MultipartStreamRequiredException.cs" />
<Compile Include="Common\MultiVolumeExtractionException.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Common\PasswordProtectedException.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\RarRijndael.Portable.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
<Compile Include="Common\SevenZip\CBindPair.cs" />
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
<Compile Include="Common\SevenZip\CFileItem.cs" />
<Compile Include="Common\SevenZip\CFolder.cs" />
<Compile Include="Common\SevenZip\CMethodId.cs" />
<Compile Include="Common\SevenZip\CStreamSwitch.cs" />
<Compile Include="Common\SevenZip\DataReader.cs" />
<Compile Include="Common\SevenZip\SevenZipEntry.cs" />
<Compile Include="Common\SevenZip\SevenZipFilePart.cs" />
<Compile Include="Common\SevenZip\SevenZipVolume.cs" />
<Compile Include="Common\Tar\Headers\TarHeader.cs" />
<Compile Include="Common\Tar\TarEntry.cs" />
<Compile Include="Common\Tar\TarFilePart.cs" />
<Compile Include="Common\Tar\TarHeaderFactory.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\HeaderFlags.cs" />
<Compile Include="Common\Zip\Headers\IgnoreHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\SplitHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipFileEntry..cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipHeaderType.cs" />
<Compile Include="Common\Zip\PkwareTraditionalCryptoStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalEncryptionData.cs" />
<Compile Include="Common\Zip\SeekableZipFilePart.cs" />
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesEncryptionData.Portable.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
<Compile Include="Compressor\BZip2\BZip2Stream.cs" />
<Compile Include="Compressor\BZip2\CBZip2InputStream.cs" />
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\CompressionMode.cs" />
<Compile Include="Compressor\Deflate\CRC32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Compressor\Filters\BCJ2Filter.cs" />
<Compile Include="Compressor\Filters\BCJFilter.cs" />
<Compile Include="Compressor\Filters\Filter.cs" />
<Compile Include="Compressor\LZMA\Bcj2DecoderStream.cs" />
<Compile Include="Compressor\LZMA\BitVector.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Compressor\LZMA\DecoderStream.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\Log.cs" />
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBitTree.cs" />
<Compile Include="Compressor\LZMA\Registry.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs" />
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs" />
<Compile Include="Compressor\LZMA\Utilites\Utils.cs" />
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
<Compile Include="Compressor\PPMd\H\Pointer.cs" />
<Compile Include="Compressor\PPMd\H\PPMContext.cs" />
<Compile Include="Compressor\PPMd\H\RangeCoder.cs" />
<Compile Include="Compressor\PPMd\H\RarMemBlock.cs" />
<Compile Include="Compressor\PPMd\H\RarNode.cs" />
<Compile Include="Compressor\PPMd\H\SEE2Context.cs" />
<Compile Include="Compressor\PPMd\H\State.cs" />
<Compile Include="Compressor\PPMd\H\StateRef.cs" />
<Compile Include="Compressor\PPMd\H\SubAllocator.cs" />
<Compile Include="Compressor\PPMd\I1\Allocator.cs" />
<Compile Include="Compressor\PPMd\I1\Coder.cs" />
<Compile Include="Compressor\PPMd\I1\MemoryNode.cs" />
<Compile Include="Compressor\PPMd\I1\Model.cs" />
<Compile Include="Compressor\PPMd\I1\ModelRestorationMethod.cs" />
<Compile Include="Compressor\PPMd\I1\Pointer.cs" />
<Compile Include="Compressor\PPMd\I1\PpmContext.cs" />
<Compile Include="Compressor\PPMd\I1\PpmState.cs" />
<Compile Include="Compressor\PPMd\I1\See2Context.cs" />
<Compile Include="Compressor\PPMd\PpmdProperties.cs" />
<Compile Include="Compressor\PPMd\PpmdStream.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Compressor\Rar\RarStream.cs" />
<Compile Include="Compressor\Rar\Unpack.cs" />
<Compile Include="Compressor\Rar\Unpack15.cs" />
<Compile Include="Compressor\Rar\Unpack20.cs" />
<Compile Include="Compressor\Rar\UnpackFilter.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Compressor\Rar\VM\BitInput.cs" />
<Compile Include="Compressor\Rar\VM\RarVM.cs" />
<Compile Include="Compressor\Rar\VM\VMCmdFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMCommands.cs" />
<Compile Include="Compressor\Rar\VM\VMFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMOpType.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedCommand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedOperand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Crypto\BigInteger.cs" />
<Compile Include="Crypto\BufferedBlockCipher.cs" />
<Compile Include="Crypto\BufferedCipherBase.cs" />
<Compile Include="Crypto\CryptoException.cs" />
<Compile Include="Crypto\DataLengthException.cs" />
<Compile Include="Crypto\GeneralDigest.cs" />
<Compile Include="Crypto\HMac.cs" />
<Compile Include="Crypto\IBlockCipher.cs" />
<Compile Include="Crypto\IBufferedCipher.cs" />
<Compile Include="Crypto\ICipherParameters.cs" />
<Compile Include="Crypto\IDigest.cs" />
<Compile Include="Crypto\IMac.cs" />
<Compile Include="Crypto\KeyParameter.cs" />
<Compile Include="Crypto\PBKDF2.cs" />
<Compile Include="Crypto\RijndaelEngine.cs" />
<Compile Include="Crypto\Pack.cs" />
<Compile Include="Crypto\Sha1Digest.cs" />
<Compile Include="IO\AppendingStream.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="Utility.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="Writer\AbstractWriter.cs" />
<Compile Include="Writer\GZip\GZipWriter.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="Writer\IWriter.Extensions.cs" />
<Compile Include="Writer\Tar\TarWriter.cs" />
<Compile Include="Writer\WriterFactory.cs" />
<Compile Include="Writer\Zip\ZipCentralDirectoryEntry.cs" />
<Compile Include="Writer\Zip\ZipWriter.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="SharpCompress.pfx" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,387 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{10A689CF-76A2-4A4F-96E4-553C33398438}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<BaseIntermediateOutputPath>obj\Full\</BaseIntermediateOutputPath>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\sharpcompress\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Full\</OutputPath>
<DefineConstants>TRACE;DEBUG;DISABLE_TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Full\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>
</DocumentationFile>
<NoWarn>1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Common\ArchiveEncoding.cs" />
<Compile Include="Archive\AbstractWritableArchive.cs" />
<Compile Include="Archive\AbstractArchive.cs" />
<Compile Include="Archive\AbstractWritableArchive.Extensions.cs" />
<Compile Include="Archive\ArchiveFactory.cs" />
<Compile Include="Archive\GZip\GZipWritableArchiveEntry.cs" />
<Compile Include="Archive\IArchive.Extensions.cs" />
<Compile Include="Archive\GZip\GZipArchive.cs" />
<Compile Include="Archive\GZip\GZipArchiveEntry.cs" />
<Compile Include="Archive\IArchiveEntry.cs" />
<Compile Include="Archive\Rar\RarArchiveEntryFactory.cs" />
<Compile Include="Archive\IArchive.cs" />
<Compile Include="Archive\Rar\StreamRarArchiveVolume.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchive.cs" />
<Compile Include="Archive\SevenZip\SevenZipArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarArchive.cs" />
<Compile Include="Archive\Tar\TarArchiveEntry.cs" />
<Compile Include="Archive\Tar\TarWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipWritableArchiveEntry.cs" />
<Compile Include="Archive\Zip\ZipArchive.cs" />
<Compile Include="Archive\Zip\ZipArchiveEntry.cs" />
<Compile Include="Common\ArchiveException.cs" />
<Compile Include="Common\ArchiveExtractionEventArgs.cs" />
<Compile Include="Common\CompressedBytesReadEventArgs.cs" />
<Compile Include="Common\CompressionInfo.cs" />
<Compile Include="Common\CompressionType.cs" />
<Compile Include="Common\FilePartExtractionBeginEventArgs.cs" />
<Compile Include="Common\GenericVolume.cs" />
<Compile Include="Common\IncompleteArchiveException.cs" />
<Compile Include="Common\MultiVolumeExtractionException.cs" />
<Compile Include="Common\PasswordProtectedException.cs" />
<Compile Include="Common\CryptographicException.cs" />
<Compile Include="Common\FlagUtility.cs" />
<Compile Include="Common\GZip\GZipEntry.cs" />
<Compile Include="Common\GZip\GZipFilePart.cs" />
<Compile Include="Common\GZip\GZipVolume.cs" />
<Compile Include="Common\ExtractOptions.cs" />
<Compile Include="Common\FilePart.cs" />
<Compile Include="Common\Entry.cs" />
<Compile Include="Common\IEntry.cs" />
<Compile Include="Common\IVolume.cs" />
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
<Compile Include="Common\Rar\RarRijndael.cs" />
<Compile Include="Common\SevenZip\CBindPair.cs" />
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
<Compile Include="Common\SevenZip\CFileItem.cs" />
<Compile Include="Common\SevenZip\CFolder.cs" />
<Compile Include="Common\SevenZip\CStreamSwitch.cs" />
<Compile Include="Common\SevenZip\DataReader.cs" />
<Compile Include="Common\SevenZip\SevenZipEntry.cs" />
<Compile Include="Common\SevenZip\SevenZipFilePart.cs" />
<Compile Include="Common\SevenZip\SevenZipVolume.cs" />
<Compile Include="Common\Tar\Headers\TarHeader.cs" />
<Compile Include="Common\Tar\TarReadOnlySubStream.cs" />
<Compile Include="Common\Tar\TarVolume.cs" />
<Compile Include="Common\Tar\TarEntry.cs" />
<Compile Include="Common\Tar\TarFilePart.cs" />
<Compile Include="Common\Tar\TarHeaderFactory.cs" />
<Compile Include="Common\Zip\Headers\HeaderFlags.cs" />
<Compile Include="Common\Zip\Headers\IgnoreHeader.cs" />
<Compile Include="Common\Zip\Headers\SplitHeader.cs" />
<Compile Include="Common\Zip\Headers\ZipFileEntry..cs" />
<Compile Include="Common\Zip\Headers\ZipHeaderType.cs" />
<Compile Include="Common\Zip\SeekableZipFilePart.cs" />
<Compile Include="Common\Zip\SeekableZipHeaderFactory.cs" />
<Compile Include="Common\Zip\StreamingZipFilePart.cs" />
<Compile Include="Common\Zip\StreamingZipHeaderFactory.cs" />
<Compile Include="Common\Zip\WinzipAesCryptoStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Common\Zip\WinzipAesEncryptionData.cs" />
<Compile Include="Common\Zip\WinzipAesKeySize.cs" />
<Compile Include="Common\Zip\ZipVolume.cs" />
<Compile Include="Compressor\BZip2\BZip2Constants.cs" />
<Compile Include="Compressor\BZip2\BZip2Stream.cs" />
<Compile Include="Compressor\BZip2\CBZip2InputStream.cs" />
<Compile Include="Compressor\BZip2\CBZip2OutputStream.cs" />
<Compile Include="Compressor\BZip2\CRC.cs" />
<Compile Include="Compressor\CompressionMode.cs" />
<Compile Include="Compressor\Deflate\FlushType.cs" />
<Compile Include="Common\Zip\PkwareTraditionalCryptoStream.cs" />
<Compile Include="Common\Zip\PkwareTraditionalEncryptionData.cs" />
<Compile Include="Compressor\Deflate\GZipStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\Filters\BCJ2Filter.cs" />
<Compile Include="Compressor\Filters\BCJFilter.cs" />
<Compile Include="Compressor\Filters\Filter.cs" />
<Compile Include="Compressor\LZMA\BitVector.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\LZ\CRC.cs" />
<Compile Include="Compressor\LZMA\CRC.cs" />
<Compile Include="Common\SevenZip\ArchiveDatabase.cs" />
<Compile Include="Common\SevenZip\ArchiveReader.cs" />
<Compile Include="Common\SevenZip\CMethodId.cs" />
<Compile Include="Compressor\LZMA\AesDecoderStream.cs" />
<Compile Include="Compressor\LZMA\Bcj2DecoderStream.cs" />
<Compile Include="Compressor\LZMA\DecoderStream.cs" />
<Compile Include="Compressor\LZMA\Registry.cs" />
<Compile Include="Compressor\LZMA\ICoder.cs" />
<Compile Include="Compressor\LZMA\Log.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\LzmaBase.cs" />
<Compile Include="Compressor\LZMA\LzmaDecoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoder.cs" />
<Compile Include="Compressor\LZMA\LzmaEncoderProperties.cs" />
<Compile Include="Compressor\LZMA\LzmaStream.cs" />
<Compile Include="Compressor\LZMA\LZ\LzBinTree.cs" />
<Compile Include="Compressor\LZMA\LZ\LzInWindow.cs" />
<Compile Include="Compressor\LZMA\LZ\LzOutWindow.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoder.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBit.cs" />
<Compile Include="Compressor\LZMA\RangeCoder\RangeCoderBitTree.cs" />
<Compile Include="Compressor\LZMA\Utilites\CrcBuilderStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\CrcCheckStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\IPasswordProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\LZMA\Utilites\Utils.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compressor\PPMd\H\FreqData.cs" />
<Compile Include="Compressor\PPMd\H\ModelPPM.cs" />
<Compile Include="Compressor\PPMd\H\Pointer.cs" />
<Compile Include="Compressor\PPMd\H\PPMContext.cs" />
<Compile Include="Compressor\PPMd\H\RangeCoder.cs" />
<Compile Include="Compressor\PPMd\H\RarMemBlock.cs" />
<Compile Include="Compressor\PPMd\H\RarNode.cs" />
<Compile Include="Compressor\PPMd\H\SEE2Context.cs" />
<Compile Include="Compressor\PPMd\H\State.cs" />
<Compile Include="Compressor\PPMd\H\StateRef.cs" />
<Compile Include="Compressor\PPMd\H\SubAllocator.cs" />
<Compile Include="Compressor\PPMd\I1\Allocator.cs" />
<Compile Include="Compressor\PPMd\I1\Coder.cs" />
<Compile Include="Compressor\PPMd\I1\MemoryNode.cs" />
<Compile Include="Compressor\PPMd\I1\Model.cs" />
<Compile Include="Compressor\PPMd\I1\ModelRestorationMethod.cs" />
<Compile Include="Compressor\PPMd\I1\Pointer.cs" />
<Compile Include="Compressor\PPMd\I1\PpmContext.cs" />
<Compile Include="Compressor\PPMd\I1\PpmState.cs" />
<Compile Include="Compressor\PPMd\I1\See2Context.cs" />
<Compile Include="Compressor\PPMd\PpmdProperties.cs" />
<Compile Include="Compressor\PPMd\PpmdStream.cs" />
<Compile Include="Compressor\Rar\RarStream.cs" />
<Compile Include="IO\CountingWritableSubStream.cs" />
<Compile Include="Common\EntryStream.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IO\ListeningStream.cs" />
<Compile Include="IO\NonDisposingStream.cs" />
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
<Compile Include="IO\RewindableStream.cs" />
<Compile Include="Reader\GZip\GZipReader.cs" />
<Compile Include="Reader\ReaderFactory.cs" />
<Compile Include="Reader\AbstractReader.cs" />
<Compile Include="Common\Volume.cs" />
<Compile Include="Compressor\Deflate\CRC32.cs" />
<Compile Include="Compressor\Deflate\DeflateManager.cs" />
<Compile Include="Compressor\Deflate\DeflateStream.cs" />
<Compile Include="Compressor\Deflate\Inflate.cs" />
<Compile Include="Compressor\Deflate\InfTree.cs" />
<Compile Include="Compressor\Deflate\Tree.cs" />
<Compile Include="Compressor\Deflate\Zlib.cs" />
<Compile Include="Compressor\Deflate\ZlibBaseStream.cs" />
<Compile Include="Compressor\Deflate\ZlibCodec.cs" />
<Compile Include="Compressor\Deflate\ZlibConstants.cs" />
<Compile Include="Compressor\Deflate\ZlibStream.cs" />
<Compile Include="Common\Rar\Headers\FileNameDecoder.cs" />
<Compile Include="Common\InvalidFormatException.cs" />
<Compile Include="IO\ReadOnlySubStream.cs" />
<Compile Include="IO\StreamingMode.cs" />
<Compile Include="Common\IStreamListener.cs" />
<Compile Include="Common\MultipartStreamRequiredException.cs" />
<Compile Include="LazyReadOnlyCollection.cs" />
<Compile Include="Archive\Rar\RarArchive.Extensions.cs" />
<Compile Include="Archive\IArchiveEntry.Extensions.cs" />
<Compile Include="Archive\Rar\RarArchiveEntry.cs" />
<Compile Include="Common\ExtractionException.cs" />
<Compile Include="Common\Rar\RarEntry.cs" />
<Compile Include="Common\Options.cs" />
<Compile Include="Reader\IReader.cs" />
<Compile Include="Reader\Rar\MultiVolumeRarReader.cs" />
<Compile Include="Reader\Rar\RarReader.cs" />
<Compile Include="Reader\IReader.Extensions.cs" />
<Compile Include="Reader\Rar\RarReaderEntry.cs" />
<Compile Include="Archive\Rar\SeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\SingleVolumeRarReader.cs" />
<Compile Include="Common\ArchiveType.cs" />
<Compile Include="Reader\Tar\TarReader.cs" />
<Compile Include="ReadOnlyCollection.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="Archive\Rar\FileInfoRarFilePart.cs" />
<Compile Include="Archive\Rar\FileInfoRarArchiveVolume.cs" />
<Compile Include="Common\Rar\RarFilePart.cs" />
<Compile Include="Common\Rar\Headers\AVHeader.cs" />
<Compile Include="Common\Rar\Headers\CommentHeader.cs" />
<Compile Include="Common\Rar\Headers\EndArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\SignHeader.cs" />
<Compile Include="Common\Rar\RarVolume.cs" />
<Compile Include="Compressor\Rar\UnpackUtility.cs" />
<Compile Include="Archive\Rar\RarArchive.cs" />
<Compile Include="Compressor\Rar\MultiVolumeReadOnlyStream.cs" />
<Compile Include="Compressor\Rar\RarCRC.cs" />
<Compile Include="Common\Rar\Headers\FileHeader.cs" />
<Compile Include="Common\Rar\Headers\ArchiveHeader.cs" />
<Compile Include="Common\Rar\Headers\RarHeader.cs" />
<Compile Include="IO\MarkingBinaryReader.cs" />
<Compile Include="Common\Rar\Headers\NewSubHeader.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Common\Rar\Headers\RarHeaderFactory.cs" />
<Compile Include="Common\Rar\Headers\Flags.cs" />
<Compile Include="Compressor\Rar\Decode\AudioVariables.cs" />
<Compile Include="Compressor\Rar\Decode\BitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\CodeType.cs" />
<Compile Include="Compressor\Rar\Decode\Compress.cs" />
<Compile Include="Compressor\Rar\Decode\Decode.cs" />
<Compile Include="Compressor\Rar\Decode\DistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\FilterType.cs" />
<Compile Include="Compressor\Rar\Decode\LitDecode.cs" />
<Compile Include="Compressor\Rar\Decode\LowDistDecode.cs" />
<Compile Include="Compressor\Rar\Decode\MultDecode.cs" />
<Compile Include="Compressor\Rar\Decode\RepDecode.cs" />
<Compile Include="Compressor\Rar\PPM\BlockTypes.cs" />
<Compile Include="Compressor\Rar\Unpack.cs" />
<Compile Include="Compressor\Rar\Unpack15.cs" />
<Compile Include="Compressor\Rar\Unpack20.cs" />
<Compile Include="Compressor\Rar\UnpackFilter.cs" />
<Compile Include="Compressor\Rar\VM\BitInput.cs" />
<Compile Include="Compressor\Rar\VM\RarVM.cs" />
<Compile Include="Compressor\Rar\VM\VMCmdFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMCommands.cs" />
<Compile Include="Compressor\Rar\VM\VMFlags.cs" />
<Compile Include="Compressor\Rar\VM\VMOpType.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedCommand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedOperand.cs" />
<Compile Include="Compressor\Rar\VM\VMPreparedProgram.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilters.cs" />
<Compile Include="Compressor\Rar\VM\VMStandardFilterSignature.cs" />
<Compile Include="Utility.cs" />
<Compile Include="Common\Rar\Headers\MarkHeader.cs" />
<Compile Include="Archive\Rar\RarArchiveVolumeFactory.cs" />
<Compile Include="Reader\Rar\NonSeekableStreamFilePart.cs" />
<Compile Include="Reader\Rar\RarReaderVolume.cs" />
<Compile Include="Common\Zip\ZipCompressionMethod.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEndHeader.cs" />
<Compile Include="Common\Zip\Headers\DirectoryEntryHeader.cs" />
<Compile Include="Common\Zip\Headers\LocalEntryHeader.cs" />
<Compile Include="Common\Zip\ZipFilePart.cs" />
<Compile Include="Common\Zip\Headers\ZipHeader.cs" />
<Compile Include="Common\Zip\ZipHeaderFactory.cs" />
<Compile Include="Reader\Zip\ZipReader.cs" />
<Compile Include="Common\Zip\ZipEntry.cs" />
<Compile Include="Writer\AbstractWriter.cs" />
<Compile Include="Writer\GZip\GZipWriter.cs" />
<Compile Include="Writer\IWriter.Extensions.cs" />
<Compile Include="Writer\IWriter.cs" />
<Compile Include="Writer\Tar\TarWriter.cs" />
<Compile Include="Writer\WriterFactory.cs" />
<Compile Include="Writer\Zip\ZipCentralDirectoryEntry.cs" />
<Compile Include="Writer\Zip\ZipWriter.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="SharpCompress.pfx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,512 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Archive;
using SharpCompress.Common;
using SharpCompress.IO;
namespace SharpCompress
{
internal static class Utility
{
public static ReadOnlyCollection<T> ToReadOnly<T>(this IEnumerable<T> items)
{
return new ReadOnlyCollection<T>(items.ToList());
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
/// <param name="number">Number to operate on</param>
/// <param name="bits">Ammount of bits to shift</param>
/// <returns>The resulting number from the shift operation</returns>
public static int URShift(int number, int bits)
{
if (number >= 0)
return number >> bits;
else
return (number >> bits) + (2 << ~bits);
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
/// <param name="number">Number to operate on</param>
/// <param name="bits">Ammount of bits to shift</param>
/// <returns>The resulting number from the shift operation</returns>
public static int URShift(int number, long bits)
{
return URShift(number, (int)bits);
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
/// <param name="number">Number to operate on</param>
/// <param name="bits">Ammount of bits to shift</param>
/// <returns>The resulting number from the shift operation</returns>
public static long URShift(long number, int bits)
{
if (number >= 0)
return number >> bits;
else
return (number >> bits) + (2L << ~bits);
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
/// <param name="number">Number to operate on</param>
/// <param name="bits">Ammount of bits to shift</param>
/// <returns>The resulting number from the shift operation</returns>
public static long URShift(long number, long bits)
{
return URShift(number, (int)bits);
}
/// <summary>
/// Fills the array with an specific value from an specific index to an specific index.
/// </summary>
/// <param name="array">The array to be filled.</param>
/// <param name="fromindex">The first index to be filled.</param>
/// <param name="toindex">The last index to be filled.</param>
/// <param name="val">The value to fill the array with.</param>
public static void Fill<T>(T[] array, int fromindex, int toindex, T val) where T : struct
{
if (array.Length == 0)
{
throw new NullReferenceException();
}
if (fromindex > toindex)
{
throw new ArgumentException();
}
if ((fromindex < 0) || ((System.Array)array).Length < toindex)
{
throw new IndexOutOfRangeException();
}
for (int index = (fromindex > 0) ? fromindex-- : fromindex; index < toindex; index++)
{
array[index] = val;
}
}
/// <summary>
/// Fills the array with an specific value.
/// </summary>
/// <param name="array">The array to be filled.</param>
/// <param name="val">The value to fill the array with.</param>
public static void Fill<T>(T[] array, T val) where T : struct
{
Fill(array, 0, array.Length, val);
}
public static void SetSize(this List<byte> list, int count)
{
if (count > list.Count)
{
for (int i = list.Count; i < count; i++)
{
list.Add(0x0);
}
}
else
{
byte[] temp = new byte[count];
list.CopyTo(temp, 0);
list.Clear();
list.AddRange(temp);
}
}
/// <summary> Read a int value from the byte array at the given position (Big Endian)
///
/// </summary>
/// <param name="array">the array to read from
/// </param>
/// <param name="pos">the offset
/// </param>
/// <returns> the value
/// </returns>
public static int readIntBigEndian(byte[] array, int pos)
{
int temp = 0;
temp |= array[pos] & 0xff;
temp <<= 8;
temp |= array[pos + 1] & 0xff;
temp <<= 8;
temp |= array[pos + 2] & 0xff;
temp <<= 8;
temp |= array[pos + 3] & 0xff;
return temp;
}
/// <summary> Read a short value from the byte array at the given position (little
/// Endian)
///
/// </summary>
/// <param name="array">the array to read from
/// </param>
/// <param name="pos">the offset
/// </param>
/// <returns> the value
/// </returns>
public static short readShortLittleEndian(byte[] array, int pos)
{
return BitConverter.ToInt16(array, pos);
}
/// <summary> Read an int value from the byte array at the given position (little
/// Endian)
///
/// </summary>
/// <param name="array">the array to read from
/// </param>
/// <param name="pos">the offset
/// </param>
/// <returns> the value
/// </returns>
public static int readIntLittleEndian(byte[] array, int pos)
{
return BitConverter.ToInt32(array, pos);
}
/// <summary> Write an int value into the byte array at the given position (Big endian)
///
/// </summary>
/// <param name="array">the array
/// </param>
/// <param name="pos">the offset
/// </param>
/// <param name="value">the value to write
/// </param>
public static void writeIntBigEndian(byte[] array, int pos, int value)
{
array[pos] = (byte)((Utility.URShift(value, 24)) & 0xff);
array[pos + 1] = (byte)((Utility.URShift(value, 16)) & 0xff);
array[pos + 2] = (byte)((Utility.URShift(value, 8)) & 0xff);
array[pos + 3] = (byte)((value) & 0xff);
}
/// <summary> Write a short value into the byte array at the given position (little
/// endian)
///
/// </summary>
/// <param name="array">the array
/// </param>
/// <param name="pos">the offset
/// </param>
/// <param name="value">the value to write
/// </param>
#if PORTABLE || NETFX_CORE
public static void WriteLittleEndian(byte[] array, int pos, short value)
{
byte[] newBytes = BitConverter.GetBytes(value);
Array.Copy(newBytes, 0, array, pos, newBytes.Length);
}
#else
public static unsafe void WriteLittleEndian(byte[] array, int pos, short value)
{
fixed (byte* numRef = &(array[pos]))
{
*((short*)numRef) = value;
}
}
#endif
/// <summary> Increment a short value at the specified position by the specified amount
/// (little endian).
/// </summary>
public static void incShortLittleEndian(byte[] array, int pos, short incrementValue)
{
short existingValue = BitConverter.ToInt16(array, pos);
existingValue += incrementValue;
WriteLittleEndian(array, pos, existingValue);
//int c = Utility.URShift(((array[pos] & 0xff) + (dv & 0xff)), 8);
//array[pos] = (byte)(array[pos] + (dv & 0xff));
//if ((c > 0) || ((dv & 0xff00) != 0))
//{
// array[pos + 1] = (byte)(array[pos + 1] + ((Utility.URShift(dv, 8)) & 0xff) + c);
//}
}
/// <summary> Write an int value into the byte array at the given position (little
/// endian)
///
/// </summary>
/// <param name="array">the array
/// </param>
/// <param name="pos">the offset
/// </param>
/// <param name="value">the value to write
/// </param>
#if PORTABLE || NETFX_CORE
public static void WriteLittleEndian(byte[] array, int pos, int value)
{
byte[] newBytes = BitConverter.GetBytes(value);
Array.Copy(newBytes, 0, array, pos, newBytes.Length);
}
#else
public static unsafe void WriteLittleEndian(byte[] array, int pos, int value)
{
fixed (byte* numRef = &(array[pos]))
{
*((int*)numRef) = value;
}
}
#endif
public static void Initialize<T>(this T[] array, Func<T> func)
{
for (int i = 0; i < array.Length; i++)
{
array[i] = func();
}
}
public static void AddRange<T>(this ICollection<T> destination, IEnumerable<T> source)
{
foreach (T item in source)
{
destination.Add(item);
}
}
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
{
foreach (T item in items)
{
action(item);
}
}
public static IEnumerable<T> AsEnumerable<T>(this T item)
{
yield return item;
}
public static void CheckNotNull(this object obj, string name)
{
if (obj == null)
{
throw new ArgumentNullException(name);
}
}
public static void CheckNotNullOrEmpty(this string obj, string name)
{
obj.CheckNotNull(name);
if (obj.Length == 0)
{
throw new ArgumentException("String is empty.");
}
}
public static void Skip(this Stream source, long advanceAmount)
{
byte[] buffer = new byte[32 * 1024];
int read = 0;
int readCount = 0;
do
{
readCount = buffer.Length;
if (readCount > advanceAmount)
{
readCount = (int)advanceAmount;
}
read = source.Read(buffer, 0, readCount);
if (read < 0)
{
break;
}
advanceAmount -= read;
if (advanceAmount == 0)
{
break;
}
} while (true);
}
public static void SkipAll(this Stream source)
{
byte[] buffer = new byte[32 * 1024];
do
{
} while (source.Read(buffer, 0, buffer.Length) == buffer.Length);
}
public static byte[] UInt32ToBigEndianBytes(uint x)
{
return new byte[]
{
(byte) ((x >> 24) & 0xff),
(byte) ((x >> 16) & 0xff),
(byte) ((x >> 8) & 0xff),
(byte) (x & 0xff)
};
}
public static DateTime DosDateToDateTime(UInt16 iDate, UInt16 iTime)
{
int year = iDate / 512 + 1980;
int month = iDate % 512 / 32;
int day = iDate % 512 % 32;
int hour = iTime / 2048;
int minute = iTime % 2048 / 32;
int second = iTime % 2048 % 32 * 2;
if (iDate == UInt16.MaxValue || month == 0 || day == 0)
{
year = 1980;
month = 1;
day = 1;
}
if (iTime == UInt16.MaxValue)
{
hour = minute = second = 0;
}
DateTime dt;
try
{
dt = new DateTime(year, month, day, hour, minute, second);
}
catch
{
dt = new DateTime();
}
return dt;
}
public static uint DateTimeToDosTime(this DateTime? dateTime)
{
if (dateTime == null)
{
return 0;
}
return (uint)(
(dateTime.Value.Second / 2) | (dateTime.Value.Minute << 5) | (dateTime.Value.Hour << 11) |
(dateTime.Value.Day << 16) | (dateTime.Value.Month << 21) |
((dateTime.Value.Year - 1980) << 25));
}
public static DateTime DosDateToDateTime(UInt32 iTime)
{
return DosDateToDateTime((UInt16)(iTime / 65536),
(UInt16)(iTime % 65536));
}
public static DateTime DosDateToDateTime(Int32 iTime)
{
return DosDateToDateTime((UInt32)iTime);
}
public static long TransferTo(this Stream source, Stream destination)
{
byte[] array = new byte[4096];
int count;
long total = 0;
while ((count = source.Read(array, 0, array.Length)) != 0)
{
total += count;
destination.Write(array, 0, count);
}
return total;
}
public static bool ReadFully(this Stream stream, byte[] buffer)
{
int total = 0;
int read;
while ((read = stream.Read(buffer, total, buffer.Length - total)) > 0)
{
total += read;
if (total >= buffer.Length)
{
return true;
}
}
return (total >= buffer.Length);
}
public static string TrimNulls(this string source)
{
return source.Replace('\0', ' ').Trim();
}
public static bool BinaryEquals(this byte[] source, byte[] target)
{
if (source.Length != target.Length)
{
return false;
}
for (int i = 0; i < source.Length; ++i)
{
if (source[i] != target[i])
{
return false;
}
}
return true;
}
internal static void Extract<TEntry, TVolume>(this TEntry entry,
AbstractArchive<TEntry, TVolume> archive, Stream streamToWriteTo)
where TEntry : IArchiveEntry
where TVolume : IVolume
{
if (entry.IsDirectory)
{
throw new ExtractionException("Entry is a file directory and cannot be extracted.");
}
archive.EnsureEntriesLoaded();
archive.FireEntryExtractionBegin(entry);
((IStreamListener)archive).FireFilePartExtractionBegin(entry.FilePath, entry.Size, entry.CompressedSize);
using (Stream s = new ListeningStream(archive, entry.OpenEntryStream()))
{
s.TransferTo(streamToWriteTo);
}
archive.FireEntryExtractionEnd(entry);
}
#if PORTABLE || NETFX_CORE
public static void CopyTo(this byte[] array, byte[] destination, int index)
{
Array.Copy(array, 0, destination, index, array.Length);
}
public static long HostToNetworkOrder(long host)
{
return (int)((long)HostToNetworkOrder((int)host)
& unchecked((long)(unchecked((ulong)-1))) << 32
| ((long)HostToNetworkOrder((int)((int)host >> 32)) & unchecked((long)(unchecked((ulong)-1)))));
}
public static int HostToNetworkOrder(int host)
{
return (int)((int)(HostToNetworkOrder((short)host) & -1) << 16 | (HostToNetworkOrder((short)(host >> 16)) & -1));
}
public static short HostToNetworkOrder(short host)
{
return (short)((int)(host & 255) << 8 | ((int)host >> 8 & 255));
}
public static long NetworkToHostOrder(long network)
{
return HostToNetworkOrder(network);
}
public static int NetworkToHostOrder(int network)
{
return HostToNetworkOrder(network);
}
public static short NetworkToHostOrder(short network)
{
return HostToNetworkOrder(network);
}
#endif
}
}

View File

@@ -1,15 +0,0 @@
using System.Reflection;
#if !PORTABLE
using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
#endif
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright © Adam Hathcock")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.10.3.0")]
[assembly: AssemblyFileVersion("0.10.3.0")]

View File

@@ -1,47 +0,0 @@
using System;
using System.IO;
using SharpCompress.Common;
using SharpCompress.Writer.GZip;
using SharpCompress.Writer.Tar;
using SharpCompress.Writer.Zip;
namespace SharpCompress.Writer
{
public static class WriterFactory
{
public static IWriter Open(Stream stream, ArchiveType archiveType, CompressionType compressionType)
{
return Open(stream, archiveType, new CompressionInfo
{
Type = compressionType
});
}
public static IWriter Open(Stream stream, ArchiveType archiveType, CompressionInfo compressionInfo)
{
switch (archiveType)
{
case ArchiveType.GZip:
{
if (compressionInfo.Type != CompressionType.GZip)
{
throw new InvalidFormatException("GZip archives only support GZip compression type.");
}
return new GZipWriter(stream);
}
case ArchiveType.Zip:
{
return new ZipWriter(stream, compressionInfo, null);
}
case ArchiveType.Tar:
{
return new TarWriter(stream, compressionInfo);
}
default:
{
throw new NotSupportedException("Archive Type does not have a Writer: " + archiveType);
}
}
}
}
}

View File

@@ -1,60 +0,0 @@
using System;
using System.IO;
using System.Text;
using SharpCompress.Common.Zip;
using SharpCompress.Common.Zip.Headers;
namespace SharpCompress.Writer.Zip
{
internal class ZipCentralDirectoryEntry
{
internal string FileName { get; set; }
internal DateTime? ModificationTime { get; set; }
internal string Comment { get; set; }
internal uint Crc { get; set; }
internal uint HeaderOffset { get; set; }
internal uint Compressed { get; set; }
internal uint Decompressed { get; set; }
internal uint Write(Stream outputStream, ZipCompressionMethod compression)
{
byte[] encodedFilename = Encoding.UTF8.GetBytes(FileName);
byte[] encodedComment = Encoding.UTF8.GetBytes(Comment);
outputStream.Write(new byte[] {80, 75, 1, 2, 0x3F, 0, 0x0A, 0}, 0, 8);
HeaderFlags flags = HeaderFlags.UTF8;
if (!outputStream.CanSeek)
{
flags |= HeaderFlags.UsePostDataDescriptor;
if (compression == ZipCompressionMethod.LZMA)
{
flags |= HeaderFlags.Bit1; // eos marker
}
}
outputStream.Write(BitConverter.GetBytes((ushort) flags), 0, 2);
outputStream.Write(BitConverter.GetBytes((ushort) compression), 0, 2); // zipping method
outputStream.Write(BitConverter.GetBytes(ModificationTime.DateTimeToDosTime()), 0, 4);
// zipping date and time
outputStream.Write(BitConverter.GetBytes(Crc), 0, 4); // file CRC
outputStream.Write(BitConverter.GetBytes(Compressed), 0, 4); // compressed file size
outputStream.Write(BitConverter.GetBytes(Decompressed), 0, 4); // uncompressed file size
outputStream.Write(BitConverter.GetBytes((ushort) encodedFilename.Length), 0, 2); // Filename in zip
outputStream.Write(BitConverter.GetBytes((ushort) 0), 0, 2); // extra length
outputStream.Write(BitConverter.GetBytes((ushort) encodedComment.Length), 0, 2);
outputStream.Write(BitConverter.GetBytes((ushort) 0), 0, 2); // disk=0
outputStream.Write(BitConverter.GetBytes((ushort) 0), 0, 2); // file type: binary
outputStream.Write(BitConverter.GetBytes((ushort) 0), 0, 2); // Internal file attributes
outputStream.Write(BitConverter.GetBytes((ushort) 0x8100), 0, 2);
// External file attributes (normal/readable)
outputStream.Write(BitConverter.GetBytes(HeaderOffset), 0, 4); // Offset of header
outputStream.Write(encodedFilename, 0, encodedFilename.Length);
outputStream.Write(encodedComment, 0, encodedComment.Length);
return (uint) (8 + 2 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + 2
+ 2 + 2 + 2 + 2 + 4 + encodedFilename.Length + encodedComment.Length);
}
}
}

View File

@@ -1,320 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using SharpCompress.Common;
using SharpCompress.Common.Zip;
using SharpCompress.Common.Zip.Headers;
using SharpCompress.Compressor;
using SharpCompress.Compressor.BZip2;
using SharpCompress.Compressor.Deflate;
using SharpCompress.Compressor.LZMA;
using SharpCompress.Compressor.PPMd;
using SharpCompress.IO;
using DeflateStream = SharpCompress.Compressor.Deflate.DeflateStream;
namespace SharpCompress.Writer.Zip
{
public class ZipWriter : AbstractWriter
{
private readonly ZipCompressionMethod compression;
private readonly CompressionLevel deflateCompressionLevel;
private readonly List<ZipCentralDirectoryEntry> entries = new List<ZipCentralDirectoryEntry>();
private readonly string zipComment;
private long streamPosition;
private readonly PpmdProperties ppmdProperties; // Caching properties to speed up PPMd.
public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment)
: base(ArchiveType.Zip)
{
this.zipComment = zipComment ?? string.Empty;
switch (compressionInfo.Type)
{
case CompressionType.None:
{
compression = ZipCompressionMethod.None;
}
break;
case CompressionType.Deflate:
{
compression = ZipCompressionMethod.Deflate;
deflateCompressionLevel = compressionInfo.DeflateCompressionLevel;
}
break;
case CompressionType.BZip2:
{
compression = ZipCompressionMethod.BZip2;
}
break;
case CompressionType.LZMA:
{
compression = ZipCompressionMethod.LZMA;
}
break;
case CompressionType.PPMd:
{
ppmdProperties = new PpmdProperties();
compression = ZipCompressionMethod.PPMd;
}
break;
default:
throw new InvalidFormatException("Invalid compression method: " + compressionInfo.Type);
}
InitalizeStream(destination, false);
}
protected override void Dispose(bool isDisposing)
{
if (isDisposing)
{
uint size = 0;
foreach (ZipCentralDirectoryEntry entry in entries)
{
size += entry.Write(OutputStream, compression);
}
WriteEndRecord(size);
}
base.Dispose(isDisposing);
}
public override void Write(string entryPath, Stream source, DateTime? modificationTime)
{
Write(entryPath, source, modificationTime, null);
}
public void Write(string entryPath, Stream source, DateTime? modificationTime, string comment)
{
using (Stream output = WriteToStream(entryPath, modificationTime, comment))
{
source.TransferTo(output);
}
}
public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment)
{
entryPath = NormalizeFilename(entryPath);
modificationTime = modificationTime ?? DateTime.Now;
comment = comment ?? "";
var entry = new ZipCentralDirectoryEntry
{
Comment = comment,
FileName = entryPath,
ModificationTime = modificationTime,
HeaderOffset = (uint) streamPosition,
};
var headersize = (uint) WriteHeader(entryPath, modificationTime);
streamPosition += headersize;
return new ZipWritingStream(this, OutputStream, entry);
}
private string NormalizeFilename(string filename)
{
filename = filename.Replace('\\', '/');
int pos = filename.IndexOf(':');
if (pos >= 0)
filename = filename.Remove(0, pos + 1);
return filename.Trim('/');
}
private int WriteHeader(string filename, DateTime? modificationTime)
{
byte[] encodedFilename = Encoding.UTF8.GetBytes(filename);
OutputStream.Write(BitConverter.GetBytes(ZipHeaderFactory.ENTRY_HEADER_BYTES), 0, 4);
OutputStream.Write(new byte[] {63, 0}, 0, 2); //version
HeaderFlags flags = HeaderFlags.UTF8;
if (!OutputStream.CanSeek)
{
flags |= HeaderFlags.UsePostDataDescriptor;
if (compression == ZipCompressionMethod.LZMA)
{
flags |= HeaderFlags.Bit1; // eos marker
}
}
OutputStream.Write(BitConverter.GetBytes((ushort) flags), 0, 2);
OutputStream.Write(BitConverter.GetBytes((ushort) compression), 0, 2); // zipping method
OutputStream.Write(BitConverter.GetBytes(modificationTime.DateTimeToDosTime()), 0, 4);
// zipping date and time
OutputStream.Write(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 12);
// unused CRC, un/compressed size, updated later
OutputStream.Write(BitConverter.GetBytes((ushort) encodedFilename.Length), 0, 2); // filename length
OutputStream.Write(BitConverter.GetBytes((ushort) 0), 0, 2); // extra length
OutputStream.Write(encodedFilename, 0, encodedFilename.Length);
return 6 + 2 + 2 + 4 + 12 + 2 + 2 + encodedFilename.Length;
}
private void WriteFooter(uint crc, uint compressed, uint uncompressed)
{
OutputStream.Write(BitConverter.GetBytes(crc), 0, 4);
OutputStream.Write(BitConverter.GetBytes(compressed), 0, 4);
OutputStream.Write(BitConverter.GetBytes(uncompressed), 0, 4);
}
private void WriteEndRecord(uint size)
{
byte[] encodedComment = Encoding.UTF8.GetBytes(zipComment);
OutputStream.Write(new byte[] {80, 75, 5, 6, 0, 0, 0, 0}, 0, 8);
OutputStream.Write(BitConverter.GetBytes((ushort) entries.Count), 0, 2);
OutputStream.Write(BitConverter.GetBytes((ushort) entries.Count), 0, 2);
OutputStream.Write(BitConverter.GetBytes(size), 0, 4);
OutputStream.Write(BitConverter.GetBytes((uint) streamPosition), 0, 4);
OutputStream.Write(BitConverter.GetBytes((ushort) encodedComment.Length), 0, 2);
OutputStream.Write(encodedComment, 0, encodedComment.Length);
}
#region Nested type: ZipWritingStream
internal class ZipWritingStream : Stream
{
private readonly CRC32 crc = new CRC32();
private readonly ZipCentralDirectoryEntry entry;
private readonly Stream originalStream;
private readonly Stream writeStream;
private readonly ZipWriter writer;
private CountingWritableSubStream counting;
private uint decompressed;
internal ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry)
{
this.writer = writer;
this.originalStream = originalStream;
writeStream = GetWriteStream(originalStream);
this.writer = writer;
this.entry = entry;
}
public override bool CanRead
{
get { return false; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return true; }
}
public override long Length
{
get { throw new NotSupportedException(); }
}
public override long Position
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
private Stream GetWriteStream(Stream writeStream)
{
counting = new CountingWritableSubStream(writeStream);
Stream output = counting;
switch (writer.compression)
{
case ZipCompressionMethod.None:
{
return output;
}
case ZipCompressionMethod.Deflate:
{
return new DeflateStream(counting, CompressionMode.Compress, writer.deflateCompressionLevel,
true);
}
case ZipCompressionMethod.BZip2:
{
return new BZip2Stream(counting, CompressionMode.Compress, true);
}
case ZipCompressionMethod.LZMA:
{
counting.WriteByte(9);
counting.WriteByte(20);
counting.WriteByte(5);
counting.WriteByte(0);
LzmaStream lzmaStream = new LzmaStream(new LzmaEncoderProperties(!originalStream.CanSeek),
false, counting);
counting.Write(lzmaStream.Properties, 0, lzmaStream.Properties.Length);
return lzmaStream;
}
case ZipCompressionMethod.PPMd:
{
counting.Write(writer.ppmdProperties.Properties, 0, 2);
return new PpmdStream(writer.ppmdProperties, counting, true);
}
default:
{
throw new NotSupportedException("CompressionMethod: " + writer.compression);
}
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
writeStream.Dispose();
entry.Crc = (uint) crc.Crc32Result;
entry.Compressed = counting.Count;
entry.Decompressed = decompressed;
if (originalStream.CanSeek)
{
originalStream.Position = entry.HeaderOffset + 6;
originalStream.WriteByte(0);
originalStream.Position = entry.HeaderOffset + 14;
writer.WriteFooter(entry.Crc, counting.Count, decompressed);
originalStream.Position = writer.streamPosition + entry.Compressed;
writer.streamPosition += entry.Compressed;
}
else
{
originalStream.Write(BitConverter.GetBytes(ZipHeaderFactory.POST_DATA_DESCRIPTOR), 0, 4);
writer.WriteFooter(entry.Crc, counting.Count, decompressed);
writer.streamPosition += entry.Compressed + 16;
}
writer.entries.Add(entry);
}
}
public override void Flush()
{
writeStream.Flush();
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
public override void SetLength(long value)
{
throw new NotSupportedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
decompressed += (uint) count;
crc.SlurpBlock(buffer, offset, count);
writeStream.Write(buffer, offset, count);
}
}
#endregion
}
}

View File

@@ -1,129 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeEditing/ContextActionTable/DisabledContextActions/=JetBrains_002EReSharper_002EIntentions_002ECSharp_002EContextActions_002ECatchToCatchExceptionAction/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/AutoCompleteBasicCompletion/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/IntelliSenseCompletingCharactersSettingCSharp/UpgradedFromVSSettings/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntellisenseEnabled/IntellisenseEnabledSettingCSharp/IntellisenseEnabled/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntellisenseEnabled/IntellisenseEnabledSettingXaml/IntellisenseEnabled/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowSummary/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Localization/CSharpLocalizationOptions/DontAnalyseVerbatimStrings/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecpp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Eh/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ClassCanBeSealed_002EGlobal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ClassCanBeSealed_002ELocal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ConvertIfStatementToReturnStatement_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ConvertIfStatementToSwitchStatement_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022ConvertToAutoPropertyWithPrivateSetter_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022InvertIf_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022LoopCanBePartlyConvertedToQuery_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022MemberCanBeInternal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022MemberCanBeMadeStatic_002EGlobal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022MemberCanBeMadeStatic_002ELocal_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022RedundantArgumentNameForLiteralExpression_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022RedundantToStringCallForValueType_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022SimilarAnonymousTypeNearby_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022SuggestBaseTypeForParameter_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022SuggestUseVarKeywordEverywhere_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022TryStatementsCanBeMerged_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022UnknownCssVendorExtension_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CConfigurableSeverity_0020Id_003D_0022Xaml_002EBindingWithoutContextReferenceNotResolvedHighlighting_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/CodeIssueFilter/IssueTypesToHide/=_003CStaticSeverity_0020Severity_003D_00222_0022_0020Title_003D_0022Structural_0020Search_0020Hints_0022_0020GroupId_003D_0022StructuralSearch_0022_0020_002F_003E/@EntryIndexedValue">DoHide</s:String>
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IdentifierHighlightingEnabled/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FieldCanBeMadeReadOnly_002EGlobal/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FieldCanBeMadeReadOnly_002ELocal/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ImpureMethodCallOnReadonlyValueField/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleAssignmentToReadonlyField/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantThisQualifier/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SpecifyACultureInStringConversionExplicitly/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEverywhere/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnassignedReadonlyField/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Adam_0020Clean/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Adam Clean"&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;ALWAYS_IMPLICIT&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_IMPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;JsInsertSemicolon&gt;True&lt;/JsInsertSemicolon&gt;&lt;JsReformatCode&gt;True&lt;/JsReformatCode&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=NaaS_0020Clean/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="NaaS Clean"&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">NaaS Clean</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Default: Full Cleanup</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_FIRST_ARG_BY_PAREN/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_ATTRIBUTE_STYLE/@EntryValue">SEPARATE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_CHOP_COMPOUND_DO_EXPRESSION/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_CHOP_COMPOUND_IF_EXPRESSION/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_CHOP_COMPOUND_WHILE_EXPRESSION/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FIXED_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOR_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOREACH_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_ANONYMOUS_METHOD_BLOCK/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CONSTRUCTOR_INITIALIZER_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_INITIALIZER_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_LINQ_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_TYPE_CONSTRAINTS_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_WHILE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_SIZEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_BINARY_OPSIGN/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_CHAINED_METHOD_CALLS/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_FOR_STMT_HEADER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_TYPE_PARAMEER_CONSTRAINTS_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_OBJECT_AND_COLLECTION_INITIALIZER_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/JavaScriptCodeFormatting/JavaScriptFormatOther/ALIGN_MULTIPLE_DECLARATION/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Constructor/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Constructor/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Global/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Global/Options/=PropertyBody/@EntryIndexedValue">Automatic property</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=WrapInRegion/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Overrides/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=WrapInRegion/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Properties/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Properties/Options/=DebuggerStepsThrough/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Properties/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=ReadProperties/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=ReadProperties/Options/=DebuggerStepsThrough/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=ReadProperties/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EC/@EntryIndexedValue">EC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IIS/@EntryIndexedValue">IIS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Other/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/EventHandlerPatternLong/@EntryValue">$object$_On$event$</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Other/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/VBNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String></wpf:ResourceDictionary>

131
USAGE.md Normal file
View File

@@ -0,0 +1,131 @@
# SharpCompress Usage
## Stream Rules
When dealing with Streams, the rule should be that you don't close a stream you didn't create. This, in effect, should mean you should always put a Stream in a using block to dispose it.
However, the .NET Framework often has classes that will dispose streams by default to make things "easy" like the following:
```C#
using (var reader = new StreamReader(File.Open("foo")))
{
...
}
```
In this example, reader should get disposed. However, stream rules should say the the `FileStream` created by `File.Open` should remain open. However, the .NET Framework closes it for you by default unless you override the constructor. In general, you should be writing Stream code like this:
```C#
using (var fileStream = File.Open("foo"))
using (var reader = new StreamReader(fileStream))
{
...
}
```
To deal with the "correct" rules as well as the expectations of users, I've decided on this:
* When writing, leave streams open.
* When reading, close streams
To be explicit though, consider always using the overloads that use `ReaderOptions` or `WriterOptions` and explicitly set `LeaveStreamOpen` the way you want.
## Samples
Also, look over the tests for more thorough [examples](https://github.com/adamhathcock/sharpcompress/tree/master/test/SharpCompress.Test)
### Create Zip Archive from all files in a directory to a file
```C#
using (var archive = ZipArchive.Create())
{
archive.AddAllFromDirectory("D:\\temp");
archive.SaveTo("C:\\temp.zip", CompressionType.Deflate);
}
```
### Create Zip Archive from all files in a directory and save in memory
```C#
var memoryStream = new MemoryStream();
using (var archive = ZipArchive.Create())
{
archive.AddAllFromDirectory("D:\\temp");
archive.SaveTo(memoryStream, new WriterOptions(CompressionType.Deflate)
{
LeaveStreamOpen = true
});
}
//reset memoryStream to be usable now
memoryStream.Position = 0;
```
### Extract all files from a Rar file to a directory using RarArchive
```C#
using (var archive = RarArchive.Open("Test.rar"))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory("D:\\temp", new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
}
```
### Use ReaderFactory to autodetect archive type and Open the entry stream
```C#
using (Stream stream = File.OpenRead("Tar.tar.bz2"))
using (var reader = ReaderFactory.Open(stream))
{
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
Console.WriteLine(reader.Entry.Key);
reader.WriteEntryToDirectory(@"C:\temp", new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
}
}
```
### Use ReaderFactory to autodetect archive type and Open the entry stream
```C#
using (Stream stream = File.OpenRead("Tar.tar.bz2"))
using (var reader = ReaderFactory.Open(stream))
{
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
using (var entryStream = reader.OpenEntryStream())
{
entryStream.CopyTo(...);
}
}
}
}
```
### Use WriterFactory to write all files from a directory in a streaming manner.
```C#
using (Stream stream = File.OpenWrite("C:\\temp.tgz"))
using (var writer = WriterFactory.Open(stream, ArchiveType.Tar, new WriterOptions(CompressionType.GZip)
{
LeaveOpenStream = true
}))
{
writer.WriteAll("D:\\temp", "*", SearchOption.AllDirectories);
}
```

17
appveyor.yml Normal file
View File

@@ -0,0 +1,17 @@
version: '0.15.{build}'
init:
- git config --global core.autocrlf true
build_script:
- ps: .\build.ps1
test: off
cache:
- tools -> build.cake
- tools -> build.ps1
artifacts:
- path: nupkgs\*.nupkg
name: NuPkgs

229
build.cake Normal file
View File

@@ -0,0 +1,229 @@
#addin "Cake.Json"
#addin "nuget:?package=NuGet.Core"
using NuGet;
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var apiKey = Argument("apiKey", "");
var repo = Argument("repo", "");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var sources = new [] { "https://api.nuget.org/v3/index.json" };
var publishTarget = "";
Warning("=============");
var globalPath = MakeFullPath("global.json");
var nupkgs = MakeFullPath("nupkgs");
Warning("Operating on global.json: " + globalPath);
Warning("=============");
//////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////
string MakeFullPath(string relativePath)
{
if (string.IsNullOrEmpty(repo))
{
return MakeAbsolute(new DirectoryPath(relativePath)).ToString();
}
if (!System.IO.Path.IsPathRooted(repo))
{
return MakeAbsolute(new DirectoryPath(System.IO.Path.Combine(repo,relativePath))).ToString();
}
return System.IO.Path.Combine(repo, relativePath);
}
IEnumerable<string> GetAllProjects()
{
var global = DeserializeJsonFromFile<JObject>(globalPath);
var projs = global["projects"].Select(x => x.ToString());
foreach(var y in projs)
{
yield return MakeFullPath(y);
}
}
IEnumerable<string> GetSourceProjects()
{
return GetAllProjects().Where(x => x.EndsWith("src"));
}
IEnumerable<string> GetTestProjects()
{
return GetAllProjects().Where(x => x.EndsWith("test"));
}
IEnumerable<string> GetFrameworks(string path)
{
var projectJObject = DeserializeJsonFromFile<JObject>(path);
foreach(var prop in ((JObject)projectJObject["frameworks"]).Properties())
{
yield return prop.Name;
}
}
string GetVersion(string path)
{
var projectJObject = DeserializeJsonFromFile<JObject>(path);
return ((JToken)projectJObject["version"]).ToString();
}
IEnumerable<string> GetProjectJsons(IEnumerable<string> projects)
{
foreach(var proj in projects)
{
foreach(var projectJson in GetFiles(proj + "/**/project.json"))
{
yield return MakeFullPath(projectJson.ToString());
}
}
}
bool IsNuGetPublished (FilePath file, string nugetSource)
{
var pkg = new ZipPackage(file.ToString());
var repo = PackageRepositoryFactory.Default.CreateRepository(nugetSource);
var packages = repo.FindPackagesById(pkg.Id);
var version = SemanticVersion.Parse(pkg.Version.ToString());
//Filter the list of packages that are not Release (Stable) versions
var exists = packages.Any (p => p.Version == version);
return exists;
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Restore")
.Does(() =>
{
var settings = new DotNetCoreRestoreSettings
{
Sources = sources,
NoCache = true
};
foreach(var project in GetProjectJsons(GetSourceProjects().Concat(GetTestProjects())))
{
DotNetCoreRestore(project, settings);
}
});
Task("Build")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = "Release"
};
foreach(var project in GetProjectJsons(GetSourceProjects().Concat(GetTestProjects())))
{
foreach(var framework in GetFrameworks(project))
{
Information("Building: {0} on Framework: {1}", project, framework);
Information("========");
settings.Framework = framework;
DotNetCoreBuild(project, settings);
}
}
});
Task("Test")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
Verbose = true
};
foreach(var project in GetProjectJsons(GetTestProjects()))
{
settings.Framework = GetFrameworks(project).First();
DotNetCoreTest(project.ToString(), settings);
}
}).ReportError(exception =>
{
Error(exception.ToString());
});
Task("Pack")
.Does(() =>
{
if (DirectoryExists(nupkgs))
{
DeleteDirectory(nupkgs, true);
}
CreateDirectory(nupkgs);
var settings = new DotNetCorePackSettings
{
Configuration = "Release",
OutputDirectory = nupkgs
};
foreach(var project in GetProjectJsons(GetSourceProjects()))
{
DotNetCorePack(project, settings);
}
});
Task("Publish")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack")
.Does(() =>
{
var packages = GetFiles(nupkgs + "/*.nupkg");
foreach(var package in packages)
{
if (package.ToString().Contains("symbols"))
{
Warning("Skipping Symbols package " + package);
continue;
}
if (IsNuGetPublished(package, sources[1]))
{
throw new InvalidOperationException(package + " is already published.");
}
NuGetPush(package, new NuGetPushSettings{
ApiKey = apiKey,
Verbosity = NuGetVerbosity.Detailed,
Source = publishTarget
});
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);

130
build.ps1 Normal file
View File

@@ -0,0 +1,130 @@
<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
.DESCRIPTION
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
and execute your Cake build script with the parameters you provide.
.PARAMETER Target
The build script target to run.
.PARAMETER Configuration
The build configuration to use.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER ScriptArgs
Remaining arguments are added here.
.LINK
http://cakebuild.net
#>
[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$WhatIf,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
$CakeVersion = "0.16.1"
$DotNetChannel = "preview";
$DotNetVersion = "1.0.0-preview2-003131";
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1";
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
$ToolPath = Join-Path $PSScriptRoot "tools"
if (!(Test-Path $ToolPath)) {
Write-Verbose "Creating tools directory..."
New-Item -Path $ToolPath -Type directory | out-null
}
###########################################################################
# INSTALL .NET CORE CLI
###########################################################################
Function Remove-PathVariable([string]$VariableToRemove)
{
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($path -ne $null)
{
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
}
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
if ($path -ne $null)
{
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
}
}
# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
}
if($FoundDotNetCliVersion -ne $DotNetVersion) {
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
mkdir -Force $InstallPath | Out-Null;
}
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
}
###########################################################################
# INSTALL NUGET
###########################################################################
# Make sure nuget.exe exists.
$NugetPath = Join-Path $ToolPath "nuget.exe"
if (!(Test-Path $NugetPath)) {
Write-Host "Downloading NuGet.exe..."
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
}
###########################################################################
# INSTALL CAKE
###########################################################################
# Make sure Cake has been installed.
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
if (!(Test-Path $CakePath)) {
Write-Host "Installing Cake..."
Invoke-Expression "&`"$NugetPath`" install Cake -Version $CakeVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
if ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring Cake from NuGet."
}
}
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
# Build the argument list.
$Arguments = @{
target=$Target;
configuration=$Configuration;
verbosity=$Verbosity;
dryrun=$WhatIf;
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
# Start Cake
Write-Host "Running build script..."
Invoke-Expression "& `"$CakePath`" `"$Script`" $Arguments $ScriptArgs"
exit $LASTEXITCODE

3
global.json Normal file
View File

@@ -0,0 +1,3 @@
{
"projects": ["src","test"]
}

View File

@@ -1,205 +1,191 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Reader;
namespace SharpCompress.Archive
{
public abstract class AbstractArchive<TEntry, TVolume> : IArchive, IStreamListener
where TEntry : IArchiveEntry
where TVolume : IVolume
{
private readonly LazyReadOnlyCollection<TVolume> lazyVolumes;
private readonly LazyReadOnlyCollection<TEntry> lazyEntries;
public event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionBegin;
public event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionEnd;
public event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
public event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
#if !PORTABLE && !NETFX_CORE
internal AbstractArchive(ArchiveType type, FileInfo fileInfo, Options options)
{
this.Type = type;
if (!fileInfo.Exists)
{
throw new ArgumentException("File does not exist: " + fileInfo.FullName);
}
options = (Options) FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
lazyVolumes = new LazyReadOnlyCollection<TVolume>(LoadVolumes(fileInfo, options));
lazyEntries = new LazyReadOnlyCollection<TEntry>(LoadEntries(Volumes));
}
protected abstract IEnumerable<TVolume> LoadVolumes(FileInfo file, Options options);
#endif
internal AbstractArchive(ArchiveType type, IEnumerable<Stream> streams, Options options)
{
this.Type = type;
lazyVolumes =
new LazyReadOnlyCollection<TVolume>(LoadVolumes(streams.Select<Stream, Stream>(CheckStreams), options));
lazyEntries = new LazyReadOnlyCollection<TEntry>(LoadEntries(Volumes));
}
internal AbstractArchive(ArchiveType type)
{
this.Type = type;
lazyVolumes = new LazyReadOnlyCollection<TVolume>(Enumerable.Empty<TVolume>());
lazyEntries = new LazyReadOnlyCollection<TEntry>(Enumerable.Empty<TEntry>());
}
internal void FireEntryExtractionBegin(IArchiveEntry entry)
{
if (EntryExtractionBegin != null)
{
EntryExtractionBegin(this, new ArchiveExtractionEventArgs<IArchiveEntry>(entry));
}
}
internal void FireEntryExtractionEnd(IArchiveEntry entry)
{
if (EntryExtractionEnd != null)
{
EntryExtractionEnd(this, new ArchiveExtractionEventArgs<IArchiveEntry>(entry));
}
}
private static Stream CheckStreams(Stream stream)
{
if (!stream.CanSeek || !stream.CanRead)
{
throw new ArgumentException("Archive streams must be Readable and Seekable");
}
return stream;
}
/// <summary>
/// Returns an ReadOnlyCollection of all the RarArchiveEntries across the one or many parts of the RarArchive.
/// </summary>
/// <returns></returns>
public virtual ICollection<TEntry> Entries
{
get { return lazyEntries; }
}
/// <summary>
/// Returns an ReadOnlyCollection of all the RarArchiveVolumes across the one or many parts of the RarArchive.
/// </summary>
/// <returns></returns>
public ICollection<TVolume> Volumes
{
get { return lazyVolumes; }
}
/// <summary>
/// The total size of the files compressed in the archive.
/// </summary>
public long TotalSize
{
get { return Entries.Aggregate(0L, (total, cf) => total + cf.CompressedSize); }
}
protected abstract IEnumerable<TVolume> LoadVolumes(IEnumerable<Stream> streams, Options options);
protected abstract IEnumerable<TEntry> LoadEntries(IEnumerable<TVolume> volumes);
IEnumerable<IArchiveEntry> IArchive.Entries
{
get { return lazyEntries.Cast<IArchiveEntry>(); }
}
IEnumerable<IVolume> IArchive.Volumes
{
get { return lazyVolumes.Cast<IVolume>(); }
}
private bool disposed;
public virtual void Dispose()
{
if (!disposed)
{
lazyVolumes.ForEach(v => v.Dispose());
lazyEntries.GetLoaded().Cast<Entry>().ForEach(x => x.Close());
disposed = true;
}
}
internal void EnsureEntriesLoaded()
{
lazyEntries.EnsureFullyLoaded();
lazyVolumes.EnsureFullyLoaded();
}
public ArchiveType Type { get; private set; }
void IStreamListener.FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes)
{
if (CompressedBytesRead != null)
{
CompressedBytesRead(this, new CompressedBytesReadEventArgs()
{
CurrentFilePartCompressedBytesRead = currentPartCompressedBytes,
CompressedBytesRead = compressedReadBytes
});
}
}
void IStreamListener.FireFilePartExtractionBegin(string name, long size, long compressedSize)
{
if (FilePartExtractionBegin != null)
{
FilePartExtractionBegin(this, new FilePartExtractionBeginEventArgs()
{
CompressedSize = compressedSize,
Size = size,
Name = name,
});
}
}
/// <summary>
/// Use this method to extract all entries in an archive in order.
/// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
/// extracted sequentially for the best performance.
///
/// This method will load all entry information from the archive.
///
/// WARNING: this will reuse the underlying stream for the archive. Errors may
/// occur if this is used at the same time as other extraction methods on this instance.
/// </summary>
/// <returns></returns>
public IReader ExtractAllEntries()
{
EnsureEntriesLoaded();
return CreateReaderForSolidExtraction();
}
protected abstract IReader CreateReaderForSolidExtraction();
/// <summary>
/// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
/// </summary>
public virtual bool IsSolid
{
get { return false; }
}
/// <summary>
/// The archive can find all the parts of the archive needed to fully extract the archive. This forces the parsing of the entire archive.
/// </summary>
public bool IsComplete
{
get
{
EnsureEntriesLoaded();
return Entries.All(x => x.IsComplete);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Readers;
namespace SharpCompress.Archives
{
public abstract class AbstractArchive<TEntry, TVolume> : IArchive, IArchiveExtractionListener
where TEntry : IArchiveEntry
where TVolume : IVolume
{
private readonly LazyReadOnlyCollection<TVolume> lazyVolumes;
private readonly LazyReadOnlyCollection<TEntry> lazyEntries;
public event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionBegin;
public event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionEnd;
public event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
public event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
protected ReaderOptions ReaderOptions { get; }
private bool disposed;
#if !NO_FILE
internal AbstractArchive(ArchiveType type, FileInfo fileInfo, ReaderOptions readerOptions)
{
Type = type;
if (!fileInfo.Exists)
{
throw new ArgumentException("File does not exist: " + fileInfo.FullName);
}
ReaderOptions = readerOptions;
readerOptions.LeaveStreamOpen = false;
lazyVolumes = new LazyReadOnlyCollection<TVolume>(LoadVolumes(fileInfo));
lazyEntries = new LazyReadOnlyCollection<TEntry>(LoadEntries(Volumes));
}
protected abstract IEnumerable<TVolume> LoadVolumes(FileInfo file);
#endif
internal AbstractArchive(ArchiveType type, IEnumerable<Stream> streams, ReaderOptions readerOptions)
{
Type = type;
ReaderOptions = readerOptions;
lazyVolumes = new LazyReadOnlyCollection<TVolume>(LoadVolumes(streams.Select(CheckStreams)));
lazyEntries = new LazyReadOnlyCollection<TEntry>(LoadEntries(Volumes));
}
internal AbstractArchive(ArchiveType type)
{
Type = type;
lazyVolumes = new LazyReadOnlyCollection<TVolume>(Enumerable.Empty<TVolume>());
lazyEntries = new LazyReadOnlyCollection<TEntry>(Enumerable.Empty<TEntry>());
}
public ArchiveType Type { get; }
void IArchiveExtractionListener.FireEntryExtractionBegin(IArchiveEntry entry)
{
if (EntryExtractionBegin != null)
{
EntryExtractionBegin(this, new ArchiveExtractionEventArgs<IArchiveEntry>(entry));
}
}
void IArchiveExtractionListener.FireEntryExtractionEnd(IArchiveEntry entry)
{
if (EntryExtractionEnd != null)
{
EntryExtractionEnd(this, new ArchiveExtractionEventArgs<IArchiveEntry>(entry));
}
}
private static Stream CheckStreams(Stream stream)
{
if (!stream.CanSeek || !stream.CanRead)
{
throw new ArgumentException("Archive streams must be Readable and Seekable");
}
return stream;
}
/// <summary>
/// Returns an ReadOnlyCollection of all the RarArchiveEntries across the one or many parts of the RarArchive.
/// </summary>
public virtual ICollection<TEntry> Entries { get { return lazyEntries; } }
/// <summary>
/// Returns an ReadOnlyCollection of all the RarArchiveVolumes across the one or many parts of the RarArchive.
/// </summary>
public ICollection<TVolume> Volumes { get { return lazyVolumes; } }
/// <summary>
/// The total size of the files compressed in the archive.
/// </summary>
public virtual long TotalSize { get { return Entries.Aggregate(0L, (total, cf) => total + cf.CompressedSize); } }
/// <summary>
/// The total size of the files as uncompressed in the archive.
/// </summary>
public virtual long TotalUncompressSize { get { return Entries.Aggregate(0L, (total, cf) => total + cf.Size); } }
protected abstract IEnumerable<TVolume> LoadVolumes(IEnumerable<Stream> streams);
protected abstract IEnumerable<TEntry> LoadEntries(IEnumerable<TVolume> volumes);
IEnumerable<IArchiveEntry> IArchive.Entries { get { return Entries.Cast<IArchiveEntry>(); } }
IEnumerable<IVolume> IArchive.Volumes { get { return lazyVolumes.Cast<IVolume>(); } }
public virtual void Dispose()
{
if (!disposed)
{
lazyVolumes.ForEach(v => v.Dispose());
lazyEntries.GetLoaded().Cast<Entry>().ForEach(x => x.Close());
disposed = true;
}
}
void IArchiveExtractionListener.EnsureEntriesLoaded()
{
lazyEntries.EnsureFullyLoaded();
lazyVolumes.EnsureFullyLoaded();
}
void IExtractionListener.FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes)
{
if (CompressedBytesRead != null)
{
CompressedBytesRead(this, new CompressedBytesReadEventArgs
{
CurrentFilePartCompressedBytesRead = currentPartCompressedBytes,
CompressedBytesRead = compressedReadBytes
});
}
}
void IExtractionListener.FireFilePartExtractionBegin(string name, long size, long compressedSize)
{
if (FilePartExtractionBegin != null)
{
FilePartExtractionBegin(this, new FilePartExtractionBeginEventArgs
{
CompressedSize = compressedSize,
Size = size,
Name = name
});
}
}
/// <summary>
/// Use this method to extract all entries in an archive in order.
/// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
/// extracted sequentially for the best performance.
///
/// This method will load all entry information from the archive.
///
/// WARNING: this will reuse the underlying stream for the archive. Errors may
/// occur if this is used at the same time as other extraction methods on this instance.
/// </summary>
/// <returns></returns>
public IReader ExtractAllEntries()
{
((IArchiveExtractionListener)this).EnsureEntriesLoaded();
return CreateReaderForSolidExtraction();
}
protected abstract IReader CreateReaderForSolidExtraction();
/// <summary>
/// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
/// </summary>
public virtual bool IsSolid { get { return false; } }
/// <summary>
/// The archive can find all the parts of the archive needed to fully extract the archive. This forces the parsing of the entire archive.
/// </summary>
public bool IsComplete
{
get
{
((IArchiveExtractionListener)this).EnsureEntriesLoaded();
return Entries.All(x => x.IsComplete);
}
}
}
}

View File

@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Readers;
using SharpCompress.Writers;
namespace SharpCompress.Archives
{
public abstract class AbstractWritableArchive<TEntry, TVolume> : AbstractArchive<TEntry, TVolume>, IWritableArchive
where TEntry : IArchiveEntry
where TVolume : IVolume
{
private readonly List<TEntry> newEntries = new List<TEntry>();
private readonly List<TEntry> removedEntries = new List<TEntry>();
private readonly List<TEntry> modifiedEntries = new List<TEntry>();
private bool hasModifications;
internal AbstractWritableArchive(ArchiveType type)
: base(type)
{
}
internal AbstractWritableArchive(ArchiveType type, Stream stream, ReaderOptions readerFactoryOptions)
: base(type, stream.AsEnumerable(), readerFactoryOptions)
{
}
#if !NO_FILE
internal AbstractWritableArchive(ArchiveType type, FileInfo fileInfo, ReaderOptions readerFactoryOptions)
: base(type, fileInfo, readerFactoryOptions)
{
}
#endif
public override ICollection<TEntry> Entries
{
get
{
if (hasModifications)
{
return modifiedEntries;
}
return base.Entries;
}
}
private void RebuildModifiedCollection()
{
hasModifications = true;
newEntries.RemoveAll(v => removedEntries.Contains(v));
modifiedEntries.Clear();
modifiedEntries.AddRange(OldEntries.Concat(newEntries));
}
private IEnumerable<TEntry> OldEntries { get { return base.Entries.Where(x => !removedEntries.Contains(x)); } }
public void RemoveEntry(TEntry entry)
{
if (!removedEntries.Contains(entry))
{
removedEntries.Add(entry);
RebuildModifiedCollection();
}
}
void IWritableArchive.RemoveEntry(IArchiveEntry entry)
{
RemoveEntry((TEntry)entry);
}
public TEntry AddEntry(string key, Stream source,
long size = 0, DateTime? modified = null)
{
return AddEntry(key, source, false, size, modified);
}
IArchiveEntry IWritableArchive.AddEntry(string key, Stream source, bool closeStream, long size, DateTime? modified)
{
return AddEntry(key, source, closeStream, size, modified);
}
public TEntry AddEntry(string key, Stream source, bool closeStream,
long size = 0, DateTime? modified = null)
{
if (key.StartsWith("/")
|| key.StartsWith("\\"))
{
key = key.Substring(1);
}
if (DoesKeyMatchExisting(key))
{
throw new ArchiveException("Cannot add entry with duplicate key: " + key);
}
var entry = CreateEntry(key, source, size, modified, closeStream);
newEntries.Add(entry);
RebuildModifiedCollection();
return entry;
}
private bool DoesKeyMatchExisting(string key)
{
foreach (var path in Entries.Select(x => x.Key))
{
var p = path.Replace('/', '\\');
if (p.StartsWith("\\"))
{
p = p.Substring(1);
}
return string.Equals(p, key, StringComparison.OrdinalIgnoreCase);
}
return false;
}
public void SaveTo(Stream stream, WriterOptions options)
{
//reset streams of new entries
newEntries.Cast<IWritableArchiveEntry>().ForEach(x => x.Stream.Seek(0, SeekOrigin.Begin));
SaveTo(stream, options, OldEntries, newEntries);
}
protected TEntry CreateEntry(string key, Stream source, long size, DateTime? modified,
bool closeStream)
{
if (!source.CanRead || !source.CanSeek)
{
throw new ArgumentException("Streams must be readable and seekable to use the Writing Archive API");
}
return CreateEntryInternal(key, source, size, modified, closeStream);
}
protected abstract TEntry CreateEntryInternal(string key, Stream source, long size, DateTime? modified,
bool closeStream);
protected abstract void SaveTo(Stream stream, WriterOptions options, IEnumerable<TEntry> oldEntries, IEnumerable<TEntry> newEntries);
public override void Dispose()
{
base.Dispose();
newEntries.Cast<Entry>().ForEach(x => x.Close());
removedEntries.Cast<Entry>().ForEach(x => x.Close());
modifiedEntries.Cast<Entry>().ForEach(x => x.Close());
}
}
}

View File

@@ -1,168 +1,157 @@
using System;
using System.IO;
using SharpCompress.Archive.GZip;
using SharpCompress.Archive.Rar;
using SharpCompress.Archive.SevenZip;
using SharpCompress.Archive.Tar;
using SharpCompress.Archive.Zip;
using SharpCompress.Common;
namespace SharpCompress.Archive
{
public class ArchiveFactory
{
/// <summary>
/// Opens an Archive for random access
/// </summary>
/// <param name="stream"></param>
/// <param name="options"></param>
/// <returns></returns>
public static IArchive Open(Stream stream, Options options = Options.KeepStreamsOpen)
{
stream.CheckNotNull("stream");
if (!stream.CanRead || !stream.CanSeek)
{
throw new ArgumentException("Stream should be readable and seekable");
}
if (ZipArchive.IsZipFile(stream, null))
{
stream.Seek(0, SeekOrigin.Begin);
return ZipArchive.Open(stream, options, null);
}
stream.Seek(0, SeekOrigin.Begin);
if (RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
{
stream.Seek(0, SeekOrigin.Begin);
return RarArchive.Open(stream, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (TarArchive.IsTarFile(stream))
{
stream.Seek(0, SeekOrigin.Begin);
return TarArchive.Open(stream, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (SevenZipArchive.IsSevenZipFile(stream))
{
stream.Seek(0, SeekOrigin.Begin);
return SevenZipArchive.Open(stream, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (GZipArchive.IsGZipFile(stream))
{
stream.Seek(0, SeekOrigin.Begin);
return GZipArchive.Open(stream, options);
}
throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
}
public static IArchive Create(ArchiveType type)
{
switch (type)
{
case ArchiveType.Zip:
{
return ZipArchive.Create();
}
case ArchiveType.Tar:
{
return TarArchive.Create();
}
default:
{
throw new NotSupportedException("Cannot create Archives of type: " + type);
}
}
}
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
public static IArchive Open(string filePath)
{
return Open(filePath, Options.None);
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
public static IArchive Open(FileInfo fileInfo)
{
return Open(fileInfo, Options.None);
}
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
/// <param name="options"></param>
public static IArchive Open(string filePath, Options options)
{
filePath.CheckNotNullOrEmpty("filePath");
return Open(new FileInfo(filePath), options);
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
public static IArchive Open(FileInfo fileInfo, Options options)
{
fileInfo.CheckNotNull("fileInfo");
using (var stream = fileInfo.OpenRead())
{
if (ZipArchive.IsZipFile(stream, null))
{
stream.Dispose();
return ZipArchive.Open(fileInfo, options, null);
}
stream.Seek(0, SeekOrigin.Begin);
if (RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
{
stream.Dispose();
return RarArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (TarArchive.IsTarFile(stream))
{
stream.Dispose();
return TarArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (SevenZipArchive.IsSevenZipFile(stream))
{
stream.Dispose();
return SevenZipArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (GZipArchive.IsGZipFile(stream))
{
stream.Dispose();
return GZipArchive.Open(fileInfo, options);
}
throw new InvalidOperationException("Cannot determine compressed stream type.");
}
}
/// <summary>
/// Extract to specific directory, retaining filename
/// </summary>
public static void WriteToDirectory(string sourceArchive, string destinationDirectory,
ExtractOptions options = ExtractOptions.Overwrite)
{
using (IArchive archive = Open(sourceArchive))
{
foreach (IArchiveEntry entry in archive.Entries)
{
entry.WriteToDirectory(destinationDirectory, options);
}
}
}
#endif
}
using System;
using System.IO;
using SharpCompress.Archives.GZip;
using SharpCompress.Archives.Rar;
using SharpCompress.Archives.SevenZip;
using SharpCompress.Archives.Tar;
using SharpCompress.Archives.Zip;
using SharpCompress.Common;
using SharpCompress.Readers;
namespace SharpCompress.Archives
{
public class ArchiveFactory
{
/// <summary>
/// Opens an Archive for random access
/// </summary>
/// <param name="stream"></param>
/// <param name="readerOptions"></param>
/// <returns></returns>
public static IArchive Open(Stream stream, ReaderOptions readerOptions = null)
{
stream.CheckNotNull("stream");
if (!stream.CanRead || !stream.CanSeek)
{
throw new ArgumentException("Stream should be readable and seekable");
}
readerOptions = readerOptions ?? new ReaderOptions();
if (ZipArchive.IsZipFile(stream, null))
{
stream.Seek(0, SeekOrigin.Begin);
return ZipArchive.Open(stream, readerOptions);
}
stream.Seek(0, SeekOrigin.Begin);
if (SevenZipArchive.IsSevenZipFile(stream))
{
stream.Seek(0, SeekOrigin.Begin);
return SevenZipArchive.Open(stream, readerOptions);
}
stream.Seek(0, SeekOrigin.Begin);
if (GZipArchive.IsGZipFile(stream))
{
stream.Seek(0, SeekOrigin.Begin);
return GZipArchive.Open(stream, readerOptions);
}
stream.Seek(0, SeekOrigin.Begin);
if (RarArchive.IsRarFile(stream, readerOptions))
{
stream.Seek(0, SeekOrigin.Begin);
return RarArchive.Open(stream, readerOptions);
}
stream.Seek(0, SeekOrigin.Begin);
if (TarArchive.IsTarFile(stream))
{
stream.Seek(0, SeekOrigin.Begin);
return TarArchive.Open(stream, readerOptions);
}
throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
}
public static IWritableArchive Create(ArchiveType type)
{
switch (type)
{
case ArchiveType.Zip:
{
return ZipArchive.Create();
}
case ArchiveType.Tar:
{
return TarArchive.Create();
}
case ArchiveType.GZip:
{
return GZipArchive.Create();
}
default:
{
throw new NotSupportedException("Cannot create Archives of type: " + type);
}
}
}
#if !NO_FILE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
/// <param name="options"></param>
public static IArchive Open(string filePath, ReaderOptions options = null)
{
filePath.CheckNotNullOrEmpty("filePath");
return Open(new FileInfo(filePath), options ?? new ReaderOptions());
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
public static IArchive Open(FileInfo fileInfo, ReaderOptions options = null)
{
fileInfo.CheckNotNull("fileInfo");
options = options ?? new ReaderOptions();
using (var stream = fileInfo.OpenRead())
{
if (ZipArchive.IsZipFile(stream, null))
{
stream.Dispose();
return ZipArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (SevenZipArchive.IsSevenZipFile(stream))
{
stream.Dispose();
return SevenZipArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (GZipArchive.IsGZipFile(stream))
{
stream.Dispose();
return GZipArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (RarArchive.IsRarFile(stream, options))
{
stream.Dispose();
return RarArchive.Open(fileInfo, options);
}
stream.Seek(0, SeekOrigin.Begin);
if (TarArchive.IsTarFile(stream))
{
stream.Dispose();
return TarArchive.Open(fileInfo, options);
}
throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
}
}
/// <summary>
/// Extract to specific directory, retaining filename
/// </summary>
public static void WriteToDirectory(string sourceArchive, string destinationDirectory,
ExtractionOptions options = null)
{
using (IArchive archive = Open(sourceArchive))
{
foreach (IArchiveEntry entry in archive.Entries)
{
entry.WriteToDirectory(destinationDirectory, options);
}
}
}
#endif
}
}

View File

@@ -1,213 +1,192 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Common.GZip;
using SharpCompress.Reader;
using SharpCompress.Reader.GZip;
using SharpCompress.Writer.GZip;
namespace SharpCompress.Archive.GZip
{
public class GZipArchive : AbstractWritableArchive<GZipArchiveEntry, GZipVolume>
{
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
public static GZipArchive Open(string filePath)
{
return Open(filePath, Options.None);
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
public static GZipArchive Open(FileInfo fileInfo)
{
return Open(fileInfo, Options.None);
}
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
/// <param name="options"></param>
public static GZipArchive Open(string filePath, Options options)
{
filePath.CheckNotNullOrEmpty("filePath");
return Open(new FileInfo(filePath), options);
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
public static GZipArchive Open(FileInfo fileInfo, Options options)
{
fileInfo.CheckNotNull("fileInfo");
return new GZipArchive(fileInfo, options);
}
#endif
/// <summary>
/// Takes a seekable Stream as a source
/// </summary>
/// <param name="stream"></param>
public static GZipArchive Open(Stream stream)
{
stream.CheckNotNull("stream");
return Open(stream, Options.None);
}
/// <summary>
/// Takes a seekable Stream as a source
/// </summary>
/// <param name="stream"></param>
/// <param name="options"></param>
public static GZipArchive Open(Stream stream, Options options)
{
stream.CheckNotNull("stream");
return new GZipArchive(stream, options);
}
#if !PORTABLE && !NETFX_CORE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
internal GZipArchive(FileInfo fileInfo, Options options)
: base(ArchiveType.GZip, fileInfo, options)
{
}
protected override IEnumerable<GZipVolume> LoadVolumes(FileInfo file, Options options)
{
return new GZipVolume(file, options).AsEnumerable();
}
public static bool IsGZipFile(string filePath)
{
return IsGZipFile(new FileInfo(filePath));
}
public static bool IsGZipFile(FileInfo fileInfo)
{
if (!fileInfo.Exists)
{
return false;
}
using (Stream stream = fileInfo.OpenRead())
{
return IsGZipFile(stream);
}
}
public void SaveTo(string filePath)
{
SaveTo(new FileInfo(filePath));
}
public void SaveTo(FileInfo fileInfo)
{
using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
{
SaveTo(stream);
}
}
#endif
public static bool IsGZipFile(Stream stream)
{
// read the header on the first read
byte[] header = new byte[10];
int n = stream.Read(header, 0, header.Length);
// workitem 8501: handle edge case (decompress empty stream)
if (n == 0)
return false;
if (n != 10)
return false;
if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
return false;
return true;
}
/// <summary>
/// Takes multiple seekable Streams for a multi-part archive
/// </summary>
/// <param name="stream"></param>
/// <param name="options"></param>
internal GZipArchive(Stream stream, Options options)
: base(ArchiveType.GZip, stream.AsEnumerable(), options)
{
}
internal GZipArchive()
: base(ArchiveType.GZip)
{
}
public void SaveTo(Stream stream)
{
this.SaveTo(stream, CompressionType.GZip);
}
protected override GZipArchiveEntry CreateEntry(string filePath, Stream source, long size, DateTime? modified,
bool closeStream)
{
if (Entries.Any())
{
throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
}
return new GZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
}
protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
IEnumerable<GZipArchiveEntry> oldEntries,
IEnumerable<GZipArchiveEntry> newEntries)
{
if (Entries.Count > 1)
{
throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
}
using (var writer = new GZipWriter(stream))
{
foreach (var entry in oldEntries.Concat(newEntries)
.Where(x => !x.IsDirectory))
{
using (var entryStream = entry.OpenEntryStream())
{
writer.Write(entry.FilePath, entryStream, entry.LastModifiedTime);
}
}
}
}
protected override IEnumerable<GZipVolume> LoadVolumes(IEnumerable<Stream> streams, Options options)
{
return new GZipVolume(streams.First(), options).AsEnumerable();
}
protected override IEnumerable<GZipArchiveEntry> LoadEntries(IEnumerable<GZipVolume> volumes)
{
Stream stream = volumes.Single().Stream;
yield return new GZipArchiveEntry(this, new GZipFilePart(stream));
}
protected override IReader CreateReaderForSolidExtraction()
{
var stream = Volumes.Single().Stream;
stream.Position = 0;
return GZipReader.Open(stream);
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Common;
using SharpCompress.Common.GZip;
using SharpCompress.Readers;
using SharpCompress.Readers.GZip;
using SharpCompress.Writers;
using SharpCompress.Writers.GZip;
namespace SharpCompress.Archives.GZip
{
public class GZipArchive : AbstractWritableArchive<GZipArchiveEntry, GZipVolume>
{
#if !NO_FILE
/// <summary>
/// Constructor expects a filepath to an existing file.
/// </summary>
/// <param name="filePath"></param>
/// <param name="readerOptions"></param>
public static GZipArchive Open(string filePath, ReaderOptions readerOptions = null)
{
filePath.CheckNotNullOrEmpty("filePath");
return Open(new FileInfo(filePath), readerOptions ?? new ReaderOptions());
}
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="readerOptions"></param>
public static GZipArchive Open(FileInfo fileInfo, ReaderOptions readerOptions = null)
{
fileInfo.CheckNotNull("fileInfo");
return new GZipArchive(fileInfo, readerOptions ?? new ReaderOptions());
}
#endif
/// <summary>
/// Takes a seekable Stream as a source
/// </summary>
/// <param name="stream"></param>
/// <param name="readerOptions"></param>
public static GZipArchive Open(Stream stream, ReaderOptions readerOptions = null)
{
stream.CheckNotNull("stream");
return new GZipArchive(stream, readerOptions ?? new ReaderOptions());
}
public static GZipArchive Create()
{
return new GZipArchive();
}
#if !NO_FILE
/// <summary>
/// Constructor with a FileInfo object to an existing file.
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="options"></param>
internal GZipArchive(FileInfo fileInfo, ReaderOptions options)
: base(ArchiveType.GZip, fileInfo, options)
{
}
protected override IEnumerable<GZipVolume> LoadVolumes(FileInfo file)
{
return new GZipVolume(file, ReaderOptions).AsEnumerable();
}
public static bool IsGZipFile(string filePath)
{
return IsGZipFile(new FileInfo(filePath));
}
public static bool IsGZipFile(FileInfo fileInfo)
{
if (!fileInfo.Exists)
{
return false;
}
using (Stream stream = fileInfo.OpenRead())
{
return IsGZipFile(stream);
}
}
public void SaveTo(string filePath)
{
SaveTo(new FileInfo(filePath));
}
public void SaveTo(FileInfo fileInfo)
{
using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
{
SaveTo(stream, new WriterOptions(CompressionType.GZip));
}
}
#endif
public static bool IsGZipFile(Stream stream)
{
// read the header on the first read
byte[] header = new byte[10];
int n = stream.Read(header, 0, header.Length);
// workitem 8501: handle edge case (decompress empty stream)
if (n == 0)
{
return false;
}
if (n != 10)
{
return false;
}
if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
{
return false;
}
return true;
}
/// <summary>
/// Takes multiple seekable Streams for a multi-part archive
/// </summary>
/// <param name="stream"></param>
/// <param name="options"></param>
internal GZipArchive(Stream stream, ReaderOptions options)
: base(ArchiveType.GZip, stream, options)
{
}
internal GZipArchive()
: base(ArchiveType.GZip)
{
}
protected override GZipArchiveEntry CreateEntryInternal(string filePath, Stream source, long size, DateTime? modified,
bool closeStream)
{
if (Entries.Any())
{
throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
}
return new GZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
}
protected override void SaveTo(Stream stream, WriterOptions options,
IEnumerable<GZipArchiveEntry> oldEntries,
IEnumerable<GZipArchiveEntry> newEntries)
{
if (Entries.Count > 1)
{
throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
}
using (var writer = new GZipWriter(stream))
{
foreach (var entry in oldEntries.Concat(newEntries)
.Where(x => !x.IsDirectory))
{
using (var entryStream = entry.OpenEntryStream())
{
writer.Write(entry.Key, entryStream, entry.LastModifiedTime);
}
}
}
}
protected override IEnumerable<GZipVolume> LoadVolumes(IEnumerable<Stream> streams)
{
return new GZipVolume(streams.First(), ReaderOptions).AsEnumerable();
}
protected override IEnumerable<GZipArchiveEntry> LoadEntries(IEnumerable<GZipVolume> volumes)
{
Stream stream = volumes.Single().Stream;
yield return new GZipArchiveEntry(this, new GZipFilePart(stream));
}
protected override IReader CreateReaderForSolidExtraction()
{
var stream = Volumes.Single().Stream;
stream.Position = 0;
return GZipReader.Open(stream);
}
}
}

View File

@@ -0,0 +1,34 @@
using System.IO;
using System.Linq;
using SharpCompress.Common.GZip;
namespace SharpCompress.Archives.GZip
{
public class GZipArchiveEntry : GZipEntry, IArchiveEntry
{
internal GZipArchiveEntry(GZipArchive archive, GZipFilePart part)
: base(part)
{
Archive = archive;
}
public virtual Stream OpenEntryStream()
{
//this is to reset the stream to be read multiple times
var part = Parts.Single() as GZipFilePart;
if (part.GetRawStream().Position != part.EntryStartPosition)
{
part.GetRawStream().Position = part.EntryStartPosition;
}
return Parts.Single().GetCompressedStream();
}
#region IArchiveEntry Members
public IArchive Archive { get; }
public bool IsComplete { get { return true; } }
#endregion
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.IO;
using SharpCompress.Common;
using SharpCompress.IO;
namespace SharpCompress.Archives.GZip
{
internal class GZipWritableArchiveEntry : GZipArchiveEntry, IWritableArchiveEntry
{
private readonly bool closeStream;
private readonly Stream stream;
internal GZipWritableArchiveEntry(GZipArchive archive, Stream stream,
string path, long size, DateTime? lastModified, bool closeStream)
: base(archive, null)
{
this.stream = stream;
Key = path;
Size = size;
LastModifiedTime = lastModified;
this.closeStream = closeStream;
}
public override long Crc { get { return 0; } }
public override string Key { get; }
public override long CompressedSize { get { return 0; } }
public override long Size { get; }
public override DateTime? LastModifiedTime { get; }
public override DateTime? CreatedTime { get { return null; } }
public override DateTime? LastAccessedTime { get { return null; } }
public override DateTime? ArchivedTime { get { return null; } }
public override bool IsEncrypted { get { return false; } }
public override bool IsDirectory { get { return false; } }
public override bool IsSplit { get { return false; } }
internal override IEnumerable<FilePart> Parts { get { throw new NotImplementedException(); } }
Stream IWritableArchiveEntry.Stream { get { return stream; } }
public override Stream OpenEntryStream()
{
//ensure new stream is at the start, this could be reset
stream.Seek(0, SeekOrigin.Begin);
return new NonDisposingStream(stream);
}
internal override void Close()
{
if (closeStream)
{
stream.Dispose();
}
}
}
}

View File

@@ -1,41 +1,49 @@
using System;
using System.Collections.Generic;
using SharpCompress.Common;
using SharpCompress.Reader;
namespace SharpCompress.Archive
{
public interface IArchive : IDisposable
{
event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionBegin;
event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionEnd;
event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
IEnumerable<IArchiveEntry> Entries { get; }
long TotalSize { get; }
IEnumerable<IVolume> Volumes { get; }
ArchiveType Type { get; }
/// <summary>
/// Use this method to extract all entries in an archive in order.
/// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
/// extracted sequentially for the best performance.
/// </summary>
/// <returns></returns>
IReader ExtractAllEntries();
/// <summary>
/// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
/// Rar Archives can be SOLID while all 7Zip archives are considered SOLID.
/// </summary>
bool IsSolid { get; }
/// <summary>
/// This checks to see if all the known entries have IsComplete = true
/// </summary>
bool IsComplete { get; }
}
using System;
using System.Collections.Generic;
using SharpCompress.Common;
using SharpCompress.Readers;
namespace SharpCompress.Archives
{
public interface IArchive : IDisposable
{
event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionBegin;
event EventHandler<ArchiveExtractionEventArgs<IArchiveEntry>> EntryExtractionEnd;
event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
IEnumerable<IArchiveEntry> Entries { get; }
IEnumerable<IVolume> Volumes { get; }
ArchiveType Type { get; }
/// <summary>
/// Use this method to extract all entries in an archive in order.
/// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
/// extracted sequentially for the best performance.
/// </summary>
IReader ExtractAllEntries();
/// <summary>
/// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
/// Rar Archives can be SOLID while all 7Zip archives are considered SOLID.
/// </summary>
bool IsSolid { get; }
/// <summary>
/// This checks to see if all the known entries have IsComplete = true
/// </summary>
bool IsComplete { get; }
/// <summary>
/// The total size of the files compressed in the archive.
/// </summary>
long TotalSize { get; }
/// <summary>
/// The total size of the files as uncompressed in the archive.
/// </summary>
long TotalUncompressSize { get; }
}
}

Some files were not shown because too many files have changed in this diff Show More