File system thoughts

This post is very old. Please bear in mind that information here might be incorrect or obsolete, and links can be broken. If something seems wrong, please feel free to comment or contact me and I'll update the post.

I’ve been working today morning on the file system (today afternoon I’m going to install my new Asus K8N-SLI Premium ;) mobo so my desktop PC will be running again). I’ve added some generic stream classes: IStreamMemoryStreamTextStream and IFile. Some of them depend on each other, MemoryStreams can be streamed into IFiles, the same is true for the TextStreams. The log uses now the TextStream which means that is basically stores a TestStream and the output file and redirects all incoming data to the TextStream with a bit of formatting (log prepends the current timestamp).

This approach has some nice advantages as for example MemoryArchive can wrap around a MemoryStream and does not need to fall back to the C++ IOStreams internally. MemoryArchive provides some serialization functions for primitive data types and hides a bit of MemoryStream‘s functions (namely, the raw read/write functions, and the seek function). Another nice thing is that MemoryArchive can stream into any kind of stream now, including MemoryStream – which means you can do deep copies “for free” without additional work. Code like this is enough:

MemoryArchive::operator=(MemoryArchive& rhs)
{
	MemoryStream stream;
	streamTo (&stream);
	rhs.streamFrom (&stream);
}

So much for now, I’ll post a few more details when the refactoring/rewrite is over.

Related posts:

  1. File I/O performance
  2. Some random thoughts
  3. Thoughts on scripting

This entry was posted in Programming and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>