Skip to content

Commit 664b053

Browse files
committed
fixed:Failed to insert the absolute path into the database
1 parent 9e66ad5 commit 664b053

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

XEngine_Source/StorageModule_Database/Database_File/Database_File.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,32 @@ BOOL CDatabase_File::Database_File_FileInsert(XSTORAGECORE_DBFILE *pSt_DBManage,
140140
BaseLib_OperatorMemory_Free((void***)&ppSt_ListFile, nListCount);
141141
return TRUE;
142142
}
143-
BaseLib_OperatorMemory_Free((void***)&ppSt_ListFile, nListCount);
144-
145-
TCHAR tszSQLStatement[2048];
146-
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
143+
TCHAR tszSQLQuery[2048];
144+
memset(tszSQLQuery, '\0', sizeof(tszSQLQuery));
147145

148146
if (bRewrite)
149147
{
150148
Database_File_FileDelete(pSt_DBManage->tszBuckKey, pSt_DBManage->st_ProtocolFile.tszFilePath, pSt_DBManage->st_ProtocolFile.tszFileName);
151149
}
152-
Database_Help_Insert(tszSQLStatement, pSt_DBManage);
153-
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement))
150+
Database_Help_Insert(tszSQLQuery, pSt_DBManage);
151+
152+
int nType = 0;
153+
std::string m_StrSQL = tszSQLQuery;
154+
BaseLib_OperatorString_GetPath(pSt_DBManage->st_ProtocolFile.tszFilePath, &nType);
155+
if (1 == nType)
156+
{
157+
std::string m_StrSource = "\\";
158+
std::string m_StrDest = "\\\\";
159+
160+
size_t nStartPos = 0;
161+
while ((nStartPos = m_StrSQL.find(m_StrSource, nStartPos)) != std::string::npos)
162+
{
163+
m_StrSQL.replace(nStartPos, m_StrSource.length(), m_StrDest);
164+
nStartPos += m_StrDest.length();
165+
}
166+
}
167+
168+
if (!DataBase_MySQL_Execute(xhDBSQL, m_StrSQL.c_str()))
154169
{
155170
Database_IsErrorOccur = TRUE;
156171
Database_dwErrorCode = DataBase_GetLastError();

XEngine_Source/StorageModule_Database/pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <list>
2727
#include <memory>
2828
#include <thread>
29+
#include <algorithm>
2930
#include <inttypes.h>
3031
#include <shared_mutex>
3132
#include <unordered_map>

0 commit comments

Comments
 (0)