本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# InflaterInputStream.Close方法的具体用法?C# InflaterInputStream.Close怎么用?C# InflaterInputStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
的用法示例。
在下文中一共展示了InflaterInputStream.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decompress
public string Decompress(string compressedString)
{
var uncompressedString = string.Empty;
var totalLength = 0;
var inputAsBytes = Convert.FromBase64String(compressedString);;
var writeData = new byte[4096];
var inputStream = new InflaterInputStream(new MemoryStream(inputAsBytes));
for(;;)
{
var size = inputStream.Read(writeData, 0, writeData.Length);
if (size > 0)
{
totalLength += size;
uncompressedString += Encoding.UTF8.GetString(writeData, 0, size);
}
else
{
break;
}
}
inputStream.Close();
return uncompressedString;
}
示例2: Decompress
public static byte[] Decompress(string data)
{
byte[] array = null;
if (data.StartsWith("ZipStream:"))
{
MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(data.Substring(10)));
InflaterInputStream inflaterInputStream = new InflaterInputStream(memoryStream);
BinaryReader binaryReader = new BinaryReader(memoryStream);
int num = binaryReader.ReadInt32();
array = new byte[num];
inflaterInputStream.Read(array, 0, num);
inflaterInputStream.Close();
memoryStream.Close();
}
return array;
}
示例3: Decompress
public byte[] Decompress( byte[] bytes )
{
Stream stream = new InflaterInputStream( new MemoryStream( bytes ) );
MemoryStream memory = new MemoryStream();
int totalLength = 0;
byte[] writeData = new byte[4096];
while ( true )
{
int size = stream.Read( writeData, 0, writeData.Length );
if ( size > 0 )
{
totalLength += size;
memory.Write( writeData, 0, size );
}
else
break;
}
stream.Close();
return memory.ToArray();
}
示例4: Decompress
public static byte[] Decompress(byte[] bytes)
{
InflaterInputStream stream = new InflaterInputStream(new MemoryStream(bytes));
MemoryStream memory = new MemoryStream();
Byte[] writeData = new byte[4096];
int size;
while (true)
{
size = stream.Read(writeData, 0, writeData.Length);
if (size > 0)
{
memory.Write(writeData, 0, size);
}
else
{
break;
}
}
stream.Close();
return memory.ToArray();
}
示例5: ProcessData
public static MemoryStream ProcessData(byte[] data)
{
if (data == null)
{
return null;
}
MemoryStream baseInputStream = null;
MemoryStream stream2;
InflaterInputStream stream3 = null;
try
{
baseInputStream = new MemoryStream(data);
stream2 = new MemoryStream();
stream3 = new InflaterInputStream(baseInputStream);
byte[] buffer = new byte[data.Length];
while (true)
{
int count = stream3.Read(buffer, 0, buffer.Length);
if (count <= 0)
{
break;
}
stream2.Write(buffer, 0, count);
}
stream2.Flush();
stream2.Seek(0L, SeekOrigin.Begin);
}
finally
{
if (baseInputStream != null)
{
baseInputStream.Close();
}
if (stream3 != null)
{
stream3.Close();
}
}
return stream2;
}
示例6: DeCompress
public static byte[] DeCompress( byte []b )
{
Stream s2 = new InflaterInputStream( new MemoryStream( b ) );
try
{
byte []dest = null;
int size = s2.Read( writeData, 0, writeData.Length);
if (size > 0)
{
dest = new byte[ size ];
Buffer.BlockCopy( writeData , 0, dest, 0, size );
}
s2.Flush();
s2.Close();
return dest;
}
catch(Exception e)
{
Console.WriteLine( e.Message );
return null;
}
}
示例7: ParseQpyd
private string ParseQpyd(string qqydFile)
{
var fs = new FileStream(qqydFile, FileMode.Open, FileAccess.Read);
fs.Position = 0x38;
var startAddressByte = new byte[4];
fs.Read(startAddressByte, 0, 4);
int startAddress = BitConverter.ToInt32(startAddressByte, 0);
fs.Position = 0x44;
int wordCount = BinFileHelper.ReadInt32(fs);
CountWord = wordCount;
CurrentStatus = 0;
fs.Position = startAddress;
var zipStream = new InflaterInputStream(fs);
int bufferSize = 2048; //缓冲区大小
int readCount = 0; //读入缓冲区的实际字节
var buffer = new byte[bufferSize];
var byteList = new List<byte>();
readCount = zipStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
for (int i = 0; i < readCount; i++)
{
byteList.Add(buffer[i]);
}
readCount = zipStream.Read(buffer, 0, bufferSize);
}
zipStream.Close();
zipStream.Dispose();
fs.Close();
byte[] byteArray = byteList.ToArray();
int unzippedDictStartAddr = -1;
int idx = 0;
var sb = new StringBuilder();
while (unzippedDictStartAddr == -1 || idx < unzippedDictStartAddr)
{
// read word
int pinyinStartAddr = BitConverter.ToInt32(byteArray, idx + 0x6);
int pinyinLength = BitConverter.ToInt32(byteArray, idx + 0x0) & 0xff;
int wordStartAddr = pinyinStartAddr + pinyinLength;
int wordLength = BitConverter.ToInt32(byteArray, idx + 0x1) & 0xff;
if (unzippedDictStartAddr == -1)
{
unzippedDictStartAddr = pinyinStartAddr;
Debug.WriteLine("词库地址(解压后):0x" + unzippedDictStartAddr.ToString("0x") + "\n");
}
string pinyin = Encoding.UTF8.GetString(byteArray, pinyinStartAddr, pinyinLength);
string word = Encoding.Unicode.GetString(byteArray, wordStartAddr, wordLength);
sb.Append(word + "\t" + pinyin + "\n");
Debug.WriteLine(word + "\t" + pinyin);
CurrentStatus++;
// step up
idx += 0xa;
}
return sb.ToString();
}
示例8: DeCompressToString
public static string DeCompressToString(byte[] bytInput)
{
if (bytInput == null || bytInput.Length == 0)
return null;
string strResult = "";
int totalLength = 0;
byte[] writeData = new byte[10240];
Stream s2 = new InflaterInputStream(new MemoryStream(bytInput));
while (true) {
int size = s2.Read(writeData, 0, writeData.Length);
if (size > 0) {
totalLength += size;
strResult += System.Text.Encoding.ASCII.GetString(writeData, 0,
size);
} else {
break;
}
}
s2.Close();
return strResult;
}
示例9: DeCompress
public static byte[] DeCompress(byte[] bytInput)
{
if (bytInput == null || bytInput.Length == 0)
return null;
Stream s2 = new InflaterInputStream(new MemoryStream(bytInput));
MemoryStream mem = new MemoryStream();
byte[] writeData = new byte[10240];
try {
while (true) {
int size = s2.Read(writeData, 0, writeData.Length);
if (size > 0) {
mem.Write(writeData, 0, size);
} else {
break;
}
}
mem.Close();
return mem.ToArray();
} finally {
s2.Close();
}
}
示例10: UnZip
private static MemoryStream UnZip(byte[] data)
{
if (data == null)
{
return null;
}
MemoryStream memoryStream = null;
MemoryStream memoryStream2 = null;
InflaterInputStream inflaterInputStream = null;
try
{
memoryStream = new MemoryStream(data);
memoryStream2 = new MemoryStream();
inflaterInputStream = new InflaterInputStream(memoryStream);
byte[] array = new byte[data.Length];
while (true)
{
int num = inflaterInputStream.Read(array, 0, array.Length);
if (num <= 0)
{
break;
}
memoryStream2.Write(array, 0, num);
}
memoryStream2.Flush();
memoryStream2.Seek(0L, SeekOrigin.Begin);
}
finally
{
if (memoryStream != null)
{
memoryStream.Close();
}
if (inflaterInputStream != null)
{
inflaterInputStream.Close();
}
memoryStream = null;
inflaterInputStream = null;
}
return memoryStream2;
}
示例11: DoWork
//.........这里部分代码省略.........
X = ReadInt(netStream),
Z = ReadInt(netStream),
};
var mode = ReadBoolean(netStream);
if (mode == false)
{
//if (World.IsChunkLoaded(chunkPos))
//{
// World.Chunks.Remove(World.GetChunk(chunkPos));
// GC.Collect();
//}
}
break;
case PacketID.MapChunks:
chunkPos = new Vector3();
chunkPos.X = ReadInt(netStream);
chunkPos.Y = ReadShort(netStream);
chunkPos.Z = ReadInt(netStream);
byte chunkSizeX = (byte) netStream.ReadByte();
byte chunkSizeY = (byte) netStream.ReadByte();
byte chunkSizeZ = (byte) netStream.ReadByte();
size = ReadInt(netStream);
byte[] deflatedChunk = ReadBytes(netStream, size);
Chunk chunk = new Chunk(chunkPos);
InflaterInputStream inflateStream =
new InflaterInputStream(new MemoryStream(deflatedChunk));
byte[] inflatedChunk = new byte[(int) (chunkSizeX*chunkSizeY*chunkSizeZ*2.5)];
inflateStream.Read(inflatedChunk, 0, inflatedChunk.Length);
inflateStream.Close();
try
{
Array.Copy(inflatedChunk, 0, chunk.Blocks, 0, chunk.Blocks.Length);
byte[] meta = new byte[chunk.Blocks.Length/2];
Array.Copy(inflatedChunk, chunk.Blocks.Length, meta, 0, meta.Length);
chunk.SetMetadata(meta);
//World.SetChunk(chunk);
break;
//Array.Copy(inflatedChunk, 0, chunk.Blocks, 0, chunk.Blocks.Length);
//byte[] blockLight = new byte[chunk.Blocks.Length/2];
//Array.Copy(inflatedChunk, chunk.Blocks.Length + meta.Length, blockLight, 0,
// blockLight.Length);
//chunk.SetBlockLight(blockLight);
//Array.Copy(inflatedChunk, 0, chunk.Blocks, 0, chunk.Blocks.Length);
//byte[] skyLight = new byte[chunk.Blocks.Length/2];
//Array.Copy(inflatedChunk, chunk.Blocks.Length + meta.Length + blockLight.Length,
// skyLight, 0, skyLight.Length);
//chunk.SetSkyLight(skyLight);
}
catch
{
}
//World.SetChunk(chunk);
break;
case PacketID.MultiBlockChange:
ReadInt(netStream);
示例12: InflatorStreamOwnership
public void InflatorStreamOwnership()
{
TrackedMemoryStream memStream = new TrackedMemoryStream();
InflaterInputStream s = new InflaterInputStream(memStream);
Assert.IsFalse(memStream.IsClosed, "Shouldnt be closed initially");
Assert.IsFalse(memStream.IsDisposed, "Shouldnt be disposed initially");
s.Close();
Assert.IsTrue(memStream.IsClosed, "Should be closed after parent owner close");
Assert.IsTrue(memStream.IsDisposed, "Should be disposed after parent owner close");
memStream = new TrackedMemoryStream();
s = new InflaterInputStream(memStream);
Assert.IsFalse(memStream.IsClosed, "Shouldnt be closed initially");
Assert.IsFalse(memStream.IsDisposed, "Shouldnt be disposed initially");
s.IsStreamOwner = false;
s.Close();
Assert.IsFalse(memStream.IsClosed, "Should not be closed after parent owner close");
Assert.IsFalse(memStream.IsDisposed, "Should not be disposed after parent owner close");
}
示例13: Uncompress
public static int Uncompress(ref byte[] Data)
{
int maxsize=Data.Length*10+300;
if (maxsize>50000) maxsize=50000;
byte[] outputData=new byte[maxsize];
MemoryStream dataStream=new MemoryStream(Data);
InflaterInputStream inflater=new InflaterInputStream(dataStream);
//int res=descompresor.Read(packetsalida,0,packetsalida.Length);
//if (res>0)
int res;
int resTotal=0;
MemoryStream uncompressedStream=new MemoryStream();
do
{
if (inflater.Position==Data.Length) res=0;
else
try
{
res=inflater.Read(outputData,0,outputData.Length);
}
catch
{
res=0;
}
if (res>0)
{
uncompressedStream.Write(outputData,0,res);
}
resTotal+=res;
}
while (res>0);
if (resTotal==0)
{
return 0;
}
else
{
inflater.Close();
inflater=null;
dataStream.Close();
dataStream=null;
Data=null;
Data=new byte[resTotal];
uncompressedStream.Seek(0,SeekOrigin.Begin);
uncompressedStream.Read(Data,0,resTotal);
uncompressedStream.Close();
uncompressedStream=null;
return resTotal;
}
}
示例14: Decompress
public byte[] Decompress(byte[] bytInput)
{
var ms = new MemoryStream(bytInput, 0, bytInput.Length);
byte[] bytResult = null;
string strResult = String.Empty;
var writeData = new byte[4096];
Stream s2 = new InflaterInputStream(ms);
try
{
bytResult = ReadFullStream(s2);
s2.Close();
return bytResult;
}
catch
{
throw;
}
}
示例15: Decompress
public static byte[] Decompress(string data, ICodeProgress progress)
{
byte[] output = null;
if(data.StartsWith("ZipStream:"))
{
var m = new MemoryStream(Convert.FromBase64String(data.Substring(10)));
var z = new InflaterInputStream(m);
var br = new BinaryReader(m);
var length = br.ReadInt32();
output = new byte[length];
z.Read(output, 0, length);
z.Close();
m.Close();
}
else
{
return SevenZipRadical.Compression.LZMA.SevenZipRadicalHelper.Decompress(Convert.FromBase64String(data), progress);
}
return output;
}