| 8 |
|
#include <iostream> |
| 9 |
|
#include "methods.h" |
| 10 |
|
#include <vector> |
| 11 |
+ |
#include <fstream> |
| 12 |
|
|
| 13 |
|
#include <errno.h> |
| 14 |
|
#include "Include\dirent.h" |
| 38 |
|
vector<ModPackage> packages; |
| 39 |
|
packages.reserve(256); //thats 63 or 64 pointers to packages...i think. :P Reserving this improves performance when we add new pointers |
| 40 |
|
|
| 41 |
+ |
fstream file; |
| 42 |
+ |
|
| 43 |
|
#ifdef WIN32 |
| 44 |
|
string path = "K:\\Oni\\edition\\install\\packages"; //only for my build. :P |
| 45 |
|
#else |
| 48 |
|
|
| 49 |
|
string filename = "\0"; |
| 50 |
|
string MODINFO_CFG = "\\Mod_Info.cfg"; |
| 51 |
+ |
|
| 52 |
+ |
string line; |
| 53 |
+ |
|
| 54 |
|
DIR *pdir; |
| 55 |
|
struct dirent *pent; |
| 56 |
|
|
| 59 |
|
printf ("opendir() failure; terminating"); |
| 60 |
|
exit(1); |
| 61 |
|
} |
| 62 |
< |
errno=0; |
| 63 |
< |
while ((pent=readdir(pdir))){ |
| 64 |
< |
|
| 62 |
> |
errno=0; |
| 63 |
> |
|
| 64 |
> |
while (( pent = readdir(pdir) )){ |
| 65 |
|
|
| 66 |
|
filename = path + '\\' + pent->d_name + MODINFO_CFG; |
| 67 |
< |
|
| 67 |
> |
file.open(filename.c_str()); |
| 68 |
> |
|
| 69 |
|
//cout << filename << "\n"; |
| 70 |
|
|
| 71 |
< |
if (FILE * file = fopen( filename.c_str(), "r")) |
| 71 |
> |
if(!file.fail() ) |
| 72 |
|
{ |
| 73 |
+ |
//file.open(filename.c_str(), fstream::out); |
| 74 |
+ |
|
| 75 |
|
//do stuff like adding to vector :P |
| 67 |
– |
|
| 76 |
|
cout << pent->d_name << "\n"; |
| 77 |
< |
|
| 77 |
> |
while (! file.eof() ) |
| 78 |
> |
{ |
| 79 |
> |
getline (file,line); |
| 80 |
> |
cout << line << endl; |
| 81 |
> |
} |
| 82 |
|
//would prefer to push a pointer to a package, but this will do for now |
| 83 |
< |
//packages.push_back(modelfileToModPackage(file *)) |
| 84 |
< |
fclose(file); |
| 85 |
< |
} |
| 86 |
< |
|
| 83 |
> |
//packages.push_back( fileToModPackage(file) ); |
| 84 |
> |
|
| 85 |
> |
} |
| 86 |
> |
file.close(); |
| 87 |
> |
file.clear(); |
| 88 |
> |
|
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 99 |
|
return packages; |
| 100 |
|
} |
| 101 |
|
|
| 102 |
+ |
ModPackage fileToModPackage(fstream file) { |
| 103 |
+ |
ModPackage package; |
| 104 |
+ |
cout << file; |
| 105 |
+ |
return package; |
| 106 |
+ |
} |
| 107 |
+ |
|
| 108 |
|
int mainMenu(void) { |
| 109 |
|
int choice = '0'; |
| 110 |
|
bool ok = FALSE; |