------------------------------------------------------------------------------
| 192 | |
| 193 | //------------------------------------------------------------------------------ |
| 194 | vtkSmartPointer<vtkResourceStream> vtkURILoader::LoadFile(const vtkURI& uri) |
| 195 | { |
| 196 | // Decode |
| 197 | auto decodedPath = vtkURI::PercentDecode(uri.GetPath().GetValue()); |
| 198 | |
| 199 | auto cpath = decodedPath.c_str(); |
| 200 | #if defined(_WIN32) |
| 201 | if (*cpath == '/') // discard first / on Windows |
| 202 | { |
| 203 | ++cpath; |
| 204 | } |
| 205 | #endif |
| 206 | |
| 207 | auto stream = vtkSmartPointer<vtkFileResourceStream>::New(); |
| 208 | if (!stream->Open(cpath)) |
| 209 | { |
| 210 | vtkErrorMacro("Failed to open file \"" << cpath << "\""); |
| 211 | return nullptr; |
| 212 | } |
| 213 | |
| 214 | return stream; |
| 215 | } |
| 216 | |
| 217 | namespace |
| 218 | { |