Game Development Reference
In-Depth Information
VirtualName ) ? NULL : File;
}
private:
std::string FPhysicalName;
};
7.
The collection of mount points will be called FileSystem , as shown in the
following code:
class FileSystem: public iObject
{
public:
void Mount( const std::string& PhysicalPath );
void AddAlias(const std::string& Src,
const std::string& Prefix );
std::string VirtualNameToPhysical(
const std::string& Path ) const;
bool FileExists( const std::string& Name ) const;
private:
std::vector< clPtr<iMountPoint> > FMountPoints;
};
How it works...
The MapName() member function transforms a given virtual ilename into a form that can be
passed to the CreateReader() method.
The FS_IsFullPath() function checks if the path starts with the / character on Android, or
contains the :\ substring on Windows. The Str_AddTrailingChar() function ensures we
have a path separator at the end of the given path.
The FileSystem object acts as a container of the mount points, and redirects the ile
reader creation to the appropriate points. The Mount method determines the type of the
mount point. If the PhysicalPath ends with either .zip or .apk substrings, an instance
of the ArchiveMountPoint class is created, otherwise the PhysicalMountPoint class
is instantiated. The FileExists() method iterates the active mount points and calls the
iMountPoint::FileExists() method. The VirtualNameToPhysical() function
inds the appropriate mount point and calls the iMountPoint::MapName() method for
the ilename to make it usable with the underlying OS I/O functions. Here we omit the trivial
details of the FMountPoints vector management.
There's more...
Using our FileSystem::AddAlias method, we can create a special mount point that
decorates a ilename:
 
Search WWH ::




Custom Search