1
0

errhnd.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _RAR_ERRHANDLER_
  2. #define _RAR_ERRHANDLER_
  3. enum RAR_EXIT // RAR exit code.
  4. {
  5. RARX_SUCCESS = 0,
  6. RARX_WARNING = 1,
  7. RARX_FATAL = 2,
  8. RARX_CRC = 3,
  9. RARX_LOCK = 4,
  10. RARX_WRITE = 5,
  11. RARX_OPEN = 6,
  12. RARX_USERERROR = 7,
  13. RARX_MEMORY = 8,
  14. RARX_CREATE = 9,
  15. RARX_NOFILES = 10,
  16. RARX_BADPWD = 11,
  17. RARX_READ = 12,
  18. RARX_USERBREAK = 255
  19. };
  20. class ErrorHandler
  21. {
  22. private:
  23. RAR_EXIT ExitCode;
  24. uint ErrCount;
  25. bool EnableBreak;
  26. bool Silent;
  27. bool DisableShutdown; // Shutdown is not suitable after last error.
  28. bool ReadErrIgnoreAll;
  29. public:
  30. ErrorHandler();
  31. void Clean();
  32. void MemoryError();
  33. void OpenError(const wchar *FileName);
  34. void CloseError(const wchar *FileName);
  35. void ReadError(const wchar *FileName);
  36. void AskRepeatRead(const wchar *FileName,bool &Ignore,bool &Retry,bool &Quit);
  37. void WriteError(const wchar *ArcName,const wchar *FileName);
  38. void WriteErrorFAT(const wchar *FileName);
  39. bool AskRepeatWrite(const wchar *FileName,bool DiskFull);
  40. void SeekError(const wchar *FileName);
  41. void GeneralErrMsg(const wchar *fmt,...);
  42. void MemoryErrorMsg();
  43. void OpenErrorMsg(const wchar *FileName);
  44. void OpenErrorMsg(const wchar *ArcName,const wchar *FileName);
  45. void CreateErrorMsg(const wchar *FileName);
  46. void CreateErrorMsg(const wchar *ArcName,const wchar *FileName);
  47. void ReadErrorMsg(const wchar *FileName);
  48. void ReadErrorMsg(const wchar *ArcName,const wchar *FileName);
  49. void WriteErrorMsg(const wchar *ArcName,const wchar *FileName);
  50. void ArcBrokenMsg(const wchar *ArcName);
  51. void ChecksumFailedMsg(const wchar *ArcName,const wchar *FileName);
  52. void UnknownMethodMsg(const wchar *ArcName,const wchar *FileName);
  53. void Exit(RAR_EXIT ExitCode);
  54. void SetErrorCode(RAR_EXIT Code);
  55. RAR_EXIT GetErrorCode() {return ExitCode;}
  56. uint GetErrorCount() {return ErrCount;}
  57. void SetSignalHandlers(bool Enable);
  58. void Throw(RAR_EXIT Code);
  59. void SetSilent(bool Mode) {Silent=Mode;}
  60. bool GetSysErrMsg(wchar *Msg,size_t Size);
  61. void SysErrMsg();
  62. int GetSystemErrorCode();
  63. void SetSystemErrorCode(int Code);
  64. void SetDisableShutdown() {DisableShutdown=true;}
  65. bool IsShutdownEnabled() {return !DisableShutdown;}
  66. bool UserBreak; // Ctrl+Break is pressed.
  67. bool MainExit; // main() is completed.
  68. };
  69. #endif