Minecraft Community Edition 0.1.0
Loading...
Searching...
No Matches
mce::VirtualFileSystem Class Reference

VirtualFileSystem manages a collection of files referenced by tags. More...

#include <VirtualFileSystem.hpp>

Classes

union  Version
 Version information for the virtual file system format. More...
struct  Config
 Configuration for how the VirtualFileSystem should operate. More...

Public Types

enum  FileBinaryType : unsigned char { NONE = 0 , ASSETS_FILE = 1 , SOURCE_FILE = 2 , WORLD_FILE = 4 }
 Types of virtual file collections that can be stored in a VFS file. More...

Public Member Functions

ConfiggetConfig ()
 Access the runtime configuration.
bool getFile (const eastl::string_view &fileTag, eastl::vector< char > &bytes)
 Retrieve a file's bytes identified by its tag.
bool buildJSONMappingFile (const std::string &fileInName, const std::string &fileOutName)
 Build a binary VFS file from a JSON mapping.
bool loadFile (const std::string &fileName)
 Load the virtual file system from a file.

Detailed Description

VirtualFileSystem manages a collection of files referenced by tags.

The virtual file system can be built from a JSON mapping (debug mode) or from a binary VFS file (release). It supports loading file contents either via stream input or by keeping the virtual file contents in memory.

Member Enumeration Documentation

◆ FileBinaryType

Types of virtual file collections that can be stored in a VFS file.

Enumerator
NONE 

No file type specified.

ASSETS_FILE 

Assets bundle.

SOURCE_FILE 

Source files bundle.

WORLD_FILE 

World data bundle.

Member Function Documentation

◆ buildJSONMappingFile()

bool mce::VirtualFileSystem::buildJSONMappingFile ( const std::string & fileInName,
const std::string & fileOutName )

Build a binary VFS file from a JSON mapping.

Parameters
fileInNamePath to the input JSON mapping file.
fileOutNamePath where the resulting binary VFS should be written.
Returns
True if the output file was successfully created.

◆ getConfig()

VirtualFileSystem::Config & mce::VirtualFileSystem::getConfig ( )

Access the runtime configuration.

Returns
Reference to the VFS configuration.

◆ getFile()

bool mce::VirtualFileSystem::getFile ( const eastl::string_view & fileTag,
eastl::vector< char > & bytes )

Retrieve a file's bytes identified by its tag.

Parameters
fileTagTag identifying the file in the VFS.
bytesOutput vector which will be filled with file data.
Returns
True if the file was found and bytes were successfully loaded.

◆ loadFile()

bool mce::VirtualFileSystem::loadFile ( const std::string & fileName)

Load the virtual file system from a file.

Parameters
fileNameBase file name (without extension) to load.
Returns
True if the VFS data was successfully loaded.

The documentation for this class was generated from the following files: