Exemplo n.º 1
0
ReaderWriter::WriteResult FileCache::writeObject(const osg::Object& object, const std::string& originalFileName, const osgDB::Options* options) const
{
    std::string cacheFileName = createCacheFileName(originalFileName);
    if (!cacheFileName.empty())
    {
        std::string path = osgDB::getFilePath(cacheFileName);

        if (!osgDB::fileExists(path) && !osgDB::makeDirectory(path))
        {
            OSG_NOTICE<<"Could not create cache directory: "<<path<<std::endl;
            return ReaderWriter::WriteResult::ERROR_IN_WRITING_FILE;
        }

        OSG_INFO<<"FileCache::writeObjectToCache("<<originalFileName<<") as "<<cacheFileName<<std::endl;
        ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeObject(object, cacheFileName, options);
        if (result.success())
        {
            removeFileFromBlackListed(originalFileName);
        }
        return result;
    }
    return ReaderWriter::WriteResult::FILE_NOT_HANDLED;
}
Exemplo n.º 2
0
bool osgDB::writeScriptFile(const Script& image,const std::string& filename, const Options* options )
{
    ReaderWriter::WriteResult wr = Registry::instance()->writeScript( image, filename, options );
    if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
    return wr.success();
}
Exemplo n.º 3
0
bool osgDB::writeShaderFile(const Shader& shader,const std::string& filename, const Options* options )
{
    ReaderWriter::WriteResult wr = Registry::instance()->writeShader( shader, filename, options );
    if (!wr.success()) OSG_WARN << "Error writing file " << filename << ": " << wr.statusMessage() << std::endl;
    return wr.success();
}