-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Android NDK Game Development Cookbook
By :
Quite frequently, our application might want to store some of its data on the disk. Another typical use case we have already encountered is the downloading of some file from the network into a memory buffer. Here, we implement two variations of the iOStream interface for the ordinary and in-memory files.
Let us derive the FileWriter class from the iOStream interface. We add the Open() and Close() member functions on top of the iOStream interface and carefully implement the Write() operation. Our output stream implementation does not use memory-mapped files and uses ordinary file descriptors, as shown in the following code:
class FileWriter: public iOStream
{
public:
FileWriter(): FPosition( 0 ) {}
virtual ~FileWriter() { Close(); }
bool Open( const std::string& FileName )
{
FFileName = FileName;We split Android and Windows-specific code paths using defines:
#ifdef _WIN32
FMapFile = CreateFile( FFileName.c_str(),GENERIC_WRITE, FILE_SHARE_READ...
Change the font size
Change margin width
Change background colour