From 6e7a1608df9551d714cca4a0a07f14cc8dd9438c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 21 Mar 2008 18:35:29 +0000 Subject: [PATCH] Added preliminary file cache support. Enabled by setting the OSG_FILE_CACHE variable. --- src/osgPlugins/curl/ReaderWriterCURL.cpp | 54 ++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/osgPlugins/curl/ReaderWriterCURL.cpp b/src/osgPlugins/curl/ReaderWriterCURL.cpp index 731fdd56e..60f2205fe 100644 --- a/src/osgPlugins/curl/ReaderWriterCURL.cpp +++ b/src/osgPlugins/curl/ReaderWriterCURL.cpp @@ -10,6 +10,7 @@ */ +#include #include #include #include @@ -144,6 +145,22 @@ class ReaderWriterCURL : public osgDB::ReaderWriter osg::notify(osg::NOTICE)<<"Error: No ReaderWriter for file "<readObject(cacheFileName,options); + } std::stringstream buffer; @@ -157,16 +174,47 @@ class ReaderWriterCURL : public osgDB::ReaderWriter if (res==0) { + + osg::ref_ptr local_opt = const_cast(options); if (!local_opt) local_opt = new Options; local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName)); - ReadResult result = readFile(objectType, reader, buffer, local_opt.get() ); + ReadResult readResult = readFile(objectType, reader, buffer, local_opt.get() ); local_opt->getDatabasePathList().pop_front(); - - return result; + + if (fileCachePath && readResult.validObject()) + { + osg::notify(osg::NOTICE)<<"Writing cache file "<