ROMFS is a read only filesystem that is built into a C byte array/blob.
A utility executable called mk_romfs used in the build takes a folder and recursively builds a bin file image of it.
The ROMFS reader is able to traverse the byte structure to read the file.
Build ROMFS
[login to view URL]
mk_romfs needs to be able to run on both Windows and Linux and generate the output C array.
Update the above code so it will run as a standalone exe. Can be 32bit or 64bit.
I think the C code generates a bin image. The TCL code generates a C byte array. Up to you how you migrate this so it is portable. Don’t want to install TCL on Windows. Provide proposed method before starting.
Read ROMFS
[login to view URL]
Convert romfs.c into a C++ class called CROMFSFileIO
The purpose of this class is to allow files to be opened and read from the pseudo file system.
Code should work as 32 and 64bit
This class will be used in Windows, Linux and ECOS.
Multiple instances of the class will be used to read files concurrently.
The instance of the class will not be used across threads.
Handle the use of / or \ in file path requested.
Example C++ header next page
Tests to Provide
Use Microsoft C++ unit test framework in Visual Studio 2019
Provide test files so as to prove these tests pass correctly
File open when it doesn’t exists
File open in root folder and read contents
File open in sub folder and read contents
File open and seek positions.
Multiple threads/ instances of the class accessing same file concurrently. Don’t share CROMFSFileIO class between threads.
File is closed in destructor, if not already closed
Sufficient test evidence to show working on Linux. No need for unit tests running on Linux.
class CROMFSFileIO
{
public:
CROMFSFileIO(void);
virtual ~CROMFSFileIO(void);
enum
{
modeRead = 0x0004,
typeText = 0x0100,
typeBinary = 0x0200
};
bool Open(const char *szFile, int nFlags);
void Close(void);
size_t Read(char *buf, size_t len);
enum
{
seekSET,
seekCUR,
seekEND
};
bool Seek(size_t offset, int origin = seekSET);
long FilePosition(void);
bool IsOpen(void);
static bool Exists(const char* szFile);
static size_t Length(const char* szFile);
};