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 292 by gumby, Sat Apr 4 08:13:56 2009 UTC vs.
Revision 293 by gumby, Sat Apr 4 20:14:05 2009 UTC

# Line 11 | Line 11 | Needs getPackages() now!
11   #include <fstream>
12  
13   #include <errno.h>
14 < #include "Include\dirent.h"
14 > #ifdef WIN32
15 >        #include "Include\dirent.h"
16 > #else
17 >        #include <dirent.h> //??? is this included for Macs?
18 > #endif
19   #include <stdio.h>
20   #include <stdlib.h>
21  
# Line 49 | Line 53 | vector<ModPackage> getPackages(void) {
53          string filename = "\0";
54          string MODINFO_CFG = "\\Mod_Info.cfg";
55  
56 <        string line;
56 >        
57  
58          DIR *pdir;
59          struct dirent *pent;
# Line 73 | Line 77 | vector<ModPackage> getPackages(void) {
77                          //file.open(filename.c_str(), fstream::out);
78                                  
79                          //do stuff like adding to vector :P
80 <                        cout << pent->d_name << "\n";
77 <                        while (! file.eof() )
78 <                        {
79 <                                getline (file,line);
80 <                                 cout << line << endl;
81 <                        }
80 >
81                          //would prefer to push a pointer to a package, but this will do for now
82 <                        //packages.push_back( fileToModPackage(file) );
82 >                        packages.push_back( fileToModPackage(file) );
83                          
84                  }      
85                  file.close();
# Line 99 | Line 98 | vector<ModPackage> getPackages(void) {
98          return packages;
99   }
100  
101 < ModPackage fileToModPackage(fstream file) {
102 <        ModPackage package;
103 <                cout << file;
101 > ModPackage fileToModPackage(fstream &file) {
102 >        ModPackage package = {0, ""};
103 >        string line;
104 >        static string NameOfMod = "NameOfMod"; //used for comparing to the current token
105 >        static string SLASHSLASH = "//";
106 >        static string ARROW = "->";
107 >                        while (! file.eof() )
108 >                        {
109 >                                getline (file,line);
110 >                                     vector<string> tokens;
111 >                                         vector<string>::iterator iter;
112 >                                Tokenize(line, tokens);                                 //string to vector of "words"
113 >                                if (tokens.capacity() >= 2) {                   //make sure they are using enough stuff
114 >                                        iter = tokens.begin();                          //what word we are on, starts at first word
115 >                                                                                /*
116 >                                        if (!AEInstallVersion.compare(*iter))
117 >                                                If mod is too old, skip this mod.
118 >                                        */
119 >                                        /*else*/if (!NameOfMod.compare(*iter))  {       //if it contains the name
120 >                                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
121 >                                                        if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) {                 //ignores "->" and "NameOfMod"
122 >                                                                //cout << *iter;
123 >                                                                //cout << " ";
124 >                                                                package.name += *iter + " ";
125 >                                                        }
126 >                                                }
127 >                                                cout << package.name; cout << "\n"; //remove this when done
128 >                                        /*
129 >                                        else if (!ModString.compare(*iter)
130 >                                        else if (!HasOnis.compare(*iter)
131 >                                        else if (!HasDeltas.compare(*iter)
132 >                                        else if (!HasBSL.compare(*iter)
133 >                                        else if (!HasDats.compare(*iter)
134 >                                        else if (!Category.compare(*iter)
135 >                                        else if (!Creator.compare(*iter)
136 >                                        else if (!IsEngine.compare(*iter)
137 >                                        else if (!Readme.compare(*iter)
138 >                                        else if (!GlobalNeeded.compare(*iter)
139 >                                        */
140 >                                        }
141 >                                        //cout << *iter;
142 >                                }
143 >                        
144 >                        }
145 >                        
146          return package;
147   }
148  

Diff Legend

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