diff options
Diffstat (limited to 'src/system')
-rw-r--r-- | src/system/MemoryMappedFile.cpp | 36 | ||||
-rw-r--r-- | src/system/Utf8.cpp | 11 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/system/MemoryMappedFile.cpp b/src/system/MemoryMappedFile.cpp new file mode 100644 index 0000000..54f15c1 --- /dev/null +++ b/src/system/MemoryMappedFile.cpp @@ -0,0 +1,36 @@ +#include "../../include/mglpp/system/MemoryMappedFile.hpp" + +namespace mgl { + MemoryMappedFile::MemoryMappedFile() { + memory_mapped_file.data = nullptr; + memory_mapped_file.size = 0; + memory_mapped_file.fd = -1; + } + + MemoryMappedFile::~MemoryMappedFile() { + mgl_mapped_file_unload(&memory_mapped_file); + } + + bool MemoryMappedFile::load(const char *filepath, LoadOptions load_options) { + if(memory_mapped_file.fd != -1) + return false; + + mgl_memory_mapped_file_load_options mapped_file_load_options = { + load_options.readable, + load_options.writable + }; + return mgl_mapped_file_load(filepath, &memory_mapped_file, &mapped_file_load_options) == 0; + } + + void* MemoryMappedFile::data() { + return memory_mapped_file.data; + } + + size_t MemoryMappedFile::size() { + return memory_mapped_file.size; + } + + const mgl_memory_mapped_file* MemoryMappedFile::internal_mapped_file() const { + return &memory_mapped_file; + } +}
\ No newline at end of file diff --git a/src/system/Utf8.cpp b/src/system/Utf8.cpp new file mode 100644 index 0000000..be9b2af --- /dev/null +++ b/src/system/Utf8.cpp @@ -0,0 +1,11 @@ +#include "../../include/mglpp/system/Utf8.hpp" + +extern "C" { +#include <mgl/system/utf8.h> +} + +namespace mgl { + bool utf8_decode(const unsigned char *str, size_t size, uint32_t *decoded_codepoint, size_t *codepoint_length) { + return mgl_utf8_decode(str, size, decoded_codepoint, codepoint_length); + } +}
\ No newline at end of file |