| 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 |
|
|
| 53 |
|
string filename = "\0"; |
| 54 |
|
string MODINFO_CFG = "\\Mod_Info.cfg"; |
| 55 |
|
|
| 56 |
< |
string line; |
| 56 |
> |
|
| 57 |
|
|
| 58 |
|
DIR *pdir; |
| 59 |
|
struct dirent *pent; |
| 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(); |
| 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 |
|
|