Dont know if you still visit the site but I tried your IrrIni. I realise this is 2 years old

. It still works with the newest version of Irrlicht, so that's nice.
It's good for the most part, but I have some comments.
I'm not sure why you would just convert an unsigned int to a signed one. Values larger than 2,147,483,647 will go into negative.
Code: Select all
void CIrrIniStub::setValue(const c8* section, const c8* key, u32 value)
{
setValue(section,key,(s32)value);
}
So instead I changed it to:
Code: Select all
void CIrrIniStub::setValue(const c8* section, const c8* key, u32 value)
{
c8 buf[20];
sprintf(buf,"%u",value);
setValue(section,key,buf);
}
I don't think that using random fixed size buffers like that is the best programming practice (eg 20), especially using Irrlicht, where you could just use Irrlicht's stringc. But this matches the behaviour of the other methods.
Also, in CIrrIniStub::addSection() I added if (!getSection(name)). Otherwise, adding a section with the same name again creates multiple sections with the same name, and adding to the section will always just add to the first one found. If you wanted you could make setValue() add the section if it doesn't exist too, I suppose.
Also in your constructor for CIrrIniStub, the first part of the code (the block that uses an IReadFile) you create a file but you never drop the file, this causes a memory leak. Changing it to look like this resolves the issue:
Code: Select all
IReadFile* readFile = fileSystem->createAndOpenFile(file);
if(readFile)
{
s32 size = readFile->getSize();
c8* buffer = new c8[size+2];
readFile->read(buffer,size);
buffer[size+1] = 0x0;
Content = buffer;
delete [] buffer;
readFile->drop(); // <- added this line
}
Lastly I wish you had used wide chars, so that values in say Japanese or whatever could be used in the ini files. But I guess that's being picky.
Overall though from my experience so far, it works well and I'll be using it. Saves me time to write my own one. I haven't thoroughly tested it though, I guess I'll post again if I find any other issues.
Cheers.