void Cx_TempFolder::DeleteFolders() { while (!c_arrToDel.empty()) { std::wstring wstrPath(c_arrToDel.back()); c_arrToDel.pop_back(); FileUtility()->DeletePathFile(wstrPath.c_str()); } }
std::wstring Cx_TempFolder::CreateFolder(const std::wstring& wstrPrefix) { ASSERT(!m_wstrRootPath.empty()); Cx_Interface<Ix_FileUtility> pIFUtility(CLSID_FileUtility); DeleteFolder(); for (int i = 1; i < 9999; i++) { WCHAR szFileName[MAX_PATH] = { 0 }; swprintf_s(szFileName, _countof(szFileName), L"%s%03d", wstrPrefix.c_str(), i); std::wstring wstrPath (pIFUtility->RelToAbs(szFileName, false, m_wstrRootPath.c_str(), false)); if (!pIFUtility->IsPathFileExists(wstrPath.c_str())) { m_wstrPath = wstrPath; break; } } bool bRet = !m_wstrPath.empty() && pIFUtility->CreateDirectory(m_wstrPath.c_str(), true); return bRet ? m_wstrPath : L"?"; }
CSystemFidFile* CSystemFidsFolder::GetFile ( const wchar_t* pwszPath ) { CSystemFidsFolder* pFolder = this; const wchar_t* pwszLastSlash = wcsrchr ( pwszPath, L'/' ); const wchar_t* pwszFileName = pwszPath; if ( pwszLastSlash ) { std::wstring wstrPath ( pwszPath, pwszLastSlash ); pFolder = GetFolder ( wstrPath.c_str () ); if ( !pFolder ) return NULL; pwszFileName = pwszLastSlash + 1; } for ( auto it = pFolder->m_Files.Begin (); it != pFolder->m_Files.End (); it++ ) { CSystemFidFile* pFile = nod_cast < CSystemFidFile* > ( *it ); if ( pFile && pFile->GetFileName () == pwszFileName ) return pFile; } return NULL; }