Filesystem
Access to files is made with FileManager class. FileManager is responsible for operations made with all files.
File class is interface to file. Each File has member FileHandle, which is responsible for all file operations such as reading data from file (so far).
"True" file management is made by VirtualFileSystem class (VFS) (which is actually member of FileManager clas) which stores all resources of games (images, cursor, videos, ...). First, configuration files are read, and data paths or library files paths are obtained from it (Library is container (of files) for resources, something like ZIP file). Each path is iterated and resources are added to resource map. Resource map is map container of pair resource name, VFSEntry. VFSEntry is abstract class which can represent file (VFSEntryFile) or directory (VFSEntryDirectory). File can be real file on filesystem, or file inside library (If it is real file, FileHandle uses std::ifstream of that file for operations. If the file is inside library, std::ifstream use library file (with offsets inside library file) for operations). So it is with directories. When a user want to open some file i.e. "file.stci" first, the VFS entry for that resource is search. If found, then if it is real file on filesystem (i.e. /home/trigve/data/file.stci), FileHandle is created by FileManager and File object is returned. If file is inside some library, library is found, file inside that library is found, FileHandle created and File object returned.
Here is class diagram of filesystem package:

File class is interface to file. Each File has member FileHandle, which is responsible for all file operations such as reading data from file (so far).
"True" file management is made by VirtualFileSystem class (VFS) (which is actually member of FileManager clas) which stores all resources of games (images, cursor, videos, ...). First, configuration files are read, and data paths or library files paths are obtained from it (Library is container (of files) for resources, something like ZIP file). Each path is iterated and resources are added to resource map. Resource map is map container of pair resource name, VFSEntry. VFSEntry is abstract class which can represent file (VFSEntryFile) or directory (VFSEntryDirectory). File can be real file on filesystem, or file inside library (If it is real file, FileHandle uses std::ifstream of that file for operations. If the file is inside library, std::ifstream use library file (with offsets inside library file) for operations). So it is with directories. When a user want to open some file i.e. "file.stci" first, the VFS entry for that resource is search. If found, then if it is real file on filesystem (i.e. /home/trigve/data/file.stci), FileHandle is created by FileManager and File object is returned. If file is inside some library, library is found, file inside that library is found, FileHandle created and File object returned.
Here is class diagram of filesystem package:

Comments