refactor: 水池截面中转文件改用 CoreTools::getTempFilePath #33

Merged
gjm merged 3 commits from company-desktop-computer/fix/pool-section-sat-name AGit into main 2026-10-22 10:09:15 +08:00
6 changed files with 49 additions and 19 deletions
Showing only changes of commit e3fff2ad66 - Show all commits

No files matched your search

@@ -129,11 +129,15 @@ bool FormatScriptFromSection(CString& sScr,STSection* pSection)
if (file.Open(sFullPath,CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt,(UINT)dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
sRegionScrp = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
sRegionScrp = CString(pszTxt, (int)nRead);
delete [] pszTxt;
file.Close();
@@ -2900,7 +2904,11 @@ bool AcDbX3dSolid::CreateFromSat(LPCTSTR pszSatFile,double dUnitScale)
//上一级目录
int nPos = sFullPath.ReverseFind(_T('\\'));
CString sPath = sFullPath.Mid(0,nPos + 1);
sFullPath = sPath + _T("temp\\temp.sat");
// 每次用唯一文件名:多个 CAD 实例同时从 SAT 重建时不会互相覆盖
static LONG s_nSatSeq = 0;
sFullPath.Format(_T("%stemp\\temp_%lu_%ld.sat"),(LPCTSTR)sPath
,(unsigned long)::GetCurrentProcessId(),(long)::InterlockedIncrement(&s_nSatSeq));
CFile file;
if (file.Open(sFullPath,CFile::modeCreate|CFile::modeWrite))
@@ -2912,6 +2920,8 @@ bool AcDbX3dSolid::CreateFromSat(LPCTSTR pszSatFile,double dUnitScale)
AcDbVoidPtrArray arPtr;
AcDbBody::acisIn(sFullPath,arPtr);
::DeleteFile(sFullPath);
//按照体积从大到小排序
Sort3dSolidByVol(arPtr);
@@ -580,11 +580,15 @@ CString GetSectionScr(AcDbRegion* pReg)
if (file.Open(sFullPath,CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt,(UINT)dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
sRegionScrp = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
sRegionScrp = CString(pszTxt, (int)nRead);
delete [] pszTxt;
file.Close();
+7 -3
View File
@@ -951,11 +951,15 @@ void CDGJMDlg::OnBnClickedBtaddtodb()
if (file.Open(sFullPath,CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt,dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
sRegionScrp = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
sRegionScrp = CString(pszTxt, (int)nRead);
delete [] pszTxt;
file.Close();
@@ -9418,11 +9418,15 @@ bool FormatScriptFromSection(CString& sScr,STSection* pSection)
if (file.Open(sFullPath,CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt,dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
sRegionScrp = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
sRegionScrp = CString(pszTxt, (int)nRead);
delete [] pszTxt;
file.Close();
+7 -3
View File
@@ -186,11 +186,15 @@ void CJMDBDlg::OnBnClickedButton2()
if (file.Open(sFullPath, CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt, dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
m_sRegScr = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
m_sRegScr = CString(pszTxt, (int)nRead);
DELETE_ARR_(pszTxt);
file.Close();
+7 -3
View File
@@ -152,11 +152,15 @@ void CJMSJDlg::OnBnClickedBtaddtodb()
if (file.Open(sFullPath, CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt, dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
sRegionScrp = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
sRegionScrp = CString(pszTxt, (int)nRead);
DELETE_ARR_(pszTxt);
file.Close();