Filelist/filesystem problems -- Null pointer
Posted: Sat Feb 17, 2007 7:36 pm
Hi, I have a method setup in my project that loads bmps using the irrlicht io system and I am having some touble.
The method goes through a folder called PLAYER, which holds all the player's bmp files and loads them into CSprite objects.
The problem is at this line:
The method terminates because of a null pointer, but I dont understand why. From what i can see there shouldn't be any problems (but then again I'm dumb, so thats why I'm asking)
I am using DevCpp and irrlicht 1.2. The only other lib file besides the irrlicht files is libwinmm.a, if thats any help. If any other information is required please let me know.
I am very confused and frustrated so any help would be greatly appreciated.
Code: Select all
bool CPlayer::loadSprites(video::IVideoDriver* driver, IrrlichtDevice* device)
{
if(device == NULL)
{
return false;
}
if(driver == NULL)
{
return false;
}
io::IFileSystem* filesystem = device->getFileSystem();
if(filesystem == NULL)
{
return false;
}
if(!filesystem->changeWorkingDirectoryTo("PLAYER"))
{
return false;
}
io::IFileList* filelist = filesystem->createFileList();
if(filelist == NULL)
{
return false;
}
if(filelist->getFileCount() == 0)
{
return false;
}
else
{
for(int i = 2; i < filelist->getFileCount() - 2; i++)
{
c8 filename[MAX_PATH] = "";
strcpy(filename, filelist->getFileName(i));
if(strstr(filename, "up"))
{
c8 name[12] = "";
strcpy(name, filelist->getFileName(i));
sprite_sheet[0]->setname(name);
sprite_sheet[0]->setSprite(driver->getTexture(sprite_sheet[0]->getname()));
}
else if(strstr(filename, "down"))
{
c8 name[12] = "";
strcpy(name, filelist->getFileName(i));
sprite_sheet[1]->setname(name);
sprite_sheet[1]->setSprite(driver->getTexture(sprite_sheet[1]->getname()));
}
else if(strstr(filename, "left"))
{
c8 name[12] = "";
strcpy(name, filelist->getFileName(i));
sprite_sheet[2]->setname(name);
sprite_sheet[2]->setSprite(driver->getTexture(sprite_sheet[2]->getname()));
}
else if(strstr(filename, "right"))
{
c8 name[12] = "";
strcpy(name, filelist->getFileName(i));
sprite_sheet[3]->setname(name);
sprite_sheet[3]->setSprite(driver->getTexture(sprite_sheet[3]->getname()));
}
}
filelist->drop();
return true;
}
return false;
}
The problem is at this line:
Code: Select all
io::IFileList* filelist = filesystem->createFileList();
if(filelist == NULL)
{
return false;
}
I am using DevCpp and irrlicht 1.2. The only other lib file besides the irrlicht files is libwinmm.a, if thats any help. If any other information is required please let me know.
I am very confused and frustrated so any help would be greatly appreciated.