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