[ox/fs] Give FileSystem ability to cleanup FS buffer
This commit is contained in:
parent
dd008c3a08
commit
e927c51b61
12
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
12
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@ -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<FileStore, Directory>::FileSystemTemplate(FileStore fs) {
|
||||
m_fs = fs;
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
FileSystemTemplate<FileStore, Directory>::FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(uint8_t*)):
|
||||
m_fs(buffer, bufferSize),
|
||||
m_freeBuffer(freeBuffer) {
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
FileSystemTemplate<FileStore, Directory>::~FileSystemTemplate() {
|
||||
if (m_freeBuffer && m_fs.buff()) {
|
||||
m_freeBuffer(m_fs.buff());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename FileStore, typename Directory>
|
||||
|
Loading…
Reference in New Issue
Block a user