123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- // SystemManager.cpp: implementation of the CSystemManager class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "IDE.h"
- #include "Afxcoll.h"
- #include <io.h>
- #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 );
- }
|