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

Method fixFilePath

Engine/Project.cpp:2335–2366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2333}
2334
2335bool
2336Project::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
2368bool
2369Project::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