MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / canonicalizePath

Method canonicalizePath

Engine/Project.cpp:2524–2563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2522}
2523
2524void
2525Project::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
2565void
2566Project::simplifyPath(std::string& str)

Callers 11

knobChangedMethod · 0.80
createReaderMethod · 0.80
loadMethod · 0.80
SequenceFileDialogMethod · 0.80
createReaderMethod · 0.80
updateGUIMethod · 0.80

Calls 6

emptyMethod · 0.80
toStdStringMethod · 0.80
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected