From d362ec98ec0db2039944da31729ad8efcd72834a Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 02 一月 2025 14:19:36 +0800
Subject: [PATCH] 1.20250102合并;

---
 SourceCode/Bond/BondEq/ToolUnits.cpp |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/BondEq/ToolUnits.cpp b/SourceCode/Bond/BondEq/ToolUnits.cpp
index f9022f8..ad4d92e 100644
--- a/SourceCode/Bond/BondEq/ToolUnits.cpp
+++ b/SourceCode/Bond/BondEq/ToolUnits.cpp
@@ -152,7 +152,7 @@
 
 int CToolUnits::toInt32(const char* pBuffer)
 {
-	return (pBuffer[0] & 0xff) | (pBuffer[1] & 0xff) << 8 | (pBuffer[2] & 0xff) << 16 | (pBuffer[3] & 0xff) << 24;
+	return (pBuffer[0] & 0xff) | ((pBuffer[1] & 0xff) << 8) | ((pBuffer[2] & 0xff) << 16) | ((pBuffer[3] & 0xff) << 24);
 }
 
 int CToolUnits::toInt16(const char* pBuffer)
@@ -247,3 +247,57 @@
 	strText.Format(_T("%.03f"), value);
 	pWnd->SetDlgItemText(nCtrlId, strText);
 }
+
+std::vector<CString> CToolUnits::GetFileNamesInDirectory(const CString& strFolderPath, const CString& strExtension)
+{
+	std::vector<CString> fileNames;
+
+	// 确保目录路径最后有反斜杠
+	CString strSearchPath = strFolderPath;
+	if (strSearchPath[strSearchPath.GetLength() - 1] != '\\') {
+		strSearchPath += '\\';
+	}
+
+	CString finalExtension = strExtension;
+	if (finalExtension.Find('.') == -1) {
+		finalExtension = '.' + finalExtension;
+	}
+	strSearchPath += "*" + finalExtension;
+
+	std::unique_ptr<CFileFind> finder = std::make_unique<CFileFind>();
+	BOOL bWorking = finder->FindFile(strSearchPath);
+
+	// 遍历文件夹
+	while (bWorking) {
+		bWorking = finder->FindNextFile();
+		if (!finder->IsDirectory()) {
+			CString fileName = finder->GetFileName();
+			int dotPos = fileName.ReverseFind('.');
+			if (dotPos != -1) {
+				fileName = fileName.Left(dotPos);
+			}
+			fileNames.push_back(fileName);
+		}
+	}
+
+	return fileNames;
+}
+
+std::string CToolUnits::getRecipePath()
+{
+	return getCurrentExePath() + "\\Recipe";
+}
+
+std::string CToolUnits::getCurrentTimeString()
+{
+	struct tm ltm;
+	time_t now = time(0);
+	localtime_s(&ltm, &now);  // 使用安全的 localtime_s 函数
+
+	char buffer[256];
+	sprintf_s(buffer, sizeof(buffer), "%04d-%02d-%02d %02d:%02d:%02d",
+		ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday,
+		ltm.tm_hour, ltm.tm_min, ltm.tm_sec);
+
+	return std::string(buffer);
+}
\ No newline at end of file

--
Gitblit v1.9.3