errhnd.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _RAR_ERRHANDLER_
  2. #define _RAR_ERRHANDLER_
  3. #if (defined(GUI) || !defined(_WIN_ALL)) && !defined(SFX_MODULE) && !defined(_WIN_CE) || defined(RARDLL)
  4. #define ALLOW_EXCEPTIONS
  5. #endif
  6. enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
  7. OPEN_ERROR,USER_ERROR,MEMORY_ERROR,CREATE_ERROR,NO_FILES_ERROR,
  8. USER_BREAK=255};
  9. class ErrorHandler
  10. {
  11. private:
  12. void ErrMsg(const char *ArcName,const char *fmt,...);
  13. int ExitCode;
  14. int ErrCount;
  15. bool EnableBreak;
  16. bool Silent;
  17. bool DoShutdown;
  18. public:
  19. ErrorHandler();
  20. void Clean();
  21. void MemoryError();
  22. void OpenError(const char *FileName,const wchar *FileNameW);
  23. void CloseError(const char *FileName,const wchar *FileNameW);
  24. void ReadError(const char *FileName,const wchar *FileNameW);
  25. bool AskRepeatRead(const char *FileName,const wchar *FileNameW);
  26. void WriteError(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW);
  27. void WriteErrorFAT(const char *FileName,const wchar *FileNameW);
  28. bool AskRepeatWrite(const char *FileName,const wchar *FileNameW,bool DiskFull);
  29. void SeekError(const char *FileName,const wchar *FileNameW);
  30. void GeneralErrMsg(const char *Msg);
  31. void MemoryErrorMsg();
  32. void OpenErrorMsg(const char *FileName,const wchar *FileNameW=NULL);
  33. void OpenErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW);
  34. void CreateErrorMsg(const char *FileName,const wchar *FileNameW=NULL);
  35. void CreateErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW);
  36. void CheckLongPathErrMsg(const char *FileName,const wchar *FileNameW);
  37. void ReadErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW);
  38. void WriteErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW);
  39. void Exit(int ExitCode);
  40. void SetErrorCode(int Code);
  41. int GetErrorCode() {return(ExitCode);}
  42. int GetErrorCount() {return(ErrCount);}
  43. void SetSignalHandlers(bool Enable);
  44. void Throw(int Code);
  45. void SetSilent(bool Mode) {Silent=Mode;};
  46. void SetShutdown(bool Mode) {DoShutdown=Mode;};
  47. void SysErrMsg();
  48. };
  49. #endif