OTSFileSys.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. //#include <boost/scope_exit.hpp>
  3. #include <boost/noncopyable.hpp>
  4. #include <wtypes.h>
  5. #include <afxstr.h>
  6. #include "otsdataconst.h"
  7. namespace OTSTools {
  8. using namespace OTSDATA;
  9. /*typedef enum class __declspec(dllexport) OTS_SOFT_PACKAGE_ID
  10. {
  11. INVALID = -1,
  12. MIN = 0,
  13. OTSIncA = 0,
  14. OTSPartA = 1,
  15. MAX = 1*/
  16. //} OTS_SOFT_PACKAGE_ID;
  17. class __declspec(dllexport) COTSFileSys : private boost::noncopyable
  18. {
  19. public:
  20. COTSFileSys();
  21. ~COTSFileSys();
  22. // check if the file exists or not
  23. static BOOL Exists(LPCTSTR a_sPath);
  24. // check if the given string is valid file name or not
  25. static BOOL IsValidFileName(LPCTSTR a_sFileName);
  26. // copy a file
  27. static BOOL CopyAFile(LPCTSTR a_strSourceFile, LPCTSTR a_strTargetFile, const BOOL a_bOverwrite = FALSE);
  28. // move a file
  29. static BOOL MoveAFile(LPCTSTR a_strSourceFile, LPCTSTR a_strTargetFile, const BOOL a_bOverwrite = TRUE);
  30. // delete a file.
  31. static BOOL DeleteAFile(LPCTSTR a_strFileName);
  32. // delete all files in the folder
  33. static BOOL DeleteAllFiles(LPCTSTR a_strFolder, LPCTSTR a_sFilter = nullptr);
  34. // creates a folder.
  35. static BOOL CreateFolder(LPCTSTR a_strFolder);
  36. // deletes a folder and contents recursively.
  37. static BOOL DeleteFolder(LPCTSTR a_strFolder);
  38. // check if this is an existing folder
  39. static BOOL IsFolder(LPCTSTR a_strFolder);
  40. // check if the file or folder is read only
  41. static BOOL IsReadOnly(LPCTSTR a_strPathName);
  42. // sets the read only flag for a file or a folder
  43. static BOOL SetReadOnly(LPCTSTR a_strPathName, BOOL a_bReadOnly = TRUE);
  44. // get system common data folder pathname
  45. static CString GetOSCommonDataPathName();
  46. // get company system data pathname
  47. static CString GetSysDataPathName();
  48. // get company log path
  49. static CString GetLogPathName();
  50. // get software pack system data path
  51. static CString GetOTSPackSysDataPathName(OTS_SOFT_PACKAGE_ID a_nPackId);
  52. // get software pack program data path
  53. static CString GetOTSPackProgDataPathName(OTS_SOFT_PACKAGE_ID a_nPackId);
  54. // get software pack measure preference file path name
  55. static CString GetOTSPackMeasurePrefFilePathName(OTS_SOFT_PACKAGE_ID a_nPackId);
  56. // get software pack measure preference file path name
  57. static CString GetOTSPackReportPrefFilePathName(OTS_SOFT_PACKAGE_ID a_nPackId);
  58. // get system STD lib file path name
  59. static CString GetOTSPackSysSTDLibFilePathName(OTS_SOFT_PACKAGE_ID a_nPackId);
  60. };
  61. }