anyway, since irrlicht has quite a few filesystem tools it presumably also has the ability to run the equivalent of ls and getting a file list, no?
Well, in any case - I tried my best at replicating such functionality in any meaningful way (I need to get a list of files so I can load them, and I don't know the file names at compile time)
If so, currently I just load strings from xml (this is not extensible) and then for each path I do this (minimal example with hardcoded path):
Code: Select all
std::string fpath = "data/models/levels/alphamap.obj";
io::IFileSystem* FileSystem = device->getFileSystem();
if (FileSystem->existFile(fpath.c_str()))
{
IAnimatedMesh* levelMesh = smgr->getMesh(fpath.c_str());
IMeshSceneNode* level = smgr->addMeshSceneNode(levelMesh);
if (level)
{
level->setMaterialFlag(EMF_LIGHTING, false);
level->setPosition(level->getPosition() + vector3df(0.0f, 0.0f, 50.0f));
}
else
{
level->drop();
level = smgr->addCubeSceneNode(10.0f, 0, -1);
level->setMaterialFlag(EMF_LIGHTING, false);
level->setPosition(level->getPosition() + vector3df(0.0f, 0.0f, 50.0f));
}
}
Code: Select all
io::IFileSystem* fs = Game->device->getFileSystem();
fs->changeWorkingDirectoryTo("Data/");
IFileList *fileList = fs->createFileList();
fs->setFileListSystem(FILESYSTEM_NATIVE);
for (int i = 0; i < fileList->getFileCount(); ++i)
{
s = fileList->getFullFileName(i);
if (s.find(".obj") >= 0)
{
printf("path: %s\n", s);
}
}
but all lines are just "path: c" and I'm definitely certain none of the obj. files are named "c"; this implies that I misunderstand how to use that. s is defined as a core::stringw type, if that matters.
So the question is; what exactly am I doing wrong?
Worth noting is: I get exactly 10 lines out, so it is finding 10 obj files.