Added ReaderWriter::fileExists() method to help enable querrying of existing of files on servers using the curl plugin
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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); }
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user