Changeset 8577
- Timestamp:
- 07/13/08 17:24:45
- Files:
-
- OpenSceneGraph/trunk/include/osgDB/FileNameUtils (modified) (1 diff)
- OpenSceneGraph/trunk/include/osgDB/ReaderWriter (modified) (3 diffs)
- OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp (modified) (1 diff)
- OpenSceneGraph/trunk/src/osgDB/ReaderWriter.cpp (modified) (2 diffs)
- OpenSceneGraph/trunk/src/osgPlugins/curl/ReaderWriterCURL.cpp (modified) (6 diffs)
- OpenSceneGraph/trunk/src/osgPlugins/ive/ReaderWriterIVE.cpp (modified) (1 diff)
- OpenSceneGraph/trunk/src/osgPlugins/osg/ReaderWriterOSG.cpp (modified) (1 diff)
- OpenSceneGraph/trunk/src/osgPlugins/rgb/ReaderWriterRGB.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph/trunk/include/osgDB/FileNameUtils
r6005 r8577 31 31 extern OSGDB_EXPORT std::string convertFileNameToWindowsStyle(const std::string& fileName); 32 32 extern OSGDB_EXPORT std::string convertFileNameToUnixStyle(const std::string& fileName); 33 extern OSGDB_EXPORT std::string convertToLowerCase(const std::string& fileName); 33 34 34 35 extern OSGDB_EXPORT bool isFileNameNativeStyle(const std::string& fileName); OpenSceneGraph/trunk/include/osgDB/ReaderWriter
r8535 r8577 23 23 24 24 #include <deque> 25 #include <list> 25 26 #include <iosfwd> 26 27 … … 48 49 META_Object(osgDB,ReaderWriter); 49 50 50 virtual bool acceptsExtension(const std::string& /*extension*/) const { return false; } 51 typedef std::map<std::string, std::string> FormatDescriptionMap; 52 53 /** return which protocols are supported by ReaderWriter. */ 54 virtual const FormatDescriptionMap& supportedProtocols() const { return _supportedProtocols; } 55 56 /** return which list of file extensions supported by ReaderWriter. */ 57 virtual const FormatDescriptionMap& supportedExtension() const { return _supportedExtensions; } 58 59 /** return which list of file extensions supported by ReaderWriter. */ 60 virtual const FormatDescriptionMap& supportedOptions() const { return _supportedOptions; } 61 62 /** return true if ReaderWriter accepts specified file extension.*/ 63 virtual bool acceptsExtension(const std::string& /*extension*/) const; 51 64 52 65 /** Options base class used for passing options into plugins to control their operation.*/ … … 305 318 virtual WriteResult writeShader(const osg::Shader& /*shader*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 306 319 320 protected: 321 322 void supportsProtocol(const std::string& fmt, const std::string& description); 323 void supportsExtension(const std::string& fmt, const std::string& description); 324 void supportsOption(const std::string& fmt, const std::string& description); 325 326 FormatDescriptionMap _supportedProtocols; 327 FormatDescriptionMap _supportedExtensions; 328 FormatDescriptionMap _supportedOptions; 307 329 }; 308 330 OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp
r7994 r8577 114 114 std::string osgDB::getLowerCaseFileExtension(const std::string& filename) 115 115 { 116 std::string ext = osgDB::getFileExtension(filename); 117 for(std::string::iterator itr=ext.begin(); 118 itr!=ext.end(); 116 return convertToLowerCase(osgDB::getFileExtension(filename)); 117 } 118 119 std::string osgDB::convertToLowerCase(const std::string& str) 120 { 121 std::string lowcase_str(str); 122 for(std::string::iterator itr=lowcase_str.begin(); 123 itr!=lowcase_str.end(); 119 124 ++itr) 120 125 { 121 126 *itr = tolower(*itr); 122 127 } 123 return ext; 124 } 125 128 return lowcase_str; 129 } 126 130 127 131 // strip one level of extension from the filename. OpenSceneGraph/trunk/src/osgDB/ReaderWriter.cpp
r7908 r8577 13 13 14 14 #include <osgDB/ReaderWriter> 15 #include <osgDB/FileNameUtils> 15 16 #include <osgDB/Archive> 16 17 … … 34 35 { 35 36 } 37 38 bool ReaderWriter::acceptsExtension(const std::string& extension) const 39 { 40 std::string lowercase_ext = convertToLowerCase(extension); 41 return (_supportedExtensions.count(lowercase_ext)!=0); 42 } 43 44 void ReaderWriter::supportsProtocol(const std::string& fmt, const std::string& description) 45 { 46 _supportedProtocols[convertToLowerCase(fmt)] = description; 47 } 48 49 void ReaderWriter::supportsExtension(const std::string& fmt, const std::string& description) 50 { 51 _supportedExtensions[convertToLowerCase(fmt)] = description; 52 } 53 54 void ReaderWriter::supportsOption(const std::string& fmt, const std::string& description) 55 { 56 _supportedOptions[fmt] = description; 57 } OpenSceneGraph/trunk/src/osgPlugins/curl/ReaderWriterCURL.cpp
r8325 r8577 143 143 ReaderWriterCURL::ReaderWriterCURL() 144 144 { 145 //osg::notify(osg::NOTICE)<<"ReaderWriterCURL::ReaderWriterCURL()"<<std::endl; 145 supportsProtocol("http","Read from http port using libcurl."); 146 supportsExtension("curl","Psuedo file extension, used to select curl plugin."); 147 supportsOption("OSG_CURL_PROXY","Specify the http proxy."); 148 supportsOption("OSG_CURL_PROXYPORT","Specify the http proxy oirt."); 146 149 } 147 150 … … 186 189 osg::notify(osg::INFO)<<"ReaderWriterCURL::readFile("<<fullFileName<<")"<<std::endl; 187 190 188 std::string cacheFilePath, cacheFileName;189 191 std::string proxyAddress, optProxy, optProxyPort; 190 192 … … 196 198 { 197 199 int index = opt.find( "=" ); 198 if( opt.substr( 0, index ) == "OSG_FILE_CACHE" ) 199 cacheFilePath = opt.substr( index+1 ); //Setting Cache Directory by OSG Options 200 else if( opt.substr( 0, index ) == "OSG_CURL_PROXY" ) 200 if( opt.substr( 0, index ) == "OSG_CURL_PROXY" ) 201 201 optProxy = opt.substr( index+1 ); 202 202 else if( opt.substr( 0, index ) == "OSG_CURL_PROXYPORT" ) … … 223 223 } 224 224 225 //Getting CURL Environment Variables (If found rewrite OSG Options)226 const char* fileCachePath = getenv("OSG_FILE_CACHE");227 if (fileCachePath) //Env Cache Directory228 cacheFilePath = std::string(fileCachePath);229 230 if (!cacheFilePath.empty())231 {232 cacheFileName = cacheFilePath + "/" +233 osgDB::getServerAddress(fileName) + "/" +234 osgDB::getServerFileName(fileName);235 236 std::string path = osgDB::getFilePath(cacheFileName);237 238 if (!osgDB::fileExists(path) && !osgDB::makeDirectory(path))239 {240 cacheFileName.clear();241 }242 }243 244 #if 0245 if (!cacheFilePath.empty() && osgDB::fileExists(cacheFileName))246 {247 osg::notify(osg::NOTICE) << "Reading cache file " << cacheFileName <<", previous path "<<osgDB::getFilePath(fileName)<<std::endl;248 ReadResult result = osgDB::Registry::instance()->readObject(cacheFileName,options);249 250 return result;251 }252 #endif253 225 254 226 osgDB::ReaderWriter *reader = … … 274 246 std::stringstream buffer; 275 247 276 #if 0277 EasyCurl::StreamObject sp(&buffer, cacheFileName);278 #else279 248 EasyCurl::StreamObject sp(&buffer, std::string()); 280 #endif281 249 282 250 ReadResult curlResult = getEasyCurl().read(proxyAddress, fileName, sp); … … 290 258 291 259 ReadResult readResult = readFile(objectType, reader, buffer, local_opt.get() ); 292 293 #if 0294 if (!cacheFileName.empty() && readResult.success())295 {296 switch(objectType)297 {298 case(NODE):299 osg::notify(osg::NOTICE)<<"Write to cache "<<cacheFileName<<std::endl;300 reader->writeNode(*readResult.getNode(), cacheFileName, local_opt.get());301 break;302 default:303 osg::notify(osg::NOTICE)<<"Curl plugin write to cache not implemented yet"<<std::endl;304 }305 }306 #endif307 260 308 261 local_opt->getDatabasePathList().pop_front(); OpenSceneGraph/trunk/src/osgPlugins/ive/ReaderWriterIVE.cpp
r6753 r8577 14 14 { 15 15 public: 16 17 ReaderWriterIVE() 18 { 19 supportsExtension("ive","OpenSceneGraph native binary format"); 20 } 21 16 22 virtual const char* className() const { return "IVE Reader/Writer"; } 17 23 OpenSceneGraph/trunk/src/osgPlugins/osg/ReaderWriterOSG.cpp
r7447 r8577 17 17 { 18 18 public: 19 20 OSGReaderWriter() 21 { 22 supportsExtension("osg","OpenSceneGraph Ascii file format"); 23 supportsExtension("osgs","Psuedo OpenSceneGraph file loaded, with file encoded in filename string"); 24 supportsOption("precision","Set the floating point precision when writing out files"); 25 supportsOption("OutputTextureFiles","Write out the texture images to file"); 26 } 27 19 28 virtual const char* className() const { return "OSG Reader/Writer"; } 20 21 virtual bool acceptsExtension(const std::string& extension) const22 {23 return equalCaseInsensitive(extension,"osg");24 }25 29 26 30 virtual ReadResult readObject(const std::string& file, const Options* opt) const OpenSceneGraph/trunk/src/osgPlugins/rgb/ReaderWriterRGB.cpp
r8295 r8577 444 444 { 445 445 public: 446 447 ReaderWriterRGB() 448 { 449 supportsExtension("rgb","rgb image format"); 450 supportsExtension("rgba","rgba image format"); 451 supportsExtension("sgi","sgi image format"); 452 supportsExtension("int","int image format"); 453 supportsExtension("inta","inta image format"); 454 supportsExtension("bw","bw image format"); 455 } 456 446 457 virtual const char* className() const { return "RGB Image Reader/Writer"; } 447 458 448 virtual bool acceptsExtension(const std::string& extension) const449 {450 return osgDB::equalCaseInsensitive(extension,"rgb") ||451 osgDB::equalCaseInsensitive(extension,"sgi") ||452 osgDB::equalCaseInsensitive(extension,"rgba") ||453 osgDB::equalCaseInsensitive(extension,"int") ||454 osgDB::equalCaseInsensitive(extension,"inta") ||455 osgDB::equalCaseInsensitive(extension,"bw");456 }457 458 459 ReadResult readRGBStream(std::istream& fin) const 459 460 {
