102 }
103 #ifdef DEBUG
104 // There is a compiler bug on Mac when overloading ShowResponseMessage.
105 else if (argument == _T("-nativedebug")) {
106 if (platform.ShowResponseMessage(_T("Test"),
107 TString(_T("Would you like to debug?\n\nProcessID: ")) +
108 PlatformString(platform.GetProcessID()).toString()) == mrOK) {
109 while (platform.IsNativeDebuggerPresent() == false) {
110 }
111 }
112 }
113 #endif //DEBUG
114 }
115
116 // Package must be initialized after Platform is fully initialized.
117 Package& package = Package::GetInstance();
118 Macros::Initialize();
119 package.SetCommandLineArguments(argc, argv);
120 platform.SetCurrentDirectory(package.GetPackageAppDirectory());
121
122 switch (platform.GetAppCDSState()) {
123 case cdsDisabled:
124 case cdsUninitialized:
125 case cdsEnabled: {
126 break;
127 }
128
129 case cdsGenCache: {
130 TString cacheDirectory = package.GetAppCDSCacheDirectory();
131
132 if (FilePath::DirectoryExists(cacheDirectory) == false) {
133 FilePath::CreateDirectory(cacheDirectory, true);
134 }
135 else {
136 TString cacheFileName = package.GetAppCDSCacheFileName();
137
138 if (FilePath::FileExists(cacheFileName) == true) {
139 FilePath::DeleteFile(cacheFileName);
140 }
141 }
175 break;
176 }
177
178 case cdsEnabled:
179 case cdsAuto: {
180 TString cacheFileName = package.GetAppCDSCacheFileName();
181
182 if (FilePath::FileExists(cacheFileName) == false) {
183 Messages& messages = Messages::GetInstance();
184 TString message = PlatformString::Format(messages.GetMessage(APPCDS_CACHE_FILE_NOT_FOUND), cacheFileName.data());
185 throw FileNotFoundException(message);
186 }
187 break;
188 }
189
190 case cdsUninitialized: {
191 throw Exception(_T("Internal Error"));
192 }
193 }
194 }
195
196 // Run App
197 result = RunVM();
198 }
199 catch (FileNotFoundException &e) {
200 platform.ShowMessage(e.GetMessage());
201 }
202
203 return result;
204 }
205
206 #ifdef WINDOWS
207 __declspec(dllexport)
208 #endif //WINDOWS
209
210 void stop_launcher() {
211 }
212 }
|
102 }
103 #ifdef DEBUG
104 // There is a compiler bug on Mac when overloading ShowResponseMessage.
105 else if (argument == _T("-nativedebug")) {
106 if (platform.ShowResponseMessage(_T("Test"),
107 TString(_T("Would you like to debug?\n\nProcessID: ")) +
108 PlatformString(platform.GetProcessID()).toString()) == mrOK) {
109 while (platform.IsNativeDebuggerPresent() == false) {
110 }
111 }
112 }
113 #endif //DEBUG
114 }
115
116 // Package must be initialized after Platform is fully initialized.
117 Package& package = Package::GetInstance();
118 Macros::Initialize();
119 package.SetCommandLineArguments(argc, argv);
120 platform.SetCurrentDirectory(package.GetPackageAppDirectory());
121
122 if (package.CheckForSingleInstance()) {
123 // reactivate the first instance if the process Id is valid
124 platform.reactivateAnotherInstance();
125 if (package.GetArgs().size() > 0 && platform.GetSingleInstanceProcessId() != 0) {
126 // if user specified args, try to pass them to the first instance
127 return RunVM(SINGLE_INSTANCE_NOTIFICATION_LAUNCH);
128 }
129 return true;
130 }
131
132 switch (platform.GetAppCDSState()) {
133 case cdsDisabled:
134 case cdsUninitialized:
135 case cdsEnabled: {
136 break;
137 }
138
139 case cdsGenCache: {
140 TString cacheDirectory = package.GetAppCDSCacheDirectory();
141
142 if (FilePath::DirectoryExists(cacheDirectory) == false) {
143 FilePath::CreateDirectory(cacheDirectory, true);
144 }
145 else {
146 TString cacheFileName = package.GetAppCDSCacheFileName();
147
148 if (FilePath::FileExists(cacheFileName) == true) {
149 FilePath::DeleteFile(cacheFileName);
150 }
151 }
185 break;
186 }
187
188 case cdsEnabled:
189 case cdsAuto: {
190 TString cacheFileName = package.GetAppCDSCacheFileName();
191
192 if (FilePath::FileExists(cacheFileName) == false) {
193 Messages& messages = Messages::GetInstance();
194 TString message = PlatformString::Format(messages.GetMessage(APPCDS_CACHE_FILE_NOT_FOUND), cacheFileName.data());
195 throw FileNotFoundException(message);
196 }
197 break;
198 }
199
200 case cdsUninitialized: {
201 throw Exception(_T("Internal Error"));
202 }
203 }
204 }
205 // Run App
206 result = RunVM(USER_APP_LAUNCH);
207 }
208 catch (FileNotFoundException &e) {
209 platform.ShowMessage(e.GetMessage());
210 }
211
212 return result;
213 }
214
215 #ifdef WINDOWS
216 __declspec(dllexport)
217 #endif //WINDOWS
218
219 void stop_launcher() {
220 }
221 }
|