From d0580040b51b6c4803e0f61863bd985c382370e9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 26 Jan 2014 15:22:35 +0000 Subject: fix for creating backup files in dbchecker git-svn-id: http://svn.miranda-ng.org/main/trunk@7906 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/src/dbcache.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'plugins/Db3x_mmap/src/dbcache.cpp') diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp index 76126f7885..f047af0a1b 100644 --- a/plugins/Db3x_mmap/src/dbcache.cpp +++ b/plugins/Db3x_mmap/src/dbcache.cpp @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CDb3Base::Map() { - m_hMap = CreateFileMapping(m_hDbFile, NULL, PAGE_READWRITE, 0, m_dwFileSize, NULL); + m_hMap = CreateFileMapping(m_hDbFile, NULL, (m_bReadOnly) ? PAGE_WRITECOPY : PAGE_READWRITE, 0, m_dwFileSize, NULL); if (m_hMap) { - m_pDbCache = (PBYTE)MapViewOfFile(m_hMap, FILE_MAP_ALL_ACCESS/*FILE_MAP_WRITE*/, 0, 0 ,0); + m_pDbCache = (PBYTE)MapViewOfFile(m_hMap, (m_bReadOnly) ? FILE_MAP_COPY : FILE_MAP_ALL_ACCESS, 0, 0, 0); if (!m_pDbCache) DatabaseCorruption( _T("%s (MapViewOfFile failed. Code: %d)")); } @@ -156,9 +156,11 @@ int CDb3Base::InitCache(void) m_dwFileSize = GetFileSize(m_hDbFile, NULL); // Align to chunk - DWORD x = m_dwFileSize % m_ChunkSize; - if (x) - m_dwFileSize += m_ChunkSize - x; + if (!m_bReadOnly) { + DWORD x = m_dwFileSize % m_ChunkSize; + if (x) + m_dwFileSize += m_ChunkSize - x; + } Map(); -- cgit v1.2.3