Index: AE/Installer/trunk/source/installer.h
===================================================================
--- AE/Installer/trunk/source/installer.h	(revision 462)
+++ AE/Installer/trunk/source/installer.h	(revision 487)
@@ -1,317 +1,70 @@
- #pragma once 
-/* AE/Mod Installer header file */
+/***************************************************************************\
+| Project: AE Installer														|
+| By: Gumby & Iritscen														|
+| File: Installer.h															|
+| Function: Contains the real meat of the installation process.				|
+| Created: 24/05/2009 19:39:00												|
+\***************************************************************************/
+
 #ifndef DOUBLE_HEADER
 #define DOUBLE_HEADER
 
-
 #include <string>
 #include <vector>
+#include <iostream>
+#include "globals.h"
+#ifdef WIN32
+#ifndef __GUICON_H__
+#define __GUICON_H__
+#endif
 #include <fstream>
+#include <windows.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <io.h>
 
-using namespace std;
+void RedirectIOToConsole();
+// maximum mumber of lines the output console should have
+static const WORD MAX_CONSOLE_LINES = 500;
+#endif
 
+
+#pragma mark GLOBALS
 static string SLASHSLASH = "//";
 static string DIRSLASH = "\\";
-string strInstallCfg = "../GameDataFolder/Add.cfg";
-static string strInstallerVersion = "1.0";
+extern bool busy;
+extern string strInstallCfg;// = "../GameDataFolder/Add.cfg";
+extern Install_info_cfg currentAE, updateAE;
+extern bool splitInstances;
+extern string strImportOption;
+extern string strOniSplit;
+extern vector<ModPackage> globalPackages;
+extern string strEUFN; // I don't mind long variable names, but even I think strEditionUpdateFolderName is a bit much
+#ifndef WIN32
+void Sleep(int ms); // crudely converts the Windows sleep() call, which operates in ms, to the Mac sleep() call that operates in seconds
+#endif
 
-#define STRUCT_DEFS 
-struct ModPackage
-{
-	bool	isInstalled; //replace with function 
-	string	name;
-	string	modStringName;
-	int	modStringVersion;
-	bool	hasOnis;
-	bool	hasDeltas;
-	bool	hasBSL;
-	bool	hasAddon;
-	bool	hasDats;
-	string	category;
-	string	creator;
-	bool	isEngine;
-	string	readme;
-	bool	globalNeeded;
-	ModPackage();
 
-	void doOutput()
-	{
-		cout << "Mod: " << name; cout << "\n"; // remove this when done
-		cout << "	String: " << modStringName << " v." << modStringVersion << "\n";
-		cout << "	Category: " << category << "\n";
-		cout << "	Creator: " << creator << "\n";
-		cout << "	HasOnis: " << hasOnis << "\n";
-		cout << "	HasBSL: " << hasBSL << "\n";
-		cout << "	HasDeltas: " << hasDeltas << "\n";
-		cout << "	HasDats: " << hasDats << "\n";
-		cout << "	IsEngine: " << isEngine << "\n";
-		cout << "	GlobalNeeded: " << globalNeeded << "\n";
-		cout << "	Readme: " << readme << "\n";
-		cout << "\n";
-	}
-
-	     bool operator < (const ModPackage &fs) const
-     { return (name < fs.name);}
-
-     bool operator > (const ModPackage &fs) const
-     { return (name > fs.name);}
-
-     bool operator == (const ModPackage &fs) const
-     { return (name == fs.name);}
-};
-
-#define METHOD_DEFS 
-// Initialization to default values
-ModPackage::ModPackage()
-{
-	isInstalled = true; // replace with function 
-	name = "";
-	modStringName = "";
-	modStringVersion = 0;
-	hasOnis = false;
-	hasDeltas = false;
-	hasBSL = false;
-	hasAddon = false;
-	hasDats = false;
-	category = "";
-	creator = "";
-	isEngine = false;
-	readme = "";
-	globalNeeded = true;
-	//		void doOutput() const
-	//		{ };
-}
-
-#define FUNCTION_PROTOTYPES 
+#pragma mark PROTOTYPES
 int mainMenu(void);
-int globalizeData(void);
+vector<string> getInstallString(string = strInstallCfg);
 int installPackages(void);
 int uninstallPackages(void);
 int listInstalledPackages(void);
 int printInstallerInfo(void);
-vector<ModPackage> getPackages(void);
 ModPackage fileToModPackage(fstream&);
-void recompileAll(vector<string>);
-vector<string> getInstallString(string = strInstallCfg);
+bool StringIsLegalPathForDeletion(string);
+vector<ModPackage> getPackages(string packageDir = "./packages");
+void MakePathLocalToGlobalize(string*);
+bool SortBySize(string, string);
 void tokenize(const string&, vector<string>&, const string& delimiters = " ");
-//bool getDirectoryContents(char , char &);
 void clearOldDats(void);
 void writeInstalledMods( vector<string> );
-void setStatusArea( string );
-void setProgressBar( int );
-
 void copyBSL( string, vector<string>&, ModPackage );
