mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-07-23 05:23:59 +00:00
Port XEX patcher from Unleashed Recompiled. (#4)
* Port XEX patcher from Unleashed Recompiled. * Fix compilation error on Linux.
This commit is contained in:
32
XenonUtils/memory_mapped_file.h
Normal file
32
XenonUtils/memory_mapped_file.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <Windows.h>
|
||||
#else
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
struct MemoryMappedFile {
|
||||
#if defined(_WIN32)
|
||||
HANDLE fileHandle = nullptr;
|
||||
HANDLE fileMappingHandle = nullptr;
|
||||
LPVOID fileView = nullptr;
|
||||
LARGE_INTEGER fileSize = {};
|
||||
#else
|
||||
int fileHandle = -1;
|
||||
void *fileView = MAP_FAILED;
|
||||
off_t fileSize = 0;
|
||||
#endif
|
||||
|
||||
MemoryMappedFile();
|
||||
MemoryMappedFile(const std::filesystem::path &path);
|
||||
MemoryMappedFile(MemoryMappedFile &&other);
|
||||
~MemoryMappedFile();
|
||||
bool open(const std::filesystem::path &path);
|
||||
void close();
|
||||
bool isOpen() const;
|
||||
uint8_t *data() const;
|
||||
size_t size() const;
|
||||
};
|
Reference in New Issue
Block a user