Page 6 of 6

Posted: Mon Feb 25, 2008 3:41 pm
by Sylence
Bad news:

My hoster kilu.de got hacked and all user accounts and data has been deleted and couldn't be restored.

The real bad thing is, that I didn't have any local backups of the website so I have to create a new one which will take some time.

Don't worry the projects themselves are backed up ;)

However the hack has its good sites, too.
The new site will be hosted on an root server running only two websites (mine plus another).

So the performance should be very high.
You can reach my site with this url (the old domain doesn't work on the root server... strange)
http://btbsoft.org

Posted: Wed Feb 27, 2008 1:47 pm
by MickeyKnox
Hi, i think i found a bug in getValueW:

you're creating a local variable str and returning a pointer to it's content.
But when conrol exits this method, the local variable is destroyed and the
pointer points anywhere.

I fixed it for me this way:

Code: Select all

const wchar_t* CIniFileReaderStub::getValueW(const c8* section, const c8* key)
{
  w_value = core::stringw(getValue(section,key));
  return w_value.c_str();
}
with w_value being a private class variable.

Posted: Wed Feb 27, 2008 3:41 pm
by Sylence
Thanks a lot!

This bug and the one MasterGod posted are fixed. The archive on the site is updated.

Thanks for finding the bugs :)

Posted: Sat Dec 27, 2008 8:08 pm
by MasterGod
@Sylence: Any updates with the actual code?

Posted: Sat Dec 27, 2008 8:12 pm
by Sylence
No sorry. I was very busy the last time and I somehow lost the overview of what have to be done with it. Still trying to figure out a way to make it more easily expandable but I just can't figure out a way of dealing with the different Irrlicht types in a more abstract way (and of all the features I want to have in the conversation to irrlicht core types is the number 1)

Either it's now bug-free because there hasn't been a bug report for a while now, or no one is using this anymore...

Posted: Sun Dec 28, 2008 3:08 am
by Sylence
Ok did a coding marathon and made version 0.3 in a few hours :)
I'm afraid I did more damage than I repaired ^^

Finally fixed that empty line thing at the end of the file =)

Check it out at my site

Posted: Sun Dec 28, 2008 8:48 pm
by MasterGod
Sylence wrote:Finally fixed that empty line thing at the end of the file =)
Well what was it then? How did you fix it?

Posted: Mon Dec 29, 2008 8:55 am
by Sylence
Actually I don't really know. I used strtok to read the lines of the file and now I switched to string::findFirst and string::findNext and now it works...

Posted: Thu Jul 09, 2009 5:07 pm
by Sylence
Half a year later I finally managed to find some time to implement comments.

When you load a file with comments (starting with ; or ##) they will be stored and will be written to the file when saved.
Also you can add / change comments during runtime.

A comment is always associated with the section or key that follows the comment.

Download can be found here

Posted: Tue Jun 14, 2011 7:14 am
by Reiko
Dont know if you still visit the site but I tried your IrrIni. I realise this is 2 years old :P. 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.