#include "Bootil/Bootil.h"

using namespace Bootil;

int main( int argc, char** argv )
{
	Debug::SuppressPopups( true );
	CommandLine::Set( argc, argv );
	
	Console::FGColorPush( Console::Green );
    Output::Msg( "GMod Lua Cache Extractor 1.0\n\n" );
    Console::FGColorPop();

	BString strInFolder = CommandLine::GetArg( 0, "" );
	BString strOutFolder = CommandLine::GetArg( 1, strInFolder );

	if (strInFolder == "")
		Output::Error("Usage: gluaextract <in> [out]");

	String::List files;
	String::List folders;
	File::Find( &files, &folders, strInFolder + "/*.lua", false );
	File::CreateFolder(strOutFolder);
	
	Output::Msg( "Converting %i files.\n", files.size() );

	BOOTIL_FOREACH_CONST(f, files, String::List)
	{
		AutoBuffer inBuf;
		File::Read(strInFolder + "/" + *f, inBuf);

		// Extract using LZMA (first 4 bytes are junk)
		AutoBuffer outBuf;
		Compression::LZMA::Extract(inBuf.GetBase(4), inBuf.GetSize()-4, outBuf);

		File::Write(strOutFolder + "/" + *f, outBuf);
	}

	return 0;
}

#include "Bootil/Bootil.h"

using namespace Bootil;

int main( int argc, char** argv )
{
	CommandLine::Set( argc, argv );

	BString strInFolder = CommandLine::GetArg( 0, "" );
	BString strOutFolder = CommandLine::GetArg( 1, strInFolder );

	if (strInFolder == "")
		Output::Error("Usage: gluaextract <in> [out]");

	String::List files;
	String::List folders;
	File::Find( &files, &folders, strInFolder + "/*.lua", false );

	Output::Msg( "Converting %i files.\n", files.size() );

	BOOTIL_FOREACH_CONST(f, files, String::List)
	{
		AutoBuffer inBuf;
		File::Read(strInFolder + "/" + *f, inBuf);

		// Extract using LZMA (first 4 bytes are junk)
		AutoBuffer outBuf;
		Compression::LZMA::Extract(inBuf.GetBase(4), inBuf.GetSize()-4, outBuf);

		File::Write(strOutFolder + "/" + *f, outBuf);
	}

	return 0;
}

--- 
+++ 
@@ -4,7 +4,12 @@
 
 int main( int argc, char** argv )
 {
+	Debug::SuppressPopups( true );
 	CommandLine::Set( argc, argv );
+	
+	Console::FGColorPush( Console::Green );
+    Output::Msg( "GMod Lua Cache Extractor 1.0\n\n" );
+    Console::FGColorPop();
 
 	BString strInFolder = CommandLine::GetArg( 0, "" );
 	BString strOutFolder = CommandLine::GetArg( 1, strInFolder );
@@ -15,7 +20,8 @@
 	String::List files;
 	String::List folders;
 	File::Find( &files, &folders, strInFolder + "/*.lua", false );
-
+	File::CreateFolder(strOutFolder);
+	
 	Output::Msg( "Converting %i files.\n", files.size() );
 
 	BOOTIL_FOREACH_CONST(f, files, String::List)
Create output folder if does not exist. Suppress debug popups.
