Commits
1 1 | /* |
2 2 | appli* CrashReporter.cc |
3 3 | * |
4 4 | * Created on: Mar 16, 2016 |
5 5 | * Author: jjacobs |
6 6 | */ |
7 7 | |
8 8 | |
9 9 | |
10 + | |
10 11 | |
11 12 | //#warning "Defining UseCrashReport to compile main code" |
12 13 | //#define UseCrashReporter |
13 14 | |
14 15 | |
15 16 | |
16 17 | // Stubs to allow safely eliminating the breakpad/crash-reporting functionality from |
17 18 | // CASA by the use of the above build time symbol. |
18 19 | |
19 20 | using namespace casacore; |
281 282 | |
282 283 | char * s = getenv ("CASAPATH"); |
283 284 | exePath = (s) ? s : ""; |
284 285 | |
285 286 | // Replace a string of contiguous spaces (should be one of these) with |
286 287 | // a "slash". |
287 288 | |
288 289 | std::regex spaces (" +"); |
289 290 | exePath = regex_replace (exePath, spaces, "/"); |
290 291 | |
292 + | // Is the exePath doesn't exist, try removing the tail f.e. "linux" |
293 + | // Tail is only useful for developer builds |
294 + | struct stat info; |
295 + | if( stat( exePath.c_str(), &info ) != 0 ) { |
296 + | //printf( "cannot access %s\n", exePath.c_str() ); |
297 + | const char *tail = std::strrchr(exePath.c_str() , '/'); |
298 + | //std::cout << "Tail: " << tail << "\n"; |
299 + | size_t pos = exePath.find(tail); |
300 + | exePath = exePath.replace(pos, exePath.size(),""); |
301 + | //std::cout << "exePath: " << exePath << "\n"; |
302 + | } |
291 303 | exePath += "/bin/bogusExe"; |
292 304 | |
293 305 | } |
294 306 | |
295 307 | // Extract the path portion of the file spec. |
296 308 | |
297 309 | std::cmatch match; |
298 310 | std::string binPath; |
299 311 | std::regex re ("(.*/)[^/]*$"); // Match everything through the last slash |
300 312 | |