diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index a8eed502..a14957d8 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -94,10 +94,13 @@ class FileSystemTemplate: public FileSystem { }; FileStore m_fs; + void(*m_freeBuffer)(uint8_t*) = nullptr; public: FileSystemTemplate() = default; + FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(uint8_t*) = [] (uint8_t *buff) { delete buff; }); + FileSystemTemplate(FileStore fs); ~FileSystemTemplate(); @@ -167,8 +170,17 @@ FileSystemTemplate::FileSystemTemplate(FileStore fs) { m_fs = fs; } +template +FileSystemTemplate::FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(uint8_t*)): + m_fs(buffer, bufferSize), + m_freeBuffer(freeBuffer) { +} + template FileSystemTemplate::~FileSystemTemplate() { + if (m_freeBuffer && m_fs.buff()) { + m_freeBuffer(m_fs.buff()); + } } template