Added intial cut at fileExists() implement using libcurl. Note, current implement loads the whole file and then discards it so is very in-efficient. This implementation will soon be replaced.
This commit is contained in:
parent
122ee0a001
commit
59ddcd08f4
@ -349,6 +349,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType
|
||||
// return ReadResult::FILE_NOT_HANDLED;
|
||||
//}
|
||||
|
||||
osg::notify(osg::INFO)<<"CURL: Have readerwriter="<<reader<<std::endl;
|
||||
|
||||
const char* proxyEnvAddress = getenv("OSG_CURL_PROXY");
|
||||
if (proxyEnvAddress) //Env Proxy Settings
|
||||
{
|
||||
@ -368,6 +370,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType
|
||||
|
||||
if (curlResult.status()==ReadResult::FILE_LOADED)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"CURL: ReadResult::FILE_LOADED "<<std::endl;
|
||||
|
||||
// If we do not already have a ReaderWriter, try to find one based on the
|
||||
// mime-type:
|
||||
if ( !reader )
|
||||
@ -490,6 +494,22 @@ bool ReaderWriterCURL::read(std::istream& fin, std::string& destination) const
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ReaderWriterCURL::fileExists(const std::string& filename, const osgDB::Options* options) const
|
||||
{
|
||||
if (osgDB::containsServerAddress(filename))
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Checking if file exists using curl plugin: "<<filename<<std::endl;
|
||||
|
||||
ReadResult result = readFile(OBJECT,filename,options);
|
||||
return result.status()==osgDB::ReaderWriter::ReadResult::FILE_LOADED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ReaderWriter::fileExists(filename, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
REGISTER_OSGPLUGIN(curl, ReaderWriterCURL)
|
||||
|
@ -88,6 +88,8 @@ class ReaderWriterCURL : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"curl");
|
||||
}
|
||||
|
||||
virtual bool fileExists(const std::string& filename, const osgDB::Options* options) const;
|
||||
|
||||
virtual ReadResult openArchive(const std::string& fileName,ArchiveStatus status, unsigned int , const Options* options) const
|
||||
{
|
||||
if (status!=READ) return ReadResult(ReadResult::FILE_NOT_HANDLED);
|
||||
|
Loading…
Reference in New Issue
Block a user