summaryrefslogtreecommitdiff
path: root/plugins/Msg_Export/src/utils.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2017-02-06 00:06:34 +0100
committerRobert Pösel <robyer@seznam.cz>2017-02-06 00:09:07 +0100
commitc87d46c2af765e61b64dfb0859760b46cb432a59 (patch)
treed12fd6f7a35565273eda38150f8d79a7ea5ccce4 /plugins/Msg_Export/src/utils.cpp
parent98518865f72ccb25e3f5a061508aff98ffb59493 (diff)
Msg_Export: Fix exporting unicode messages, make it even faster (addresses #609)
Previously code worked with opening file and loading BOM at writing each event. When we stopped closing/opening file at each event it couldn't read BOM anymore, so it wrote messages in wrong codepage. This is not fixed by parameter defining we are just appending the file, so it doesn't need to determing BOM or even check file size. Thanks to this exporting is now about 70% faster than the initial optimization commit (in sum 13.5x faster than before).
Diffstat (limited to 'plugins/Msg_Export/src/utils.cpp')
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index f3296752ed..d56a396bfb 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -879,7 +879,7 @@ void DisplayErrorDialog(const wchar_t *pszError, tstring& sFilePath, DBEVENTINFO
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVENTINFO &dbei)
+bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVENTINFO &dbei, bool bAppendOnly)
{
tstring sLocalUser;
tstring sRemoteUser;
@@ -901,7 +901,10 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVE
wchar_t szTemp[500];
bool bWriteUTF8Format = false;
- {
+ if (bAppendOnly) {
+ bWriteUTF8Format = bUseUtf8InNewFiles;
+ }
+ else {
DWORD dwHighSize = 0;
DWORD dwLowSize = GetFileSize(hFile, &dwHighSize);
@@ -1232,7 +1235,7 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
}
// Write the event
- bExportEvent((MCONTACT)hContact, (MEVENT)hDbEvent, hFile, sFilePath);
+ bExportEvent((MCONTACT)hContact, (MEVENT)hDbEvent, hFile, sFilePath, false);
// Close the file
CloseHandle(hFile);
@@ -1240,7 +1243,7 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent)
return 0;
}
-bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath)
+bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFilePath, bool bAppendOnly)
{
DBEVENTINFO dbei = {};
int nSize = db_event_getBlobSize(hDbEvent);
@@ -1256,7 +1259,7 @@ bool bExportEvent(MCONTACT hContact, MEVENT hDbEvent, HANDLE hFile, tstring sFil
bool result = true;
if (!db_event_get(hDbEvent, &dbei)) {
// Write the event
- result = ExportDBEventInfo(hContact, hFile, sFilePath, dbei);
+ result = ExportDBEventInfo(hContact, hFile, sFilePath, dbei, bAppendOnly);
}
if (dbei.pBlob)
free(dbei.pBlob);