From d96e57c0c30f1b3bdd99d1bfb9ddc255fd0ed5fa Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 15 Sep 2010 10:24:59 +0000 Subject: [PATCH] Added https, ftp and ftps to list of supported server protocols, and add ability for curl plugin to ignore the need for a server address when .curl extension is used. --- src/osgDB/Registry.cpp | 5 +++- src/osgPlugins/curl/ReaderWriterCURL.cpp | 32 ++++++++++++------------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 2065058a7..22646915b 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -367,8 +367,11 @@ Registry::Registry() addMimeTypeExtensionMapping( mimeType, builtinMimeTypeExtMappings[i+1] ); } - // register http-protocol, so the curl can handle it, if necessary + // register server protocols, so the curl can handle it, if necessary registerProtocol("http"); + registerProtocol("https"); + registerProtocol("ftp"); + registerProtocol("ftps"); _objectWrapperManager = new ObjectWrapperManager; _deprecatedDotOsgWrapperManager = new DeprecatedDotOsgWrapperManager; diff --git a/src/osgPlugins/curl/ReaderWriterCURL.cpp b/src/osgPlugins/curl/ReaderWriterCURL.cpp index f1c23e699..09b5b7fb6 100644 --- a/src/osgPlugins/curl/ReaderWriterCURL.cpp +++ b/src/osgPlugins/curl/ReaderWriterCURL.cpp @@ -277,21 +277,32 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType, const std::string& fullFileName, const osgDB::ReaderWriter::Options *options) const { + std::string fileName(fullFileName); + std::string ext = osgDB::getFileExtension(fullFileName); + bool curl_ext = ext=="curl"; + if (curl_ext) + { + fileName = osgDB::getNameLessExtension(fullFileName); + ext = osgDB::getFileExtension(fileName); + } - - if (!osgDB::containsServerAddress(fullFileName)) + if (!osgDB::containsServerAddress(fileName)) { if (options && !options->getDatabasePathList().empty()) - { + { if (osgDB::containsServerAddress(options->getDatabasePathList().front())) { - std::string newFileName = options->getDatabasePathList().front() + "/" + fullFileName; + std::string newFileName = options->getDatabasePathList().front() + "/" + fileName; return readFile(objectType, newFileName,options); } } - return ReadResult::FILE_NOT_HANDLED; + // if user has explictly specified curl then we don't about at this point, + // instead assume the curl can read it any way, if it doesn't explictly + // specify curl then we assume that the file is a local file and not appropriate + // for the curl plugin to load. + if (!curl_ext) return ReadResult::FILE_NOT_HANDLED; } OSG_INFO<<"ReaderWriterCURL::readFile("<