-
-//New copy(path, path) function. Too lazy to implement my own, this is basically how I would have done it though.
-//No, really. :)
-//Move to utilities.cpp when the time comes.
-using namespace boost::filesystem; 
-using namespace std;
-
-void copy_directory( const path & from_dir_ph, 
-					const path & to_dir_ph ); 
-
-void copy( const path & from_file_ph, 
-		  const path & to_file_ph ); 
-
-
-// this function copies files and directories. If copying a 
-// directory to a directory, it copies recursively. 
-
-//pardon the mess, I did this at midnight, and had to fix a bug
-void copy( const path & from_ph, 
-		  const path & to_ph ) 
-{ 
-	cout << to_ph.string() << "\n";
-	// Make sure that the destination, if it exists, is a directory 
-	if((exists(to_ph) && !is_directory(to_ph)) || (!exists(from_ph))) cout << "error";
-	if(!is_directory(from_ph)) 
-	{ 
-		
-		if(exists(to_ph)) 
-		{ 
-			copy_file(from_ph,to_ph/from_ph.filename()); 
-		} 
-		else 
-		{ 
-			try{
-				
-				copy_file(from_ph,to_ph);
-			}
-			catch (exception ex){
-				cout << from_ph.string() << " to " << to_ph.string() << "\n";
-			}
-		}
-		
-	} 
-	else if(from_ph.filename() != ".svn")
-	{ 
-		path destination; 
-		if(!exists(to_ph)) 
-		{ 
-			destination=to_ph; 
-		} 
-		else 
-		{ 
-			destination=to_ph/from_ph.filename(); 
-		} 
-		//not sure what this did, its going away though. probably error checking ;)
-		//copy_directory(from_ph,destination); 
-		
-		for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) 
-		{ 
-			//the idiot who coded this in the first place (not me)
-			//forgot to make a new directory. Exception city. x_x
-			create_directory(destination); 
-			copy(*i,destination/i->filename()); 
-		} 
-	} 
-} 
-
-void copy_directory( const path &from_dir_ph, 
-					const path &to_dir_ph) 
-{ 
-	if(!exists(from_dir_ph) || !is_directory(from_dir_ph) 
-	   || exists(to_dir_ph)) 
-		cout << !exists(from_dir_ph) << " " << !is_directory(from_dir_ph) 
-		<< " " << exists(to_dir_ph);
-	//boost::throw_exception( filesystem_error( 
-	//"boost::filesystem::copy_directory", 
-	//from_dir_ph, to_dir_ph, boost::system::error_code() )); 
-	
-# ifdef BOOST_POSIX 
-	struct stat from_stat; 
-	if ( (::stat( from_dir_ph.string().c_str(), &from_stat ) != 0) 
-		|| ::mkdir(to_dir_ph.native_directory_string().c_str(), 
-				   from_stat.st_mode)!=0) 
-# endif 
-		//	boost::throw_exception( filesystem_error( 
-		//	//"boost::filesystem::copy_directory", 
-		//	from_dir_ph, to_dir_ph, boost::system::error_code())); 
-		} 
-
-#endif
-
-#ifdef WIN32
-
-#ifndef __GUICON_H__
-
-#define __GUICON_H__
-
-
-
-void RedirectIOToConsole();
-
-
-
-#endif
+bool ReadInstallInfoCfg(fstream *, Install_info_cfg *);
 
 /* End of File */
 
-
-#include <windows.h>
-
-#include <stdio.h>
-
-#include <fcntl.h>
-
-#include <io.h>
-
-#include <iostream>
-
-#include <fstream>
-
-#ifndef _USE_OLD_IOSTREAMS
-
-using namespace std;
+//End of File
 
 #endif
-
-// maximum mumber of lines the output console should have
-
-static const WORD MAX_CONSOLE_LINES = 500;
-
-
-void RedirectIOToConsole()
-
-{
-	
-	int hConHandle;
-	
-	long lStdHandle;
-	
-	CONSOLE_SCREEN_BUFFER_INFO coninfo;
-	
-	FILE *fp;
-	
-	// allocate a console for this app
-	
-	AllocConsole();
-	
-	// set the screen buffer to be big enough to let us scroll text
-	
-	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), 
-							   
-							   &coninfo);
-	
-	coninfo.dwSize.Y = MAX_CONSOLE_LINES;
-	
-	SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), 
-							   
-							   coninfo.dwSize);
-	
-	// redirect unbuffered STDOUT to the console
-	
-	lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
-	
-	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-	
-	fp = _fdopen( hConHandle, "w" );
-	
-	*stdout = *fp;
-	
-	setvbuf( stdout, NULL, _IONBF, 0 );
-	
-	// redirect unbuffered STDIN to the console
-	
-	lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
-	
-	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-	
-	fp = _fdopen( hConHandle, "r" );
-	
-	*stdin = *fp;
-	
-	setvbuf( stdin, NULL, _IONBF, 0 );
-	
-	// redirect unbuffered STDERR to the console
-	
-	lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
-	
-	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-	
-	fp = _fdopen( hConHandle, "w" );
-	
-	*stderr = *fp;
-	
-	setvbuf( stderr, NULL, _IONBF, 0 );
-	
-	
-	// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog 
-	
-	// point to console as well
-	
-	ios::sync_with_stdio();
-	
-}
-
-
-
-//End of File
-
-
-
-
-
-
-#endif
