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

Method fixFilePath

Engine/Project.cpp:2479–2510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2477}
2478
2479bool
2480Project::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
2512bool
2513Project::isRelative(const std::string& str)

Callers 1

fixRelativeFilePathsMethod · 0.80

Calls 3

emptyMethod · 0.80
toStdStringMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected