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
@@ -6189,3 +6189,45 @@ extern "C"
|
||||
return pRegAll;
|
||||
}
|
||||
}
|
||||
|
||||
CString CoreTools::getTempFilePath(LPCTSTR pszFileMainName
|
||||
, LPCTSTR pszFileSuffix
|
||||
, LPCTSTR pszParentPath
|
||||
, const bool & bUsePID
|
||||
, const AcDbObjectId & objId)
|
||||
{
|
||||
CString sPath(_T("")), sTemp;
|
||||
|
||||
if (!pszFileMainName || !pszFileSuffix)
|
||||
return sPath;
|
||||
|
||||
CString sParentPath(_T(""));
|
||||
if (pszParentPath == NULL || _taccess(pszParentPath, 0x00) != 0x00)
|
||||
sParentPath = FilePath::getSystemTemporaryFolder();
|
||||
else
|
||||
sParentPath = pszParentPath;
|
||||
|
||||
if (_taccess(sParentPath, 0x00) != 0x0)
|
||||
return sPath;
|
||||
|
||||
CString sFileName(pszFileMainName);
|
||||
|
||||
if (bUsePID)
|
||||
{
|
||||
unsigned long pid = (unsigned long)::GetCurrentProcessId();
|
||||
sTemp.Format(_T("%lu"), pid);
|
||||
sFileName += sTemp;
|
||||
}
|
||||
|
||||
if (objId.isValid())
|
||||
{
|
||||
sTemp.Format(_T("%I64u"), (unsigned __int64)objId.asOldId());
|
||||
sFileName += sTemp;
|
||||
}
|
||||
|
||||
sFileName += pszFileSuffix;
|
||||
|
||||
sPath = sParentPath + _T("\\") + sFileName;
|
||||
|
||||
return sPath;
|
||||
}
|
||||
Reference in new issue
Block a user