About files ...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
TomTim
Posts: 72
Joined: Mon Aug 16, 2010 5:32 pm
Location: NRW, Germany

About files ...

Post by TomTim »

I admit that file streams in .NET or in fstream.h are better to use than the streams/classes/functions in Irrlicht. I am totally cunfused.

My orders: Proof if the file exists. If it doesn't:
  • -create it.
    -write a few lines and informations.
else
  • -load the file byte for byte into a list (this allows fast changes).
    format it, for I need a special format.
    -save the changes, means: delete the file, create a empty new one and fill it with the content of the list's elements.
    -get the current size of the file (this allows fast reading access and spares memory).
    -allocate memory (size of the file).
    -load the file into the memory.
    -read the memory.
    -if no longer needed, free the memory.
But what kind of classes should I use? IReadFile and IWriteFile don't have the wanted interface (irr::io::IWriteFile::write(const void*,irr::u32) does not support to write in the middle of the file, it's just possible to append or to delete and then re-write the file, also I am not able to change the position pointer of the files). What would you advice me?
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Re: About files ...

Post by Luben »

TomTim wrote:also I am not able to change the position pointer of the files). What would you advice me?
Although i dont understand the rest of your post, this part made me look at the IWriteFile-interface and find this method:

Code: Select all

		//! Changes position in file
		/** \param finalPos Destination position in the file.
		\param relativeMovement If set to true, the position in the file is
		changed relative to current position. Otherwise the position is changed
		from begin of file.
		\return True if successful, otherwise false. */
		virtual bool seek(long finalPos, bool relativeMovement = false) = 0;
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Yes seek is the method you are looking for. Exactly the same name as for .NET streams and std::fstream...

However if I get you right you are loading the file, write it, and then load it again? The second load doesn't make sense since you already have all the data you want in memory...
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
TomTim
Posts: 72
Joined: Mon Aug 16, 2010 5:32 pm
Location: NRW, Germany

Post by TomTim »

Luben wrote:Although i dont understand the rest of your post, this part made me look at the IWriteFile-interface and find this method:

Code: Select all

        //! Changes position in file
        /** \param finalPos Destination position in the file.
        \param relativeMovement If set to true, the position in the file is
        changed relative to current position. Otherwise the position is changed
        from begin of file.
        \return True if successful, otherwise false. */
        virtual bool seek(long finalPos, bool relativeMovement = false) = 0;
Sylence wrote:Yes seek is the method you are looking for. Exactly the same name as for .NET streams and std::fstream...
Sorry, my brain might have slept. I forgot that I need to write INTO THE LIST, not INTO THE FILE ON HARD DISK. So I just need to load the file byte for byte into the list and format it.
Sylence wrote:However if I get you right you are loading the file, write it, and then load it again? The second load doesn't make sense since you already have all the data you want in memory...
I confess, it's hard to understand. I wanna write an ini file, using a special format. I wanna avoid empty blocks like this:

Code: Select all

   [  IrrRenderingOptions ]   ;Noticed the whitespaces?
     AntiAliasing  =    4         ;Once again ...
  IsFullscreen      = 1          ;One more time ...
First, it looks awful, second, I don't even dream of building-in a 'whitespaceskipper'. So I wanna delete every whitespace-character, for that I need it to load in the memory as a list, for its strucure allows me to delete and insert items in the middle without re-order the whole file - a few months ago, I did some tests with formating files, and a list is some times faster in changes than a array - about 15 times (for each processor core). At this point, the file should look like this:

Code: Select all

[IrrRenderingOptions];That looks way better,
AntiAliasing=4;does it?
IsFullscreen=1
But for a read-out, a list is way to uncomfortable. I can't call the items by its indices (what I need - special for my program), so I need a easy-to-read-array. See?
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
TomTim
Posts: 72
Joined: Mon Aug 16, 2010 5:32 pm
Location: NRW, Germany

Post by TomTim »

Sylence wrote:Maybe this helps:
http://www.btbsoft.org/software/irrini/ ;)
Seems to be very helpful. Thank you very much. :D
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

I might find use for this as well, +1 for sharing
TomTim
Posts: 72
Joined: Mon Aug 16, 2010 5:32 pm
Location: NRW, Germany

Post by TomTim »

It's me again, and I got a problem with IrrINI. I changed the project settings of my downloaded project, for I wanted to include IrrINI as a DLL. I changed it successfully, but now my compiler just creates a DLL-file without the common LIB-file. The console of my compiler shows that just one DLL-file was created. Any ideas how I get the LIB attached to the DLL?
Post Reply