7 #include "Windows/Error.h"
9 #include "Common/StdOutStream.h"
10 #include "Common/NewHandler.h"
11 #include "Common/MyException.h"
12 #include "Common/StringConvert.h"
14 #include "../Common/ExitCode.h"
15 #include "../Common/ArchiveCommandLine.h"
16 #include "ConsoleClose.h"
18 using namespace NWindows;
20 CStdOutStream *g_StdStream = 0;
26 #if !defined(_UNICODE) || !defined(_WIN64)
27 static inline bool IsItWindowsNT()
29 OSVERSIONINFO versionInfo;
30 versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
31 if (!::GetVersionEx(&versionInfo))
33 return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
40 int numArguments, const char *arguments[]
44 static const char *kExceptionErrorMessage = "\n\nError:\n";
45 static const char *kUserBreak = "\nBreak signaled\n";
47 static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
48 static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
49 static const char *kInternalExceptionMessage = "\n\nInternal Error #";
58 int numArguments, const char *arguments[]
62 g_StdStream = &g_StdOut;
69 (*g_StdStream) << "This program requires Windows NT/2000/XP/2003/Vista";
70 return NExitCode::kFatalError;
74 g_IsNT = IsItWindowsNT();
79 // setlocale(LC_COLLATE, ".OCP");
80 NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
86 numArguments, arguments
90 catch(const CNewException &)
92 (*g_StdStream) << kMemoryExceptionMessage;
93 return (NExitCode::kMemoryError);
95 catch(const NConsoleClose::CCtrlBreakException &)
97 (*g_StdStream) << endl << kUserBreak;
98 return (NExitCode::kUserBreak);
100 catch(const CArchiveCommandLineException &e)
102 (*g_StdStream) << kExceptionErrorMessage << e << endl;
103 return (NExitCode::kUserError);
105 catch(const CSystemException &systemError)
107 if (systemError.ErrorCode == E_OUTOFMEMORY)
109 (*g_StdStream) << kMemoryExceptionMessage;
110 return (NExitCode::kMemoryError);
112 if (systemError.ErrorCode == E_ABORT)
114 (*g_StdStream) << endl << kUserBreak;
115 return (NExitCode::kUserBreak);
118 NError::MyFormatMessage(systemError.ErrorCode, message);
119 (*g_StdStream) << endl << endl << "System error:" << endl <<
121 return (NExitCode::kFatalError);
123 catch(NExitCode::EEnum &exitCode)
125 (*g_StdStream) << kInternalExceptionMessage << exitCode << endl;
129 catch(const NExitCode::CMultipleErrors &multipleErrors)
131 (*g_StdStream) << endl << multipleErrors.NumErrors << " errors" << endl;
132 return (NExitCode::kFatalError);
135 catch(const UString &s)
137 (*g_StdStream) << kExceptionErrorMessage << s << endl;
138 return (NExitCode::kFatalError);
140 catch(const AString &s)
142 (*g_StdStream) << kExceptionErrorMessage << s << endl;
143 return (NExitCode::kFatalError);
147 (*g_StdStream) << kExceptionErrorMessage << s << endl;
148 return (NExitCode::kFatalError);
152 (*g_StdStream) << kInternalExceptionMessage << t << endl;
153 return (NExitCode::kFatalError);
157 (*g_StdStream) << kUnknownExceptionMessage;
158 return (NExitCode::kFatalError);