Memory mapped krbundles fixed for WIN32
This commit is contained in:
@@ -279,8 +279,7 @@ void KRDataBlock::copy(void *dest) {
|
|||||||
void KRDataBlock::copy(void *dest, int start, int count) {
|
void KRDataBlock::copy(void *dest, int start, int count) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
if (m_lockCount == 0 && m_hPackFile != INVALID_HANDLE_VALUE) {
|
if (m_lockCount == 0 && m_hPackFile != INVALID_HANDLE_VALUE) {
|
||||||
// Optimization: If we haven't mmap'ed or malloced the data already, pread() it directly from the file into the buffer
|
// Optimization: If we haven't mmap'ed or malloced the data already, ReadFile() it directly from the file into the buffer
|
||||||
|
|
||||||
LARGE_INTEGER distance;
|
LARGE_INTEGER distance;
|
||||||
distance.QuadPart = start + m_data_offset;
|
distance.QuadPart = start + m_data_offset;
|
||||||
bool success = SetFilePointerEx(m_hPackFile, distance, NULL, FILE_BEGIN);
|
bool success = SetFilePointerEx(m_hPackFile, distance, NULL, FILE_BEGIN);
|
||||||
@@ -468,13 +467,13 @@ void KRDataBlock::lock()
|
|||||||
size_t alignment_offset = m_data_offset & (KRContext::KRENGINE_SYS_ALLOCATION_GRANULARITY - 1);
|
size_t alignment_offset = m_data_offset & (KRContext::KRENGINE_SYS_ALLOCATION_GRANULARITY - 1);
|
||||||
assert(m_mmapData == NULL);
|
assert(m_mmapData == NULL);
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
m_hFileMapping = CreateFileMappingFromApp(m_hPackFile, NULL, m_bReadOnly ? PAGE_READONLY : PAGE_READWRITE, m_data_size, NULL);
|
m_hFileMapping = CreateFileMappingFromApp(m_hPackFile, NULL, m_bReadOnly ? PAGE_READONLY : PAGE_READWRITE, m_fileOwnerDataBlock->getSize(), NULL);
|
||||||
if(m_hFileMapping == NULL) {
|
if(m_hFileMapping == NULL) {
|
||||||
ReportWindowsLastError("CreateFileMappingFromApp");
|
ReportWindowsLastError("CreateFileMappingFromApp");
|
||||||
}
|
}
|
||||||
assert(m_hFileMapping != NULL);
|
assert(m_hFileMapping != NULL);
|
||||||
|
|
||||||
m_mmapData = MapViewOfFileFromApp(m_hFileMapping, m_bReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE, m_data_offset - alignment_offset, m_data_size + alignment_offset);
|
m_mmapData = MapViewOfFileFromApp(m_hFileMapping, m_bReadOnly ? FILE_MAP_READ | FILE_MAP_COPY : FILE_MAP_WRITE, m_data_offset - alignment_offset, m_data_size + alignment_offset);
|
||||||
if(m_mmapData == NULL) {
|
if(m_mmapData == NULL) {
|
||||||
ReportWindowsLastError("MapViewOfFileFromApp");
|
ReportWindowsLastError("MapViewOfFileFromApp");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user