From Farshid Lashkari, "I modified some plugins to use the osgDB file stream functions in order to support UTF-8 encoded filenames."
This commit is contained in:
@@ -702,7 +702,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fil
|
||||
// Do not use the lib3ds_file_open() as:
|
||||
// 1. It relies on FILE* instead of iostreams (less safe)
|
||||
// 2. It doesn't allow us to set a custom log output
|
||||
std::ifstream fin(fileName.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
osgDB::ifstream fin(fileName.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if (!fin.good()) return ReadResult::ERROR_IN_READING_FILE;
|
||||
return doReadNode(fin, options, fileName);
|
||||
/*
|
||||
@@ -1139,7 +1139,7 @@ osgDB::ReaderWriter::WriteResult ReaderWriter3DS::writeNode(const osg::Node& nod
|
||||
if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
osgDB::makeDirectoryForFile(fileName.c_str());
|
||||
std::ofstream fout(fileName.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||
osgDB::ofstream fout(fileName.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||
if (!fout.good()) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
return doWriteNode(node, fout, options, fileName);
|
||||
/*
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
#include "Q3BSPLoad.h"
|
||||
|
||||
#include <osgDB/fstream>
|
||||
|
||||
using namespace bsp;
|
||||
|
||||
|
||||
bool Q3BSPLoad::Load(const std::string& filename, int curveTessellation)
|
||||
{
|
||||
std::ifstream file(filename.c_str(),std::ios::binary);
|
||||
osgDB::ifstream file(filename.c_str(),std::ios::binary);
|
||||
if(!file.is_open())
|
||||
{
|
||||
//errorLog.OutputError("Unable to open %s", filename);
|
||||
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if ( fileName.empty() ) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream stream( fileName.c_str(), std::ios::in|std::ios::binary );
|
||||
osgDB::ifstream stream( fileName.c_str(), std::ios::in|std::ios::binary );
|
||||
if( !stream ) return ReadResult::ERROR_IN_READING_FILE;
|
||||
return readNode( stream, options );
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ReaderWriterDOT : public osgDB::ReaderWriter {
|
||||
return WriteResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
|
||||
std::ofstream o( fileName.c_str(), std::ios_base::out );
|
||||
osgDB::ofstream o( fileName.c_str(), std::ios_base::out );
|
||||
if ( o ) {
|
||||
return writeNode( node, o, options );
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
ReadResult rr = readEXRStream(istream);
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
std::string ext = osgDB::getFileExtension(fileName);
|
||||
if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
osgDB::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
bool success = writeEXRStream(img, fout, fileName);
|
||||
|
||||
@@ -642,7 +642,7 @@ class ReaderWriterGIF : public osgDB::ReaderWriter
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::FILE_NOT_HANDLED;
|
||||
ReadResult rr = readGIFStream(istream);
|
||||
if(rr.validImage()) rr.getImage()->setFileName(file);
|
||||
|
||||
@@ -173,7 +173,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterGZ::readFile(ObjectType objectType,
|
||||
osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
|
||||
local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName));
|
||||
|
||||
std::ifstream fin(fileName.c_str(), std::ios::binary|std::ios::in);
|
||||
osgDB::ifstream fin(fileName.c_str(), std::ios::binary|std::ios::in);
|
||||
if (!fin) return ReadResult::ERROR_IN_READING_FILE;
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ osgDB::ReaderWriter::WriteResult ReaderWriterGZ::writeFile(ObjectType objectType
|
||||
std::stringstream strstream;
|
||||
osgDB::ReaderWriter::WriteResult writeResult = writeFile(objectType, object, rw, strstream, options);
|
||||
|
||||
std::ofstream fout(fullFileName.c_str());
|
||||
osgDB::ofstream fout(fullFileName.c_str());
|
||||
|
||||
write(fout,strstream.str());
|
||||
|
||||
|
||||
@@ -1182,7 +1182,7 @@ public:
|
||||
#else
|
||||
// Only here to help test istream backend. The file version is better because
|
||||
// the filenname.extension could potentially be used by ImageIO to hint what the format type is.
|
||||
std::ifstream istream(full_file_name.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream istream(full_file_name.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::FILE_NOT_HANDLED;
|
||||
ReadResult read_result = readImage(istream);
|
||||
#endif
|
||||
@@ -1274,7 +1274,7 @@ public:
|
||||
#else
|
||||
// Only here to help test ostream backend. The file version is better because
|
||||
// the filenname.extension could potentially be used by ImageIO to hint what the format type is.
|
||||
std::ofstream fout(file_name.c_str(), std::ios::out | std::ios::binary);
|
||||
osgDB::ofstream fout(file_name.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
return writeImage(osg_image, fout, the_options);
|
||||
#endif
|
||||
|
||||
@@ -852,7 +852,7 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::ERROR_IN_READING_FILE;
|
||||
ReadResult rr = readJPGStream(istream);
|
||||
if(rr.validImage()) rr.getImage()->setFileName(file);
|
||||
@@ -872,7 +872,7 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
|
||||
std::string ext = osgDB::getFileExtension(fileName);
|
||||
if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
osgDB::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
return writeImage(img,fout,options);
|
||||
|
||||
@@ -255,7 +255,7 @@ ref_ptr<StateSet> MDLReader::readMaterialFile(std::string materialName)
|
||||
if (!mtlPath.empty())
|
||||
{
|
||||
// Try to open the file, bail out if we fail
|
||||
mtlFile = new std::ifstream(mtlPath.c_str(), std::ifstream::in);
|
||||
mtlFile = new osgDB::ifstream(mtlPath.c_str(), std::ifstream::in);
|
||||
if (!mtlFile)
|
||||
return NULL;
|
||||
}
|
||||
@@ -569,7 +569,7 @@ bool MDLReader::readFile(const std::string & file)
|
||||
|
||||
// Try to open the file
|
||||
fileName = findDataFile(file, CASE_INSENSITIVE);
|
||||
mdlFile = new std::ifstream(fileName.c_str(), std::ios::binary);
|
||||
mdlFile = new osgDB::ifstream(fileName.c_str(), std::ios::binary);
|
||||
if (!mdlFile)
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "MDL file not found" << std::endl;
|
||||
|
||||
@@ -92,7 +92,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterPaths::readObject(const std::string&
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> local_opt = options ? static_cast<osgDB::ReaderWriter::Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
|
||||
local_opt->setPluginStringData("filename",fileName);
|
||||
|
||||
std::ifstream input(fileName.c_str());
|
||||
osgDB::ifstream input(fileName.c_str());
|
||||
|
||||
return readObject(input, local_opt.get());
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#include <string.h>
|
||||
|
||||
#include <osg/Math>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#if defined(_MSC_VER) && defined(OSG_DISABLE_MSVC_WARNINGS)
|
||||
#pragma warning( disable : 4996 )
|
||||
@@ -314,7 +315,7 @@ PlyFile *ply_open_for_writing(
|
||||
|
||||
/* open the file for writing */
|
||||
|
||||
fp = fopen (name, "wb");
|
||||
fp = osgDB::fopen (name, "wb");
|
||||
free (name); //wjs remove memory leak//
|
||||
if (fp == NULL) {
|
||||
return (NULL);
|
||||
@@ -945,7 +946,7 @@ PlyFile *ply_open_for_reading(
|
||||
|
||||
/* open the file for reading */
|
||||
|
||||
fp = fopen (name, "rb");
|
||||
fp = osgDB::fopen (name, "rb");
|
||||
free(name);
|
||||
if (fp == NULL)
|
||||
return (NULL);
|
||||
|
||||
@@ -364,7 +364,7 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::FILE_NOT_HANDLED;
|
||||
ReadResult rr = readPNGStream(istream);
|
||||
if(rr.validImage()) rr.getImage()->setFileName(file);
|
||||
@@ -382,7 +382,7 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
std::string ext = osgDB::getFileExtension(fileName);
|
||||
if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
osgDB::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
return writeImage(img,fout,options);
|
||||
|
||||
@@ -342,7 +342,7 @@ public:
|
||||
|
||||
QuicktimeImportExport importer;
|
||||
|
||||
std::ifstream is;
|
||||
osgDB::ifstream is;
|
||||
is.open (fileName.c_str(), std::ios::binary | std::ios::in );
|
||||
is.seekg (0, std::ios::end);
|
||||
long length = is.tellg();
|
||||
@@ -424,7 +424,7 @@ public:
|
||||
if (cur == extmap.end())
|
||||
return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ofstream os(fileName.c_str(), std::ios::binary | std::ios::trunc | std::ios::out);
|
||||
osgDB::ofstream os(fileName.c_str(), std::ios::binary | std::ios::trunc | std::ios::out);
|
||||
if(os.good())
|
||||
{
|
||||
QuicktimeImportExport exporter;
|
||||
|
||||
@@ -26,7 +26,7 @@ class ReaderWriterFreeType : public osgDB::ReaderWriter
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream fin(fileName.c_str());
|
||||
osgDB::ifstream fin(fileName.c_str());
|
||||
|
||||
if (ext=="revisions") return readRevisions(fin, file, options);
|
||||
else return readFileList(fin, file, options);
|
||||
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
{
|
||||
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl;
|
||||
} else {
|
||||
m_f = new std::ofstream(m_fout.c_str());
|
||||
m_f = new osgDB::ofstream(m_fout.c_str());
|
||||
*m_f << "solid " << counter << std::endl;
|
||||
}
|
||||
};
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
|
||||
if (m_options && (m_options->getOptionString() == "separateFiles")) {
|
||||
std::string sepFile = m_fout + i2s(counter);
|
||||
m_f = new std::ofstream(sepFile.c_str());
|
||||
m_f = new osgDB::ofstream(sepFile.c_str());
|
||||
*m_f << "solid " << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -868,7 +868,7 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::FILE_NOT_HANDLED;
|
||||
ReadResult rr = readTIFStream(istream);
|
||||
if(rr.validImage()) rr.getImage()->setFileName(file);
|
||||
@@ -886,7 +886,7 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter
|
||||
std::string ext = osgDB::getFileExtension(fileName);
|
||||
if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
osgDB::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
return writeImage(img,fout,options);
|
||||
|
||||
@@ -194,7 +194,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterVRML2::readNode(const std::string& f
|
||||
resource_fetcher fetcher;
|
||||
openvrml::browser *b = new openvrml::browser(fetcher, null, null);
|
||||
|
||||
std::ifstream vrml_stream(fileName.c_str());
|
||||
osgDB::ifstream vrml_stream(fileName.c_str());
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -742,7 +742,7 @@ public:
|
||||
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream stream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
osgDB::ifstream stream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!stream) return ReadResult::FILE_NOT_HANDLED;
|
||||
ReadResult rr = readImage(stream, options);
|
||||
if(rr.validImage()) rr.getImage()->setFileName(file);
|
||||
@@ -784,7 +784,7 @@ public:
|
||||
std::string ext = osgDB::getFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ofstream fout(file.c_str(), std::ios::out | std::ios::binary);
|
||||
osgDB::ofstream fout(file.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
return writeImage(image,fout,options);
|
||||
|
||||
@@ -52,7 +52,7 @@ class ReaderWriterZIP : public osgDB::ReaderWriter
|
||||
osg::notify(osg::INFO)<<"ReaderWriterZIP::readNode( "<<fileName.c_str()<<" )\n";
|
||||
|
||||
// First open file as stream
|
||||
std::ifstream srcFileStrm(fileName.c_str(),std::ios::in|std::ios::binary);
|
||||
osgDB::ifstream srcFileStrm(fileName.c_str(),std::ios::in|std::ios::binary);
|
||||
if (!srcFileStrm.fail())
|
||||
{
|
||||
// Now read entire zip file into stream buffer
|
||||
|
||||
Reference in New Issue
Block a user