| 2333 | } |
| 2334 | |
| 2335 | bool |
| 2336 | Project::fixFilePath(const std::string& projectPathName, |
| 2337 | const std::string& newProjectPath, |
| 2338 | std::string& filePath) |
| 2339 | { |
| 2340 | if ( ( filePath.size() < (projectPathName.size() + 2) ) //< filepath doesn't have enough space to contain the variable |
| 2341 | || ( filePath[0] != '[') |
| 2342 | || ( filePath[projectPathName.size() + 1] != ']') |
| 2343 | || ( filePath.substr( 1, projectPathName.size() ) != projectPathName) ) { |
| 2344 | return false; |
| 2345 | } |
| 2346 | |
| 2347 | canonicalizePath(filePath); |
| 2348 | |
| 2349 | if ( newProjectPath.empty() ) { |
| 2350 | return true; //keep it absolute if the variables points to nothing |
| 2351 | } else { |
| 2352 | QDir dir( QString::fromUtf8( newProjectPath.c_str() ) ); |
| 2353 | if ( !dir.exists() ) { |
| 2354 | return false; |
| 2355 | } |
| 2356 | |
| 2357 | filePath = dir.relativeFilePath( QString::fromUtf8( filePath.c_str() ) ).toStdString(); |
| 2358 | if (newProjectPath[newProjectPath.size() - 1] == '/') { |
| 2359 | filePath = '[' + projectPathName + ']' + filePath; |
| 2360 | } else { |
| 2361 | filePath = '[' + projectPathName + "]/" + filePath; |
| 2362 | } |
| 2363 | |
| 2364 | return true; |
| 2365 | } |
| 2366 | } |
| 2367 | |
| 2368 | bool |
| 2369 | Project::isRelative(const std::string& str) |
no test coverage detected