Game Development Reference
In-Depth Information
virtual const ubyte* GetFileData() const = 0;
virtual uint64 GetFileSize() const = 0;
protected:
std::string FFileName;
std::string FVirtualFileName;
};
Along with the trivial GetFileName() and SetFileName() methods implemented here, in
the following recipes we implement the GetFileData() and GetFileSize() methods.
How it works...
The iIStream::BlockRead() method is useful when handling non-seekable streams.
For the fastest access possible, we use memory-mapped iles implemented in the following
recipe. The MapStream() and MapStreamFromCurrentPos() methods are there to
provide access to memory-mapped iles in a convenient way. These methods return a pointer
to the memory where your ile, or a part of it, is mapped to. The iOStream::Write()
method works similar to the standard ofstream::write() function. Refer to the project
1_AbstractStreams for the full source code of this and the following recipe.
There's more...
The important problem while programming for multiple platforms, in our case for Windows and
Linux-based Android, is the conversion of ilenames.
We deine the following PATH_SEPARATOR constant, using OS-speciic macros, to determine
the path separator character in the following way:
#if defined( _WIN32 )
const char PATH_SEPARATOR = '\\';
#else
const char PATH_SEPARATOR = '/';
#endif
The following simple function helps us to make sure we use valid ilenames for our
operating system:
inline std::string Arch_FixFileName(const std::string& VName)
{
std::string s( VName );
std::replace( s.begin(), s.end(), '\\', PATH_SEPARATOR );
std::replace( s.begin(), s.end(), '/', PATH_SEPARATOR );
return s;
}
 
Search WWH ::




Custom Search