ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/Installer/trunk/source/installer.h
(Generate patch)

Comparing AE/Installer/trunk/source/installer.h (file contents):
Revision 324 by iritscen, Tue May 26 17:52:10 2009 UTC vs.
Revision 379 by iritscen, Mon Jun 29 19:23:42 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)