summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbintf.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-29 07:35:57 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-29 07:35:57 +0000
commit93d627691da3569dd0582cc5ebaf425f4e8087d2 (patch)
tree59fb5bf01c2fd8eb435d0dbea36bd27522a456bb /plugins/Db3x_mmap/src/dbintf.cpp
parent6a47964cab12d66c30a106b77a59263e615c1213 (diff)
read-only mode for databases
git-svn-id: http://svn.miranda-ng.org/main/trunk@1237 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbintf.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp
index 84ddc64468..3decb9bc4b 100644
--- a/plugins/Db3x_mmap/src/dbintf.cpp
+++ b/plugins/Db3x_mmap/src/dbintf.cpp
@@ -52,7 +52,8 @@ static int OfsCompare(const ModuleName *mn1, const ModuleName *mn2 )
CDb3Base::CDb3Base(const TCHAR* tszFileName) :
m_hDbFile(INVALID_HANDLE_VALUE),
- m_safetyMode(TRUE),
+ m_safetyMode(true),
+ m_bReadOnly(true),
m_lSettings(100, stringCompare),
m_lContacts(50, LIST<DBCachedContactValueList>::FTSortFunc(HandleKeySort)),
m_lGlobalSettings(50, compareGlobals),
@@ -98,9 +99,11 @@ CDb3Base::~CDb3Base()
CloseHandle(m_hMap);
// update profile last modified time
- DWORD bytesWritten;
- SetFilePointer(m_hDbFile, 0, NULL, FILE_BEGIN);
- WriteFile(m_hDbFile, &dbSignature, 1, &bytesWritten, NULL);
+ if (!m_bReadOnly) {
+ DWORD bytesWritten;
+ SetFilePointer(m_hDbFile, 0, NULL, FILE_BEGIN);
+ WriteFile(m_hDbFile, &dbSignature, 1, &bytesWritten, NULL);
+ }
CloseHandle(m_hDbFile);
DeleteCriticalSection(&m_csDbAccess);
@@ -126,6 +129,8 @@ int CDb3Base::Load(bool bSkipInit)
if (InitCache()) return 1;
if (InitModuleNames()) return 1;
+ m_bReadOnly = false;
+
hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
@@ -146,7 +151,7 @@ int CDb3Base::Create()
STDMETHODIMP_(void) CDb3Base::SetCacheSafetyMode(BOOL bIsSet)
{
{ mir_cslock lck(m_csDbAccess);
- m_safetyMode = bIsSet;
+ m_safetyMode = bIsSet != 0;
}
DBFlush(1);
}