So I'm reconsidering the idea of making an abstracted File + Filesystem lib primarily geared towards adding functionality standard libs lack and adding support for the possibility of different kinds of file systems (like archives).
Basically it will be a lib for using .zip files that doesn't suck -- but it'll have other perks as well (such as being
easy to derive from).
To do this I'll need to make my own abstracted 'File' class from which I'll derive classes that read files from .zip and other kinds of archives.
I got it in my head that I want this lib to be as compatible as possible so that people won't have to rewrite their programs to make use of it. One way to do this would be to have my File class derive from std::iostream so that existing code which uses standard streams would still work.
The problem is, iostream is a beast and I have no idea how I'd go about doing this. I googled for a solution (briefly... I didn't put much effort into it) and I found 2 pages on point:
- One said "don't do it, users aren't supposed to derive from it":
http://stackoverflow.com/questions/4482116/inherit-stdostream
- The other was like a 200 page article and seemed overly wordy and complicated (but I only skimmed, so maybe it's not so bad?):
http://spec.winprog.org/streams/
From looking at the ref pages on this site, I get the impression that all I might have to do is derive another class from std::streambuf and just give a pointer to that to std::iostream on construction.
But even if that's right, deriving from streambuf doesn't seem any simpler.
Has anyone done this before? Is there any simple guide that explains how to do this? All I really need is a list of functions I need to implement and an explanation of what they need to do. And any other conditions/requirements I need to adhere to.
I vaguely recall someone (Duoas? helios?) posted a class that derived from iostream and used cstdio internally a while back.
Thanks!