aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport/Compression/SevenZipHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Transport/Compression/SevenZipHelper.cs')
-rw-r--r--Software/Visual_Studio/Tango.Transport/Compression/SevenZipHelper.cs105
1 files changed, 0 insertions, 105 deletions
diff --git a/Software/Visual_Studio/Tango.Transport/Compression/SevenZipHelper.cs b/Software/Visual_Studio/Tango.Transport/Compression/SevenZipHelper.cs
deleted file mode 100644
index e23648aa9..000000000
--- a/Software/Visual_Studio/Tango.Transport/Compression/SevenZipHelper.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-// 7Zip helper code by Peter Bromberg
-// http://www.eggheadcafe.com/tutorials/aspnet/064b41e4-60bc-4d35-9136-368603bcc27a/7zip-lzma-inmemory-com.aspx
-
-using System;
-using System.IO;
-
-
-namespace Tango.Transport.Compression
-{
- public static class SevenZipHelper
- {
-
- static int dictionary = 1 << 23;
-
- // static Int32 posStateBits = 2;
- // static Int32 litContextBits = 3; // for normal files
- // UInt32 litContextBits = 0; // for 32-bit data
- // static Int32 litPosBits = 0;
- // UInt32 litPosBits = 2; // for 32-bit data
- // static Int32 algorithm = 2;
- // static Int32 numFastBytes = 128;
-
- static bool eos = false;
-
-
-
-
-
- static CoderPropID[] propIDs =
- {
- CoderPropID.DictionarySize,
- CoderPropID.PosStateBits,
- CoderPropID.LitContextBits,
- CoderPropID.LitPosBits,
- CoderPropID.Algorithm,
- CoderPropID.NumFastBytes,
- CoderPropID.MatchFinder,
- CoderPropID.EndMarker
- };
-
- // these are the default properties, keeping it simple for now:
- static object[] properties =
- {
- (Int32)(dictionary),
- (Int32)(2),
- (Int32)(3),
- (Int32)(0),
- (Int32)(2),
- (Int32)(128),
- "bt4",
- eos
- };
-
-
- public static byte[] Compress(byte[] inputBytes)
- {
-
- MemoryStream inStream = new MemoryStream(inputBytes);
- MemoryStream outStream = new MemoryStream();
- LZMA.Encoder encoder = new LZMA.Encoder();
- encoder.SetCoderProperties(propIDs, properties);
- encoder.WriteCoderProperties(outStream);
- long fileSize = inStream.Length;
- for (int i = 0; i < 8; i++)
- outStream.WriteByte((Byte)(fileSize >> (8 * i)));
- encoder.Code(inStream, outStream, -1, -1, null);
- return outStream.ToArray();
- }
-
- public static byte[] Decompress(byte[] inputBytes)
- {
- MemoryStream newInStream = new MemoryStream(inputBytes);
-
- LZMA.Decoder decoder = new LZMA.Decoder();
-
- newInStream.Seek(0, 0);
- MemoryStream newOutStream = new MemoryStream();
-
- byte[] properties2 = new byte[5];
- if (newInStream.Read(properties2, 0, 5) != 5)
- throw (new Exception("input .lzma is too short"));
- long outSize = 0;
- for (int i = 0; i < 8; i++)
- {
- int v = newInStream.ReadByte();
- if (v < 0)
- throw (new Exception("Can't Read 1"));
- outSize |= ((long)(byte)v) << (8 * i);
- }
- decoder.SetDecoderProperties(properties2);
-
- long compressedSize = newInStream.Length - newInStream.Position;
- decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
-
- byte[] b = newOutStream.ToArray();
-
- return b;
-
-
-
- }
-
-
- }
-}