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

Comparing AE/Installer/trunk/source/subs.cpp (file contents):
Revision 289 by iritscen, Mon Mar 30 16:19:50 2009 UTC vs.
Revision 290 by gumby, Sat Apr 4 04:13:36 2009 UTC

# Line 9 | Line 9 | Needs getPackages() now!
9   #include "methods.h"
10   #include <vector>
11  
12 + #include <errno.h>
13 + #include "Include\dirent.h"
14 + #include <stdio.h>
15 + #include <stdlib.h>
16 +
17 +
18   using namespace std;
19   bool FALSE = 0;
20   bool TRUE = 0;
# Line 18 | Line 24 | int main(void)
24   {
25  
26          //      SetConsoleTitle("AE Installer"); windows junk, convert to SDL
27 < //      system("color 0A");
27 >        //      system("color 0A");
28 >        
29          cout << "\nWelcome to the AE installer!\n";
30  
31          cout << "\nWhat would you like to do?\n";
32          
33          return mainMenu();
34 <
34 > }
35 >
36 > vector<ModPackage> getPackages(void) {
37 >        vector<ModPackage> packages;
38 >        packages.reserve(256); //thats 63 or 64 pointers to packages...i think. :P Reserving this improves performance when we add new pointers
39 >        
40 >        #ifdef WIN32
41 >                string path = "K:\\Oni\\edition\\install\\packages"; //only for my build. :P
42 >        #else
43 >                string path = "K:\\Oni\\edition\\install\\packages"; //change this, 'scen.
44 >        #endif
45 >
46 >        string filename = "\0";
47 >        string MODINFO_CFG = "\\Mod_Info.cfg";
48 >        DIR *pdir;
49 >        struct dirent *pent;
50 >
51 >        pdir = opendir( path.c_str() ); //"." refers to the current dir
52 >        if (!pdir){
53 >                printf ("opendir() failure; terminating");
54 >                exit(1);
55 >        }
56 >        errno=0;
57 >        while ((pent=readdir(pdir))){
58 >                
59 >                
60 >                filename = path + '\\' + pent->d_name + MODINFO_CFG;
61 >                
62 >                //cout << filename << "\n";
63 >
64 >                if (FILE * file = fopen( filename.c_str(), "r"))
65 >                {
66 >                        //do stuff like adding to vector :P
67 >                        
68 >                        cout << pent->d_name << "\n";
69 >                        
70 >                        //would prefer to push a pointer to a package, but this will do for now
71 >                        //packages.push_back(modelfileToModPackage(file *))
72 >                        fclose(file);
73 >                }
74 >
75 >        }
76 >
77 >        
78 >        if (errno){
79 >                printf ("readdir() failure; terminating");
80 >        exit(1);
81 >        }
82 >        closedir(pdir);
83          
84 +        
85 +        return packages;
86   }
87  
88   int mainMenu(void) {
# Line 68 | Line 125 | void installPackages() {
125          vector<ModPackage>::iterator iter;
126          iter = packages.begin();
127          
128 +        getPackages();
129 +
130          if (packages.empty()) {
131                  cout << "Error: You have no packages!\n";
132                  return;

Diff Legend

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