Skip to content

Commit

Permalink
fixup! Refactor project to standardize file handling with std::filesy…
Browse files Browse the repository at this point in the history
…stem.
  • Loading branch information
stevewgr committed Nov 19, 2024
1 parent 1eef777 commit 57bf029
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/server/LoginServer/DBProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,14 @@ BOOL CDBProcess::InsertVersion(short sVersion, const fs::path & fsFile, const fs
short sHistoryVersion) {
BOOL retvalue = TRUE;

// convert narrow to wide
std::wstring szTableName(m_pMain->m_TableName, m_pMain->m_TableName + strlen(m_pMain->m_TableName));

wchar_t szSQL[1024]{};
swprintf_s(
szSQL, L"INSERT INTO %s (sVersion, strFile, strPatchFileName, sHistoryVersion) VALUES (%hd, N'%s', '%s', %hd)",
szTableName.c_str(), sVersion, fsFile.wstring().c_str(), fsPatchFileName.wstring().c_str(), sHistoryVersion);
std::string szSql = std::format(
"INSERT INTO {:s} (sVersion, strFile, strPatchFileName, sHistoryVersion) VALUES ({:d}, '{:s}', '{:s}', {:d})",
m_pMain->m_TableName, sVersion, fsFile, fsPatchFileName, sHistoryVersion);

SQLHSTMT hStmt = NULL;
SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt);
if (rc == SQL_SUCCESS) {
rc = SQLExecDirectW(hStmt, szSQL, SQL_NTS);
rc = SQLExecDirect(hStmt, (SQLCHAR *)szSql.c_str(), SQL_NTS);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
DisplayErrorMsg(hStmt);
retvalue = FALSE;
Expand Down

0 comments on commit 57bf029

Please sign in to comment.