| 2477 | } |
| 2478 | |
| 2479 | bool |
| 2480 | Project::fixFilePath(const std::string& projectPathName, |
| 2481 | const std::string& newProjectPath, |
| 2482 | std::string& filePath) |
| 2483 | { |
| 2484 | if ( ( filePath.size() < (projectPathName.size() + 2) ) //< filepath doesn't have enough space to contain the variable |
| 2485 | || ( filePath[0] != '[') |
| 2486 | || ( filePath[projectPathName.size() + 1] != ']') |
| 2487 | || ( filePath.substr( 1, projectPathName.size() ) != projectPathName) ) { |
| 2488 | return false; |
| 2489 | } |
| 2490 | |
| 2491 | canonicalizePath(filePath); |
| 2492 | |
| 2493 | if ( newProjectPath.empty() ) { |
| 2494 | return true; //keep it absolute if the variables points to nothing |
| 2495 | } else { |
| 2496 | QDir dir( QString::fromUtf8( newProjectPath.c_str() ) ); |
| 2497 | if ( !dir.exists() ) { |
| 2498 | return false; |
| 2499 | } |
| 2500 | |
| 2501 | filePath = dir.relativeFilePath( QString::fromUtf8( filePath.c_str() ) ).toStdString(); |
| 2502 | if (newProjectPath[newProjectPath.size() - 1] == '/') { |
| 2503 | filePath = '[' + projectPathName + ']' + filePath; |
| 2504 | } else { |
| 2505 | filePath = '[' + projectPathName + "]/" + filePath; |
| 2506 | } |
| 2507 | |
| 2508 | return true; |
| 2509 | } |
| 2510 | } |
| 2511 | |
| 2512 | bool |
| 2513 | Project::isRelative(const std::string& str) |
no test coverage detected