------------------------------------------------------------------------------
| 87 | |
| 88 | //------------------------------------------------------------------------------ |
| 89 | bool vtkURILoader::SetBaseDirectory(const std::string& dirpath) |
| 90 | { |
| 91 | if (!vtksys::SystemTools::FileExists(dirpath)) |
| 92 | { |
| 93 | vtkErrorMacro("Can not find \"" << dirpath << "\""); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | if (!vtksys::SystemTools::FileIsDirectory(dirpath)) |
| 98 | { |
| 99 | vtkErrorMacro("\"" << dirpath << "\" is not a directory. Use SetBaseFileName."); |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | // add /. because relative URI truncate the last path component |
| 104 | auto fullPath = vtksys::SystemTools::CollapseFullPath(dirpath) + "/."; |
| 105 | if (fullPath.front() != '/') // add / for windows path |
| 106 | { |
| 107 | fullPath.insert(fullPath.begin(), '/'); |
| 108 | } |
| 109 | |
| 110 | this->Impl->BaseURI = vtkURI::Make("file", "", vtkURI::PercentEncode(fullPath)); |
| 111 | |
| 112 | return this->Impl->BaseURI; |
| 113 | } |
| 114 | |
| 115 | //------------------------------------------------------------------------------ |
| 116 | vtkURI* vtkURILoader::GetBaseURI() const |