Original Post
I have completed a resource file system for my game, and am nearly done with my editor too. But one thing has struck me about the manipulation of the objects in my file.
The problem is, the file could contain a large number of bitmaps / text etc. If one of these is edited, and it''s size changes then I Save it to the end of the file and adjust a file_item record to record it''s new position. At some point I will operate a compress routine which tidies up the file, and reorganises it so that all bitmaps for a screen are together for example. This is all done on the live file, and so if something happens eg a power outage the file may be corrupted.
So, when I am running a Tidy_File routine is it better to make a copy of the file in a tmp directory, and only when the work is finished delete the temp (and if so, can someone give me some pointers as to the best way to achieve this), or to create a new file (eg Data1, copy and update from the old file into the new file, close the new filw, delete the old file and rename the new file ?
My game also has a variety of data stores including vectors of data, text, bitmaps etc. Using Streams I can output all my data from my structures into the file, but is there a more elegant way than having a function to parse each of my structure types in turn into the file, and hence I also need one to re-load them.
I have a load of functions that take the appropriate type and dump the data to file, but is there some commands / operations that mean I need a single function that takes a pointer to an object and irrespective of it''s data sends or loads it from disk ?
TIA,
BP