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