| 2522 | } |
| 2523 | |
| 2524 | void |
| 2525 | Project::canonicalizePath(std::string& str) |
| 2526 | { |
| 2527 | std::map<std::string, std::string> envvar; |
| 2528 | |
| 2529 | getEnvironmentVariables(envvar); |
| 2530 | |
| 2531 | expandVariable(envvar, str); |
| 2532 | |
| 2533 | if ( !str.empty() ) { |
| 2534 | ///Now check if the string is relative |
| 2535 | |
| 2536 | if ( isRelative(str) ) { |
| 2537 | ///If it doesn't start with an env var but is relative, prepend the project env var |
| 2538 | std::map<std::string, std::string>::iterator foundProject = envvar.find(NATRON_PROJECT_ENV_VAR_NAME); |
| 2539 | if ( foundProject != envvar.end() ) { |
| 2540 | if ( foundProject->second.empty() ) { |
| 2541 | return; |
| 2542 | } |
| 2543 | const char& c = foundProject->second[foundProject->second.size() - 1]; |
| 2544 | bool addTrailingSlash = c != '/' && c != '\\'; |
| 2545 | std::string copy = foundProject->second; |
| 2546 | if (addTrailingSlash) { |
| 2547 | copy += '/'; |
| 2548 | } |
| 2549 | copy += str; |
| 2550 | str = copy; |
| 2551 | } |
| 2552 | } |
| 2553 | |
| 2554 | ///Canonicalize |
| 2555 | QFileInfo info( QString::fromUtf8( str.c_str() ) ); |
| 2556 | QString canonical = info.canonicalFilePath(); |
| 2557 | if ( canonical.isEmpty() ) { |
| 2558 | return; |
| 2559 | } else { |
| 2560 | str = canonical.toStdString(); |
| 2561 | } |
| 2562 | } |
| 2563 | } |
| 2564 | |
| 2565 | void |
| 2566 | Project::simplifyPath(std::string& str) |
no test coverage detected