Changeset 293 for AE/Installer
- Timestamp:
- Apr 4, 2009, 10:14:05 PM (16 years ago)
- Location:
- AE/Installer/trunk/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/Installer/trunk/source/methods.h
r292 r293 6 6 7 7 struct ModPackage { 8 bool isInstalled; //replace with function 9 string *name; 8 bool isInstalled; //replace with function 9 string name; 10 string modString; 11 bool hasOnis; 12 bool hasDeltas; 13 bool hasBSL; 14 bool hasDats; 15 bool category; 16 string creator; 17 bool isEngine; 18 string readme; 19 bool globalNeeded; 10 20 }; 11 21 12 22 int mainMenu(); 13 23 vector<ModPackage> getPackages(); 14 ModPackage fileToModPackage(fstream );24 ModPackage fileToModPackage(fstream&); 15 25 16 26 void installPackages(); … … 20 30 bool getDirectoryContents(char , char &); 21 31 32 33 void Tokenize(const string& str, 34 vector<string>& tokens, 35 const string& delimiters = " ") 36 { 37 // Skip delimiters at beginning. 38 string::size_type lastPos = str.find_first_not_of(delimiters, 0); 39 // Find first "non-delimiter". 40 string::size_type pos = str.find_first_of(delimiters, lastPos); 41 42 while (string::npos != pos || string::npos != lastPos) 43 { 44 // Found a token, add it to the vector. 45 tokens.push_back(str.substr(lastPos, pos - lastPos)); 46 // Skip delimiters. Note the "not_of" 47 lastPos = str.find_first_not_of(delimiters, pos); 48 // Find next "non-delimiter" 49 pos = str.find_first_of(delimiters, lastPos); 50 } 51 } -
AE/Installer/trunk/source/subs.cpp
r292 r293 12 12 13 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 15 19 #include <stdio.h> 16 20 #include <stdlib.h> … … 50 54 string MODINFO_CFG = "\\Mod_Info.cfg"; 51 55 52 string line;56 53 57 54 58 DIR *pdir; … … 74 78 75 79 //do stuff like adding to vector :P 76 cout << pent->d_name << "\n"; 77 while (! file.eof() ) 78 { 79 getline (file,line); 80 cout << line << endl; 81 } 80 82 81 //would prefer to push a pointer to a package, but this will do for now 83 //packages.push_back( fileToModPackage(file) );82 packages.push_back( fileToModPackage(file) ); 84 83 85 84 } … … 100 99 } 101 100 102 ModPackage fileToModPackage(fstream file) { 103 ModPackage package; 104 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 105 146 return package; 106 147 }
Note:
See TracChangeset
for help on using the changeset viewer.