Added ReaderWriter::fileExists() method to help enable querrying of existing of files on servers using the curl plugin

This commit is contained in:
Robert Osfield
2009-05-13 19:46:16 +00:00
parent 078fe9e84c
commit 122ee0a001
3 changed files with 14 additions and 1 deletions

View File

@@ -142,7 +142,7 @@ class OSGDB_EXPORT Options : public osg::Object
void setPluginStringData(const std::string& s, const std::string& v) const { _pluginStringData[s] = v; }
/** Get a string from the PluginStrData */
std::string getPluginStringData(const std::string& s) { return _pluginStringData[s]; }
std::string& getPluginStringData(const std::string& s) { return _pluginStringData[s]; }
/** Get a value from the PluginData */
const std::string getPluginStringData(const std::string& s) const

View File

@@ -200,6 +200,10 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
typedef osgDB::Options Options;
/** determine if a file exists, normally the default implementation will be approrpiate for local file access
* but with plugins like the libcurl based on it will return true if the file is accessible a server.*/
virtual bool fileExists(const std::string& filename, const Options* options) const;
/** open an archive for reading, writing, or to create an empty archive for writing to.*/
virtual ReadResult openArchive(const std::string& /*fileName*/,ArchiveStatus, unsigned int =4096, const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }

View File

@@ -117,3 +117,12 @@ ReaderWriter::FeatureList ReaderWriter::featureAsString(ReaderWriter::Features f
}
return result;
}
bool ReaderWriter::fileExists(const std::string& filename, const Options* /*options*/) const
{
#ifdef OSG_USE_UTF8_FILENAME
return _waccess( OSGDB_STRING_TO_FILENAME(filename).c_str(), F_OK ) == 0;
#else
return access( filename.c_str(), F_OK ) == 0;
#endif
}