Original Post
Hi,
I''m writing a logger to log debug messages, etc. its output is in HTML format.
I want to use an overloaded insertion operator and the unitbuf manipulator to flush the bytes to the file everytime.
I need to be able to jump from place to place in the file to write stuff there, but using the insertion operator would simply overwrite bytes in the file instead of copying the bytes around to fit new bytes in between. What''s a good way to achieve that?
1) Reading the bytes from the file that occur after the insertion point, then inserting the new ones and writing the other bytes to the end again doesn''t sound like a good idea once the logfile gets too big (several MB). Then again I could split the logfile up after it reaches a specific size.
2) Another solution I thought about was to leave an excact copy of the whole file in memory all the time and the insertion operator would perform insertions on the memoryfile and the file on the disk, this would save me one read operation on the diskfile and replace it with a copy and write operation on the memory file - RAM-size is no issue. Again this could be coupled with splitting the file into several parts (not all of the files are going to be written to and could be locked).
What do you think?
joni the shmups creators board @