1 |
< |
#pragma once |
2 |
< |
/* AE/Mod Installer header file */ |
1 |
> |
/***************************************************************************\ |
2 |
> |
| Project: AE Installer | |
3 |
> |
| By: Gumby & Iritscen | |
4 |
> |
| File: Installer.h | |
5 |
> |
| Function: Contains the real meat of the installation process. | |
6 |
> |
| Created: 24/05/2009 19:39:00 | |
7 |
> |
\***************************************************************************/ |
8 |
> |
|
9 |
|
#ifndef DOUBLE_HEADER |
10 |
|
#define DOUBLE_HEADER |
11 |
|
|
6 |
– |
|
12 |
|
#include <string> |
13 |
|
#include <vector> |
14 |
+ |
#include <iostream> |
15 |
+ |
#include "globals.h" |
16 |
+ |
#ifdef WIN32 |
17 |
+ |
#ifndef __GUICON_H__ |
18 |
+ |
#define __GUICON_H__ |
19 |
+ |
#endif |
20 |
|
#include <fstream> |
21 |
+ |
#include <windows.h> |
22 |
+ |
#include <stdio.h> |
23 |
+ |
#include <fcntl.h> |
24 |
+ |
#include <io.h> |
25 |
+ |
|
26 |
+ |
void RedirectIOToConsole(); |
27 |
+ |
// maximum mumber of lines the output console should have |
28 |
+ |
static const WORD MAX_CONSOLE_LINES = 500; |
29 |
+ |
#endif |
30 |
|
|
11 |
– |
using namespace std; |
31 |
|
|
32 |
+ |
#pragma mark GLOBALS |
33 |
|
static string SLASHSLASH = "//"; |
34 |
|
static string DIRSLASH = "\\"; |
35 |
< |
string strInstallCfg = "../GameDataFolder/Add.cfg"; |
36 |
< |
static string strInstallerVersion = "1.0"; |
37 |
< |
|
38 |
< |
#define STRUCT_DEFS |
39 |
< |
struct ModPackage |
40 |
< |
{ |
41 |
< |
bool isInstalled; //replace with function |
42 |
< |
string name; |
43 |
< |
string modStringName; |
44 |
< |
int modStringVersion; |
45 |
< |
bool hasOnis; |
26 |
< |
bool hasDeltas; |
27 |
< |
bool hasBSL; |
28 |
< |
bool hasAddon; |
29 |
< |
bool hasDats; |
30 |
< |
string category; |
31 |
< |
string creator; |
32 |
< |
bool isEngine; |
33 |
< |
string readme; |
34 |
< |
bool globalNeeded; |
35 |
< |
ModPackage(); |
36 |
< |
|
37 |
< |
void doOutput() |
38 |
< |
{ |
39 |
< |
cout << "Mod: " << name; cout << "\n"; // remove this when done |
40 |
< |
cout << " String: " << modStringName << " v." << modStringVersion << "\n"; |
41 |
< |
cout << " Category: " << category << "\n"; |
42 |
< |
cout << " Creator: " << creator << "\n"; |
43 |
< |
cout << " HasOnis: " << hasOnis << "\n"; |
44 |
< |
cout << " HasBSL: " << hasBSL << "\n"; |
45 |
< |
cout << " HasDeltas: " << hasDeltas << "\n"; |
46 |
< |
cout << " HasDats: " << hasDats << "\n"; |
47 |
< |
cout << " IsEngine: " << isEngine << "\n"; |
48 |
< |
cout << " GlobalNeeded: " << globalNeeded << "\n"; |
49 |
< |
cout << " Readme: " << readme << "\n"; |
50 |
< |
cout << "\n"; |
51 |
< |
} |
52 |
< |
|
53 |
< |
bool operator < (const ModPackage &fs) const |
54 |
< |
{ return (name < fs.name);} |
55 |
< |
|
56 |
< |
bool operator > (const ModPackage &fs) const |
57 |
< |
{ return (name > fs.name);} |
58 |
< |
|
59 |
< |
bool operator == (const ModPackage &fs) const |
60 |
< |
{ return (name == fs.name);} |
61 |
< |
}; |
35 |
> |
extern bool busy; |
36 |
> |
extern string strInstallCfg;// = "../GameDataFolder/Add.cfg"; |
37 |
> |
extern Install_info_cfg currentAE, updateAE; |
38 |
> |
extern bool splitInstances; |
39 |
> |
extern string strImportOption; |
40 |
> |
extern string strOniSplit; |
41 |
> |
extern vector<ModPackage> globalPackages; |
42 |
> |
extern string strEUFN; // I don't mind long variable names, but even I think strEditionUpdateFolderName is a bit much |
43 |
> |
#ifndef WIN32 |
44 |
> |
void Sleep(int ms); // crudely converts the Windows sleep() call, which operates in ms, to the Mac sleep() call that operates in seconds |
45 |
> |
#endif |
46 |
|
|
63 |
– |
#define METHOD_DEFS |
64 |
– |
// Initialization to default values |
65 |
– |
ModPackage::ModPackage() |
66 |
– |
{ |
67 |
– |
isInstalled = true; // replace with function |
68 |
– |
name = ""; |
69 |
– |
modStringName = ""; |
70 |
– |
modStringVersion = 0; |
71 |
– |
hasOnis = false; |
72 |
– |
hasDeltas = false; |
73 |
– |
hasBSL = false; |
74 |
– |
hasAddon = false; |
75 |
– |
hasDats = false; |
76 |
– |
category = ""; |
77 |
– |
creator = ""; |
78 |
– |
isEngine = false; |
79 |
– |
readme = ""; |
80 |
– |
globalNeeded = true; |
81 |
– |
// void doOutput() const |
82 |
– |
// { }; |
83 |
– |
} |
47 |
|
|
48 |
< |
#define FUNCTION_PROTOTYPES |
48 |
> |
#pragma mark PROTOTYPES |
49 |
|
int mainMenu(void); |
50 |
< |
int globalizeData(void); |
50 |
> |
vector<string> getInstallString(string = strInstallCfg); |
51 |
|
int installPackages(void); |
52 |
|
int uninstallPackages(void); |
53 |
|
int listInstalledPackages(void); |
54 |
|
int printInstallerInfo(void); |
92 |
– |
vector<ModPackage> getPackages(void); |
55 |
|
ModPackage fileToModPackage(fstream&); |
56 |
< |
void recompileAll(vector<string>); |
57 |
< |
vector<string> getInstallString(string = strInstallCfg); |
56 |
> |
bool StringIsLegalPathForDeletion(string); |
57 |
> |
vector<ModPackage> getPackages(string packageDir = "./packages"); |
58 |
> |
void MakePathLocalToGlobalize(string*); |
59 |
> |
bool SortBySize(string, string); |
60 |
|
void tokenize(const string&, vector<string>&, const string& delimiters = " "); |
97 |
– |
//bool getDirectoryContents(char , char &); |
61 |
|
void clearOldDats(void); |
62 |
|
void writeInstalledMods( vector<string> ); |
100 |
– |
void setStatusArea( string ); |
101 |
– |
void setProgressBar( int ); |
102 |
– |
|
63 |
|
void copyBSL( string, vector<string>&, ModPackage ); |
64 |
< |
|
105 |
< |
//New copy(path, path) function. Too lazy to implement my own, this is basically how I would have done it though. |
106 |
< |
//No, really. :) |
107 |
< |
//Move to utilities.cpp when the time comes. |
108 |
< |
using namespace boost::filesystem; |
109 |
< |
using namespace std; |
110 |
< |
|
111 |
< |
void copy_directory( const path & from_dir_ph, |
112 |
< |
const path & to_dir_ph ); |
113 |
< |
|
114 |
< |
void copy( const path & from_file_ph, |
115 |
< |
const path & to_file_ph ); |
116 |
< |
|
117 |
< |
|
118 |
< |
// this function copies files and directories. If copying a |
119 |
< |
// directory to a directory, it copies recursively. |
120 |
< |
|
121 |
< |
//pardon the mess, I did this at midnight, and had to fix a bug |
122 |
< |
void copy( const path & from_ph, |
123 |
< |
const path & to_ph ) |
124 |
< |
{ |
125 |
< |
cout << to_ph.string() << "\n"; |
126 |
< |
// Make sure that the destination, if it exists, is a directory |
127 |
< |
if((exists(to_ph) && !is_directory(to_ph)) || (!exists(from_ph))) cout << "error"; |
128 |
< |
if(!is_directory(from_ph)) |
129 |
< |
{ |
130 |
< |
|
131 |
< |
if(exists(to_ph)) |
132 |
< |
{ |
133 |
< |
copy_file(from_ph,to_ph/from_ph.filename()); |
134 |
< |
} |
135 |
< |
else |
136 |
< |
{ |
137 |
< |
try{ |
138 |
< |
|
139 |
< |
copy_file(from_ph,to_ph); |
140 |
< |
} |
141 |
< |
catch (exception ex){ |
142 |
< |
cout << from_ph.string() << " to " << to_ph.string() << "\n"; |
143 |
< |
} |
144 |
< |
} |
145 |
< |
|
146 |
< |
} |
147 |
< |
else if(from_ph.filename() != ".svn") |
148 |
< |
{ |
149 |
< |
path destination; |
150 |
< |
if(!exists(to_ph)) |
151 |
< |
{ |
152 |
< |
destination=to_ph; |
153 |
< |
} |
154 |
< |
else |
155 |
< |
{ |
156 |
< |
destination=to_ph/from_ph.filename(); |
157 |
< |
} |
158 |
< |
//not sure what this did, its going away though. probably error checking ;) |
159 |
< |
//copy_directory(from_ph,destination); |
160 |
< |
|
161 |
< |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
162 |
< |
{ |
163 |
< |
//the idiot who coded this in the first place (not me) |
164 |
< |
//forgot to make a new directory. Exception city. x_x |
165 |
< |
create_directory(destination); |
166 |
< |
copy(*i,destination/i->filename()); |
167 |
< |
} |
168 |
< |
} |
169 |
< |
} |
170 |
< |
|
171 |
< |
void copy_directory( const path &from_dir_ph, |
172 |
< |
const path &to_dir_ph) |
173 |
< |
{ |
174 |
< |
if(!exists(from_dir_ph) || !is_directory(from_dir_ph) |
175 |
< |
|| exists(to_dir_ph)) |
176 |
< |
cout << !exists(from_dir_ph) << " " << !is_directory(from_dir_ph) |
177 |
< |
<< " " << exists(to_dir_ph); |
178 |
< |
//boost::throw_exception( filesystem_error( |
179 |
< |
//"boost::filesystem::copy_directory", |
180 |
< |
//from_dir_ph, to_dir_ph, boost::system::error_code() )); |
181 |
< |
|
182 |
< |
# ifdef BOOST_POSIX |
183 |
< |
struct stat from_stat; |
184 |
< |
if ( (::stat( from_dir_ph.string().c_str(), &from_stat ) != 0) |
185 |
< |
|| ::mkdir(to_dir_ph.native_directory_string().c_str(), |
186 |
< |
from_stat.st_mode)!=0) |
187 |
< |
# endif |
188 |
< |
// boost::throw_exception( filesystem_error( |
189 |
< |
// //"boost::filesystem::copy_directory", |
190 |
< |
// from_dir_ph, to_dir_ph, boost::system::error_code())); |
191 |
< |
} |
192 |
< |
|
193 |
< |
#endif |
194 |
< |
|
195 |
< |
#ifdef WIN32 |
196 |
< |
|
197 |
< |
#ifndef __GUICON_H__ |
198 |
< |
|
199 |
< |
#define __GUICON_H__ |
200 |
< |
|
201 |
< |
|
202 |
< |
|
203 |
< |
void RedirectIOToConsole(); |
204 |
< |
|
205 |
< |
|
206 |
< |
|
207 |
< |
#endif |
64 |
> |
bool ReadInstallInfoCfg(fstream *, Install_info_cfg *); |
65 |
|
|
66 |
|
/* End of File */ |
67 |
|
|
211 |
– |
|
212 |
– |
#include <windows.h> |
213 |
– |
|
214 |
– |
#include <stdio.h> |
215 |
– |
|
216 |
– |
#include <fcntl.h> |
217 |
– |
|
218 |
– |
#include <io.h> |
219 |
– |
|
220 |
– |
#include <iostream> |
221 |
– |
|
222 |
– |
#include <fstream> |
223 |
– |
|
224 |
– |
#ifndef _USE_OLD_IOSTREAMS |
225 |
– |
|
226 |
– |
using namespace std; |
227 |
– |
|
228 |
– |
#endif |
229 |
– |
|
230 |
– |
// maximum mumber of lines the output console should have |
231 |
– |
|
232 |
– |
static const WORD MAX_CONSOLE_LINES = 500; |
233 |
– |
|
234 |
– |
|
235 |
– |
void RedirectIOToConsole() |
236 |
– |
|
237 |
– |
{ |
238 |
– |
|
239 |
– |
int hConHandle; |
240 |
– |
|
241 |
– |
long lStdHandle; |
242 |
– |
|
243 |
– |
CONSOLE_SCREEN_BUFFER_INFO coninfo; |
244 |
– |
|
245 |
– |
FILE *fp; |
246 |
– |
|
247 |
– |
// allocate a console for this app |
248 |
– |
|
249 |
– |
AllocConsole(); |
250 |
– |
|
251 |
– |
// set the screen buffer to be big enough to let us scroll text |
252 |
– |
|
253 |
– |
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), |
254 |
– |
|
255 |
– |
&coninfo); |
256 |
– |
|
257 |
– |
coninfo.dwSize.Y = MAX_CONSOLE_LINES; |
258 |
– |
|
259 |
– |
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), |
260 |
– |
|
261 |
– |
coninfo.dwSize); |
262 |
– |
|
263 |
– |
// redirect unbuffered STDOUT to the console |
264 |
– |
|
265 |
– |
lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); |
266 |
– |
|
267 |
– |
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); |
268 |
– |
|
269 |
– |
fp = _fdopen( hConHandle, "w" ); |
270 |
– |
|
271 |
– |
*stdout = *fp; |
272 |
– |
|
273 |
– |
setvbuf( stdout, NULL, _IONBF, 0 ); |
274 |
– |
|
275 |
– |
// redirect unbuffered STDIN to the console |
276 |
– |
|
277 |
– |
lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); |
278 |
– |
|
279 |
– |
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); |
280 |
– |
|
281 |
– |
fp = _fdopen( hConHandle, "r" ); |
282 |
– |
|
283 |
– |
*stdin = *fp; |
284 |
– |
|
285 |
– |
setvbuf( stdin, NULL, _IONBF, 0 ); |
286 |
– |
|
287 |
– |
// redirect unbuffered STDERR to the console |
288 |
– |
|
289 |
– |
lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); |
290 |
– |
|
291 |
– |
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); |
292 |
– |
|
293 |
– |
fp = _fdopen( hConHandle, "w" ); |
294 |
– |
|
295 |
– |
*stderr = *fp; |
296 |
– |
|
297 |
– |
setvbuf( stderr, NULL, _IONBF, 0 ); |
298 |
– |
|
299 |
– |
|
300 |
– |
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog |
301 |
– |
|
302 |
– |
// point to console as well |
303 |
– |
|
304 |
– |
ios::sync_with_stdio(); |
305 |
– |
|
306 |
– |
} |
307 |
– |
|
308 |
– |
|
309 |
– |
|
68 |
|
//End of File |
69 |
|
|
70 |
< |
|
313 |
< |
|
314 |
< |
|
315 |
< |
|
316 |
< |
|
317 |
< |
#endif |
70 |
> |
#endif |