SystemManager.cpp 2.8 KB

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