| 542 | } |
| 543 | |
| 544 | COLLADASW::URI DocumentExporter::createTargetURI(const COLLADASW::URI& sourceUri) const |
| 545 | { |
| 546 | COLLADASW::URI targetUri; |
| 547 | |
| 548 | if (ExportOptions::preserveSourceTree()) |
| 549 | { |
| 550 | // Get the URI of the Maya source file. |
| 551 | MString mayaSourceFile = MFileIO::currentFile(); |
| 552 | COLLADASW::URI mayaSourceFileUri(COLLADASW::URI::nativePathToUri(mayaSourceFile.asChar())); |
| 553 | if (mayaSourceFileUri.getScheme().empty()) |
| 554 | mayaSourceFileUri.setScheme(COLLADASW::URI::SCHEME_FILE); |
| 555 | |
| 556 | // Get the URI of the source file. |
| 557 | bool success = true; |
| 558 | COLLADASW::URI targetRelativeUri = sourceUri.getRelativeTo(mayaSourceFileUri, success); |
| 559 | if (!success) |
| 560 | { |
| 561 | String message = "Not able to generate a relative path from " |
| 562 | + mayaSourceFileUri.getURIString() + " to " + sourceUri.getURIString() |
| 563 | + ". An absolute path will be written! "; |
| 564 | MGlobal::displayError(message.c_str()); |
| 565 | targetUri = sourceUri; |
| 566 | } |
| 567 | else |
| 568 | { |
| 569 | // Get the URI of the COLLADA file. |
| 570 | String targetColladaFile = getFilename(); |
| 571 | COLLADASW::URI targetColladaUri(COLLADASW::URI::nativePathToUri(targetColladaFile)); |
| 572 | if (targetColladaUri.getScheme().empty()) |
| 573 | targetColladaUri.setScheme(COLLADASW::URI::SCHEME_FILE); |
| 574 | |
| 575 | COLLADASW::URI targetColladaDirUri(targetColladaUri.getPathDir()); |
| 576 | targetColladaDirUri.setScheme(targetColladaUri.getScheme()); |
| 577 | |
| 578 | String pathDir = targetColladaDirUri.getPathDir() + targetRelativeUri.getPathDir(); |
| 579 | COLLADASW::URI::normalizeURIPath(const_cast<char*>(pathDir.c_str())); |
| 580 | |
| 581 | targetUri = targetColladaDirUri; |
| 582 | targetUri.setPathDir(pathDir); |
| 583 | targetUri.setPathFile(sourceUri.getPathFile()); |
| 584 | } |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | // Target file |
| 589 | String targetFile = getFilename(); |
| 590 | targetUri = COLLADASW::URI::nativePathToUri(targetFile); |
| 591 | const String& targetScheme = targetUri.getScheme(); |
| 592 | |
| 593 | // Get the pure file name of the source file and set |
| 594 | // the source file name to the target path |
| 595 | targetUri.setPathFile(sourceUri.getPathFile()); |
| 596 | if (!targetScheme.empty()) |
| 597 | targetUri.setScheme(targetScheme); |
| 598 | else |
| 599 | targetUri.setScheme(COLLADASW::URI::SCHEME_FILE); |
| 600 | } |
| 601 |
no test coverage detected