PaulStoffregen
Well-known member
please make a constructive suggestion.
You should add a length variable to your MemFile class. For the non-standard constructor (create with an array, not part of the FS class) set the length to the array size. For the standard constructor (inherited from FS.h) set it to zero, so the file starts with no data.
In most of the functions, use the length instead of "sz". In write() update the length, but of course still use "sz" so you don't allow writing beyond the buffer.
File class comes with a well documented API. A more faithful implementation of the API requires 4 more bytes to store the data length, and a small amount of extra code. Not difficult. Not needed for the usage cases you have envisioned, but when you publish a library using a well known API, odds are strong other people will use it according that API.