make it possible to close memmapped file before dctor

This commit is contained in:
ohyzha
2024-11-11 18:19:06 +02:00
parent b1bd78292a
commit a133641900
4 changed files with 29 additions and 2 deletions

View File

@@ -90,11 +90,20 @@ namespace OpenVulkano
}
}
MemMappedFileInternal::~MemMappedFileInternal()
void MemMappedFileInternal::Close()
{
UnmapViewOfFile(address);
CloseHandle(fileMappingHandle);
CloseHandle(fileHandle);
closed = true;
}
MemMappedFileInternal::~MemMappedFileInternal()
{
if (!closed)
{
Close();
}
}
#else
MemMappedFileInternal::MemMappedFileInternal(const char* file, MemMappedFile::FileMode fileMode)
@@ -114,10 +123,19 @@ namespace OpenVulkano
size = fileStat.st_size;
}
MemMappedFileInternal::~MemMappedFileInternal()
void MemMappedFileInternal::Close()
{
munmap(address, fileStat.st_size);
close(fileHandle);
closed = true;
}
MemMappedFileInternal::~MemMappedFileInternal()
{
if (!closed)
{
Close();
}
}
#endif