Commit 5188fe69 authored by James Johns's avatar James Johns

Linux compatible implementation of searching ./expansions/

Linux uses dirent syscalls to search ./expansions/ for dard databases
to load.
parent 99754f54
...@@ -27,7 +27,6 @@ bool Game::Initialize() { ...@@ -27,7 +27,6 @@ bool Game::Initialize() {
_finddata_t fdata; _finddata_t fdata;
long fhandle; long fhandle;
char fpath[1000] = "./expansions/"; char fpath[1000] = "./expansions/";
char fpath[1000] = "expansions\\";
#endif #endif
srand(time(0)); srand(time(0));
LoadConfig(); LoadConfig();
...@@ -76,6 +75,25 @@ bool Game::Initialize() { ...@@ -76,6 +75,25 @@ bool Game::Initialize() {
} }
_findclose(fhandle); _findclose(fhandle);
} }
#else
DIR * dir;
struct dirent * dirp;
const char *foldername = "./expansions/";
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername)));
strncpy(filepath, foldername, strlen(foldername)+1);
strncat(filepath, dirp->d_name, len);
std::cout << "Found file " << filepath << std::endl;
if (!dataManager.LoadDB(filepath))
std::cout << "Error loading file" << std::endl;
free(filepath);
}
closedir(dir);
}
#endif #endif
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment