#pragma once #include "../VTAll.hpp" #if defined(LIBCMO_OS_WIN32) #include // disable annoy macro at the same time #undef GetObject #undef GetClassName #undef LoadImage #undef GetTempPath #else #include #include #include #include #include #endif #include #include namespace LibCmo::VxMath { class VxMemoryMappedFile { private: #if defined(LIBCMO_OS_WIN32) HANDLE m_hFile; DWORD m_dwFileSizeLow, m_dwFileSizeHigh; HANDLE m_hFileMapping; LPVOID m_hFileMapView; #else int m_hFile; off_t m_offFileSize; void* m_pFileAddr; #endif std::filesystem::path m_szFilePath; void* m_pMemoryMappedFileBase; size_t m_cbFile; bool m_bIsValid; public: VxMemoryMappedFile(const char* u8_filepath); VxMemoryMappedFile(const VxMemoryMappedFile&) = delete; VxMemoryMappedFile& operator=(const VxMemoryMappedFile&) = delete; ~VxMemoryMappedFile(void); void* GetBase(void) { return this->m_pMemoryMappedFileBase; } CK2::CKDWORD GetFileSize(void) { return static_cast(this->m_cbFile); } bool IsValid(void) { return this->m_bIsValid; } }; }