Abstracting file streams
File I/O APIs differ slightly between Windows and Android (POSIX) operating systems, and we have to hide these differences behind a consistent set of C++ interfaces. All libraries we have compiled in Chapter 2, Porting Common Libraries use their own callbacks and interfaces. In order to unify them, we shall write adapters in this and subsequent chapters.
Getting ready
Please make sure you are familiar with the UNIX concept of the file and memory mapping. Wikipedia may be a good start (http://en.wikipedia.org/wiki/Memory-mapped_file).
How to do it...
- From now on, our programs will read input data using the following simple interface. The base class
iObject
is used to add an intrusive reference counter to instances of this class:class iIStream: public iObject { public: virtual void Seek( const uint64 Position ) = 0; virtual uint64 Read( void* Buf, const uint64 Size ) = 0; virtual bool Eof() const = 0; virtual uint64 GetSize() const = 0; virtual uint64...