Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using SevenZip;
- using SevenZip.Compression.LZMA;
- namespace GMODDataPack
- {
- class Program
- {
- static string ReadCString(BinaryReader r)
- {
- StringBuilder sb = new StringBuilder();
- char c = r.ReadChar();
- while (c != '\0')
- {
- sb.Append(c);
- c = r.ReadChar();
- }
- return sb.ToString();
- }
- static void Main(string[] args)
- {
- for( int i = 0; i < args.Length; i++ )
- {
- byte[] bytes = File.ReadAllBytes( args[ i ] );
- BinaryReader r = new BinaryReader( new MemoryStream( bytes ) );
- r.ReadBytes( 4 );
- byte[] lzma_props = r.ReadBytes( 5 );
- Int64 real_size = r.ReadInt64();
- int size = bytes.Length - 5 - 4 - 4;
- Console.WriteLine( "{0}: {1} bytes -> {2} bytes", args[i], size, real_size );
- SevenZip.Compression.LZMA.Decoder dec = new SevenZip.Compression.LZMA.Decoder();
- dec.SetDecoderProperties( lzma_props );
- MemoryStream msout = new MemoryStream();
- dec.Code( r.BaseStream, msout, size, real_size, null );
- msout.Position = 0;
- byte[] output = msout.ToArray();
- byte[] no_null = new byte[output.Length - 1];
- Array.Copy( output, no_null, no_null.Length );
- if( !Directory.Exists( "./uncompressed" ) )
- Directory.CreateDirectory( "./uncompressed" );
- File.WriteAllBytes( "./uncompressed/" + args[ i ], no_null );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement