yyc12345
e682a87d25
- rename LIBCMO_DISABLE_COPY_MOVE -> YYCC_DEL_CLS_COPY_MOVE and LIBCMO_DEFAULT_COPY_MOVE -> YYCC_DEF_CLS_COPY_MOVE. - fix Vector declaration generator. throw exception when operator[] face invalid index, instead of do fallback. - rename VTAll.hpp -> VTInternal.hpp and VYUserAll -> VTAll.hpp for easy to understand. - fix project name error in Doxygen template. - replace all LIBCMO_OS_WIN32 to YYCC_OS == YYCC_OS_WINDOWS. - fix some compile error (involving utf8 encoding) but not the final result. - use correct way to include std-image library (use <> instead of "") - finish documentation for VTUtils.hpp and VTEncoding.hpp.
54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "../VTInternal.hpp"
|
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
|
#include <Windows.h>
|
|
// disable annoy macro at the same time
|
|
#undef GetObject
|
|
#undef GetClassName
|
|
#undef LoadImage
|
|
#undef GetTempPath
|
|
#else
|
|
#include <sys/mman.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <string>
|
|
#include <filesystem>
|
|
|
|
namespace LibCmo::VxMath {
|
|
|
|
class VxMemoryMappedFile {
|
|
private:
|
|
|
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
|
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(CKSTRING u8_filepath);
|
|
VxMemoryMappedFile(const VxMemoryMappedFile&) = delete;
|
|
VxMemoryMappedFile& operator=(const VxMemoryMappedFile&) = delete;
|
|
~VxMemoryMappedFile(void);
|
|
|
|
void* GetBase(void) { return this->m_pMemoryMappedFileBase; }
|
|
CKDWORD GetFileSize(void) { return static_cast<CKDWORD>(this->m_cbFile); }
|
|
bool IsValid(void) { return this->m_bIsValid; }
|
|
};
|
|
|
|
}
|