refactor: 水池截面中转文件改用 CoreTools::getTempFilePath
删除 Pool3dCmd/PoolSectionTemp.h,JMDBDlg、JMSJDlg、HZQTDlg 共 7 处
改为 CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), 目录)。
同时修 getTempFilePath 自身的问题:
- 传了有效父目录时 sParentPath 没有赋值,会拼出 "\JMSJ_xxx.sat"
- 父目录为空时仍对 pszParentPath 调 _taccess,参数可能是 NULL
- return sPath(); 语法错误
- objId 用 %lu 格式化 Adesk::ULongPtr,64 位下会截断,改 %I64u
temp-file-naming.md 同步改为介绍这个通用函数。
This commit is contained in:
1 parent
8caea9e6bd
commit
4e658a8ae9
7 files changed
+71
-30
No files matched your search
@@ -4,7 +4,7 @@
|
||||
#include "JMSJDlg.h"
|
||||
#include "GLTKDlg.h"
|
||||
#include "KTSetting.h"
|
||||
#include "PoolSectionTemp.h"
|
||||
#include "CoreTools.h"
|
||||
|
||||
DLLIMPEXP CString IDCreate();
|
||||
|
||||
@@ -271,7 +271,7 @@ void CHZQTDlg::OnBnClickedCheck1()
|
||||
CString sScr;
|
||||
if (dlg.GetCrossSectionScr(sScr))
|
||||
{
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::GetSysDir());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::GetSysDir());
|
||||
|
||||
CStdioFile file;
|
||||
if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite ))
|
||||
@@ -393,7 +393,7 @@ void CHZQTDlg::SetFromWall(AcDbObjectId& id)
|
||||
m_bUserDefSec = TRUE;
|
||||
pWall->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_SECTIONSCR,m_sRegScr);
|
||||
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::GetSysDir());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::GetSysDir());
|
||||
|
||||
CStdioFile file;
|
||||
if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite ))
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "JMDBDlg.h"
|
||||
#include "GLTKDlg.h"
|
||||
#include "CoreTools.h"
|
||||
#include "PoolSectionTemp.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC(CJMDBDlg, CDialog)
|
||||
|
||||
@@ -88,7 +87,7 @@ void CJMDBDlg::OnBnClickedButton1()
|
||||
CString sScr;
|
||||
if (dlg.GetCrossSectionScr(sScr))
|
||||
{
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::GetSysDir());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::GetSysDir());
|
||||
|
||||
CStdioFile file;
|
||||
if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite ))
|
||||
@@ -172,7 +171,7 @@ void CJMDBDlg::OnBnClickedButton2()
|
||||
|
||||
if (m_pSectionReg != NULL && bSuccess)
|
||||
{
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::getSystemTemporaryFolder());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::getSystemTemporaryFolder());
|
||||
|
||||
CString sRegionScrp = _T("");
|
||||
CString sLine;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "JMSJDlg.h"
|
||||
#include "CoreTools.h"
|
||||
#include "PoolSectionTemp.h"
|
||||
#include "JUXCDlg.h"
|
||||
#include "GLTKDlg.h"
|
||||
#include "BYCDlg.h"
|
||||
@@ -79,7 +78,7 @@ BOOL CJMSJDlg::OnInitDialog()
|
||||
void CJMSJDlg::ShowLastSection()
|
||||
{
|
||||
//1.截面
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::getSystemTemporaryFolder());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::getSystemTemporaryFolder());
|
||||
|
||||
AcDbVoidPtrArray arBodyPtrs;
|
||||
if ( Acad::eOk == AcDbBody::acisIn(sFullPath,arBodyPtrs) )
|
||||
@@ -138,7 +137,7 @@ void CJMSJDlg::OnBnClickedBtaddtodb()
|
||||
UpdateData(TRUE);
|
||||
|
||||
if (!m_curSection.pReg) return;
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::getSystemTemporaryFolder());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::getSystemTemporaryFolder());
|
||||
|
||||
CString sRegionScrp = _T("");
|
||||
CString sLine;
|
||||
@@ -424,7 +423,7 @@ void CJMSJDlg::OnBnClickedBtselfromdb()
|
||||
CString sScr,sScrT;
|
||||
if (dlg.GetCrossSectionScr(sScr))
|
||||
{
|
||||
CString sFullPath = GetPoolSectionSatPath(FilePath::getSystemTemporaryFolder());
|
||||
CString sFullPath = CoreTools::getTempFilePath(_T("JMSJ_"), _T(".sat"), FilePath::getSystemTemporaryFolder());
|
||||
|
||||
CStdioFile file;
|
||||
if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite ))
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// 水池截面 SAT 中转文件路径。
|
||||
// 同一个 CAD 进程内所有调用点返回同一路径;不同进程用 PID 区分,
|
||||
// 避免两个实例同时写同一个 JMSJ.sat 互相覆盖。
|
||||
inline CString GetPoolSectionSatPath(LPCTSTR lpszDir)
|
||||
{
|
||||
CString sPath;
|
||||
sPath.Format(_T("%s\\JMSJ_%lu.sat"), lpszDir, (unsigned long)::GetCurrentProcessId());
|
||||
return sPath;
|
||||
}
|
||||
Reference in new issue
Block a user