diff options
author | George Hazan <george.hazan@gmail.com> | 2024-03-09 11:20:15 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-03-09 11:20:15 +0300 |
commit | 36097f66df7e46eefcce1f424d6b13cb90b8f66c (patch) | |
tree | 8dc83ae9dfa3e1d4c7418bf0bb151f8178577707 /plugins/Import | |
parent | b81c076def120b78c7e80e533a8fe1b8248852bd (diff) |
Import: JSON export compatibility with old Msg_Export code
Diffstat (limited to 'plugins/Import')
-rw-r--r-- | plugins/Import/src/textjson.cpp | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index feb826ce8c..d5818357e2 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -29,15 +29,6 @@ static int json_makeDatabase(const wchar_t*) return 1;
}
-static void replaceAll(std::string &str, const char *from, const char *to)
-{
- size_t start_pos = 0;
- while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
- str.replace(start_pos, strlen(from), to);
- start_pos += strlen(to);
- }
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// JSON text driver, read-only
@@ -258,7 +249,7 @@ public: if (m_out == INVALID_HANDLE_VALUE)
return EGROKPRF_CANTREAD;
- SetFilePointer(m_out, -4, 0, FILE_END);
+ SetFilePointer(m_out, -3, 0, FILE_END);
return EGROKPRF_NOERROR;
}
@@ -324,18 +315,17 @@ public: DWORD dwWritten;
auto szOut = pRoot.write_formatted();
- replaceAll(szOut, "\n", "\r\n");
WriteFile(m_out, szOut.c_str(), (DWORD)szOut.size(), &dwWritten, 0);
m_bAppend = false;
- SetFilePointer(m_out, -4, 0, FILE_END);
+ SetFilePointer(m_out, -3, 0, FILE_END);
return 0;
}
STDMETHODIMP_(int) ExportEvent(const DB::EventInfo &dbei) override
{
if (m_bAppend) {
- SetFilePointer(m_out, -4, 0, FILE_END);
+ SetFilePointer(m_out, -3, 0, FILE_END);
DWORD dwWritten;
WriteFile(m_out, ",", 1, &dwWritten, 0);
@@ -372,12 +362,10 @@ public: if (dbei.szReplyId)
pRoot.push_back(JSONNode("reply_id", dbei.szReplyId));
- auto szOut = pRoot.write_formatted();
- replaceAll(szOut, "\n", "\r\n");
-
DWORD dwWritten;
+ auto szOut = pRoot.write_formatted();
WriteFile(m_out, szOut.c_str(), (DWORD)szOut.size(), &dwWritten, 0);
- WriteFile(m_out, "\r\n]}", 4, &dwWritten, 0);
+ WriteFile(m_out, "\n]}", 3, &dwWritten, 0);
m_bAppend = true;
return 0;
}
|