// SystemManager.cpp: implementation of the CSystemManager class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "IDE.h" #include "Afxcoll.h" #include #include "SystemManager.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CSystemManager::CSystemManager() { } CSystemManager::~CSystemManager() { } BOOL CSystemManager::DirSearch(CString strPath, CString strFileName) { BOOL bResult = FALSE; long hDir; struct _finddata_t fDir; int nDone; strPath += "*.*"; hDir = _findfirst( (char *)(LPCTSTR)strPath, &fDir ); if( -1L != hDir ) { while( !( nDone = _findnext(hDir, &fDir) ) ) { if( !strcmp(fDir.name, "..") ) continue; if( (_A_SUBDIR == fDir.attrib) ) { CString str = fDir.name; if( !str.Compare(strFileName) ) { bResult = TRUE; } } } } return bResult; } void CSystemManager::FileSearch(CStringArray &picName, CStringArray &picPath, CString strPath, CString strFileName, int nLayer) { long hfile; struct _finddata_t fFile; CString strCurr = strPath + "\\" + strFileName; //strPath + strFileName; // int nDone=0; hfile = _findfirst( (char *)(LPCTSTR)strCurr, &fFile ); if( -1L != hfile ) { while( !( nDone = _findnext(hfile, &fFile) ) ) { if( !strcmp(fFile.name,"..") ) continue; if( (_A_SUBDIR == fFile.attrib) ) { strCurr = strPath + "\\" + fFile.name;//strPath + fFile.name; // CString str = fFile.name; FileSearch(picName, picPath, strCurr, "*.*", nLayer + 1); //pBox->AddString( str ); picName.Add(str); int nPos = strCurr.Find("\\\\"); if( nPos!=-1 ) { strCurr.Delete( nPos ); } picPath.Add(strCurr); } else { CString str = fFile.name; if( str.Right(4).Compare("view") ) continue; CString strTemp = str.Left(str.GetLength()-5); if( !DirSearch(strPath + "\\", strTemp ) ) { //pBox->AddString( str.Left(str.GetLength()-7) ); picName.Add(str.Left(str.GetLength()-5)); int nPos = strPath.Find("\\\\"); if( nPos!=-1 ) { strPath.Delete( nPos ); if( strPath.Right( strPath.GetLength()-1)!="\\" ) strPath += "\\"; } picPath.Add(strPath + strTemp);//+ "\\" } } } _findclose(hfile); } } void CSystemManager::GetPicNameArray(CStringArray &picName, CStringArray &picPath) { picName.RemoveAll(); char picDir[_MAX_PATH] = {0}; strcpy(picDir, g_strDirectory); strcat(picDir, "\\"); strcat(picDir, _PICTUREDIR); FileSearch( picName, picPath, CString(picDir), "*.*", 0 ); }