SystemManager.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // SystemManager.cpp: implementation of the CSystemManager class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "IDE.h"
  6. #include "ActionDlg.h"
  7. #include "Afxcoll.h"
  8. #include <io.h>
  9. #include "SystemManager.h"
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char THIS_FILE[]=__FILE__;
  13. #define new DEBUG_NEW
  14. #endif
  15. //////////////////////////////////////////////////////////////////////
  16. // Construction/Destruction
  17. //////////////////////////////////////////////////////////////////////
  18. CSystemManager::CSystemManager()
  19. {
  20. }
  21. CSystemManager::~CSystemManager()
  22. {
  23. }
  24. BOOL CSystemManager::DirSearch(CString strPath, CString strFileName)
  25. {
  26. BOOL bResult = FALSE;
  27. long hDir;
  28. struct _finddata_t fDir;
  29. int nDone;
  30. strPath += "*.*";
  31. hDir = _findfirst( (char *)(LPCTSTR)strPath, &fDir );
  32. if( -1L != hDir )
  33. {
  34. while( !( nDone = _findnext(hDir, &fDir) ) )
  35. {
  36. if( !strcmp(fDir.name, "..") ) continue;
  37. if( (_A_SUBDIR == fDir.attrib) )
  38. {
  39. CString str = fDir.name;
  40. if( !str.Compare(strFileName) )
  41. {
  42. bResult = TRUE;
  43. }
  44. }
  45. }
  46. }
  47. return bResult;
  48. }
  49. void CSystemManager::FileSearch(CStringArray &picName, CStringArray &picPath, CString strPath, CString strFileName, int nLayer)
  50. {
  51. long hfile;
  52. struct _finddata_t fFile;
  53. CString strCurr = strPath + "\\" + strFileName; //strPath + strFileName; //
  54. int nDone=0;
  55. hfile = _findfirst( (char *)(LPCTSTR)strCurr, &fFile );
  56. if( -1L != hfile )
  57. {
  58. while( !( nDone = _findnext(hfile, &fFile) ) )
  59. {
  60. if( !strcmp(fFile.name,"..") ) continue;
  61. if( (_A_SUBDIR == fFile.attrib) )
  62. {
  63. strCurr = strPath + "\\" + fFile.name;//strPath + fFile.name; //
  64. CString str = fFile.name;
  65. FileSearch(picName, picPath, strCurr, "*.*", nLayer + 1);
  66. //pBox->AddString( str );
  67. picName.Add(str);
  68. int nPos = strCurr.Find("\\\\");
  69. if( nPos!=-1 )
  70. {
  71. strCurr.Delete( nPos );
  72. }
  73. picPath.Add(strCurr);
  74. }
  75. else
  76. {
  77. CString str = fFile.name;
  78. if( str.Right(4).Compare("view") ) continue;
  79. CString strTemp = str.Left(str.GetLength()-5);
  80. if( !DirSearch(strPath + "\\", strTemp ) )
  81. {
  82. //pBox->AddString( str.Left(str.GetLength()-7) );
  83. picName.Add(str.Left(str.GetLength()-5));
  84. int nPos = strPath.Find("\\\\");
  85. if( nPos!=-1 )
  86. {
  87. strPath.Delete( nPos );
  88. if( strPath.Right( strPath.GetLength()-1)!="\\" )
  89. strPath += "\\";
  90. }
  91. picPath.Add(strPath + strTemp);//+ "\\"
  92. }
  93. }
  94. }
  95. _findclose(hfile);
  96. }
  97. }
  98. void CSystemManager::GetPicNameArray(CStringArray &picName, CStringArray &picPath)
  99. {
  100. picName.RemoveAll();
  101. char picDir[_MAX_PATH] = {0};
  102. strcpy(picDir, g_strDirectory);
  103. strcat(picDir, "\\");
  104. strcat(picDir, _PICTUREDIR);
  105. FileSearch( picName, picPath, CString(picDir), "*.*", 0 );
  106. }