From Michael Platings, Converted std::fstream/ifstream/ofstream to osgDB::fstream/ifstream/ofstream and

fopen to osgDB::fopen to facilitate support for wide character filenames using UT8 encoding.
This commit is contained in:
Robert Osfield
2008-11-07 15:08:08 +00:00
parent 0ccf7d8383
commit 720551d549
76 changed files with 516 additions and 161 deletions

View File

@@ -4,6 +4,7 @@
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/Registry>
#include <iostream>
@@ -37,7 +38,7 @@ class ReaderWriter3DC : public osgDB::ReaderWriter
const int LINE_SIZE = 1024;
char line[LINE_SIZE];
std::ifstream fin(fileName.c_str());
osgDB::ifstream fin(fileName.c_str());
unsigned int num = 0;
while (fin)
@@ -74,7 +75,7 @@ class ReaderWriter3DC : public osgDB::ReaderWriter
fin.close();
std::ifstream fin2(fileName.c_str());
osgDB::ifstream fin2(fileName.c_str());
while (fin2)
{
fin2.getline(line,LINE_SIZE);

View File

@@ -37,6 +37,8 @@
#include <dmalloc.h>
#endif
#include <osgDB/FileUtils>
/*!
* \defgroup file Files
@@ -68,7 +70,7 @@ lib3ds_file_load(const char *filename)
FILE *f;
Lib3dsFile *file;
f=fopen(filename, "rb");
f=osgDB::fopen(filename, "rb");
if (!f) {
return(0);
}
@@ -106,7 +108,7 @@ lib3ds_file_save(Lib3dsFile *file, const char *filename)
{
FILE *f;
f=fopen(filename, "wb");
f=osgDB::fopen(filename, "wb");
if (!f) {
return(LIB3DS_FALSE);
}

View File

@@ -505,7 +505,7 @@ FltExportVisitor::complete( const osg::Node& node )
// Copy record data temp file into final OpenFlight file.
// Yee-uck. TBD need better stream copy routine.
char buf;
std::ifstream recIn;
osgDB::ifstream recIn;
recIn.open( _recordsTempName.c_str(), std::ios::in | std::ios::binary );
while (!recIn.eof() )
{

View File

@@ -20,7 +20,7 @@
#include <osg/NodeVisitor>
#include "ExportOptions.h"
#include "Types.h"
#include <fstream>
#include <osgDB/fstream>
#include <set>
#include <memory>
@@ -168,7 +168,7 @@ private:
// _records is a temp file for most records. After the Header and palette
// records are written to _dos, _records is copied onto _dos.
std::ofstream _recordsStr;
osgDB::ofstream _recordsStr;
DataOutputStream* _records;
std::string _recordsTempName;

View File

@@ -67,7 +67,7 @@ ReaderWriter::ReadResult ReaderWriterATTR::readObject(const std::string& file, c
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream fin;
osgDB::ifstream fin;
fin.imbue(std::locale::classic());
fin.open(fileName.c_str(), std::ios::in | std::ios::binary);
@@ -209,7 +209,7 @@ ReaderWriterATTR::writeObject(const osg::Object& object, const std::string& file
return WriteResult::FILE_NOT_HANDLED;
}
std::ofstream fOut;
osgDB::ofstream fOut;
fOut.open( fileName.c_str(), std::ios::out | std::ios::binary );
if ( fOut.fail())

View File

@@ -183,7 +183,7 @@ class FLTReaderWriter : public ReaderWriter
// read file
{
std::ifstream istream;
osgDB::ifstream istream;
istream.imbue(std::locale::classic());
istream.open(fileName.c_str(), std::ios::in | std::ios::binary);
@@ -441,7 +441,7 @@ class FLTReaderWriter : public ReaderWriter
if (!filePath.empty())
_implicitPath = filePath;
std::ofstream fOut;
osgDB::ofstream fOut;
fOut.open( fileName.c_str(), std::ios::out | std::ios::binary );
if ( fOut.fail())
{

View File

@@ -158,7 +158,7 @@ VertexPaletteManager::write( DataOutputStream& dos ) const
// Open that temp file again, this time for reading.
// Then copy to dos.
char buf;
std::ifstream vertIn;
osgDB::ifstream vertIn;
vertIn.open( _verticesTempName.c_str(), std::ios::in | std::ios::binary );
while (!vertIn.eof() )
{

View File

@@ -21,7 +21,7 @@
#include "DataOutputStream.h"
#include "ExportOptions.h"
#include <osg/Array>
#include <fstream>
#include <osgDB/fstream>
#include <map>
namespace osg {
@@ -96,7 +96,7 @@ protected:
typedef std::map< const osg::Array*, ArrayInfo > ArrayMap;
ArrayMap _arrayMap;
mutable std::ofstream _verticesStr;
mutable osgDB::ofstream _verticesStr;
DataOutputStream* _vertices;
std::string _verticesTempName;

View File

@@ -33,6 +33,7 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include "Exception.h"
#include "Geode.h"
@@ -89,7 +90,7 @@ class ReaderWriterAC : public osgDB::ReaderWriter
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
// allocate per file data and start reading
std::ifstream fin;
osgDB::ifstream fin;
fin.open(fileName.c_str(), std::ios::in);
if (!fin.is_open()) return ReadResult::FILE_NOT_FOUND;
@@ -124,7 +125,7 @@ class ReaderWriterAC : public osgDB::ReaderWriter
std::vector<unsigned int>iNumMaterials;
const_cast<osg::Node&>(node).accept(vs); // this parses the tree to streamd Geodes
std::vector<const osg::Geode *> glist=vs.getGeodes();
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
osgDB::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
// Write out the file header
std::vector<const osg::Geode *>::iterator itr;
fout << "AC3Db" << std::endl;

View File

@@ -7,6 +7,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
typedef int int32;
@@ -382,7 +383,7 @@ class ReaderWriterBMP : 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 = readBMPStream(istream);
if(rr.validImage()) rr.getImage()->setFileName(file);
@@ -492,7 +493,7 @@ class ReaderWriterBMP : 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;
bool success = WriteBMPStream(img, fout, fileName);

View File

@@ -15,6 +15,8 @@
#include <osg/ref_ptr>
#include <osg/io_utils>
#include <osgDB/FileUtils>
#if defined(WIN32) && !defined(__CYGWIN__)
#include <io.h>
#include <windows.h>
@@ -573,11 +575,6 @@ void CameraConfig::scaleCameraOffset( osg::Matrix::value_type x, osg::Matrix::va
memcpy( _offset_matrix, m.ptr(), sizeof( osg::Matrix::value_type[16] ));
}
bool CameraConfig::fileExists(const std::string& filename)
{
return access( filename.c_str(), F_OK ) == 0;
}
// Order of precedence:
//
std::string CameraConfig::findFile( std::string filename )
@@ -590,23 +587,23 @@ std::string CameraConfig::findFile( std::string filename )
if( ptr != NULL )
{
path = std::string(ptr) + '/' + filename;
if( fileExists(path))
if( osgDB::fileExists(path))
return path;
}
// Check standard location(s)
//path.clear();
path = std::string( "/usr/local/share/Producer/Config/") + filename;
if( fileExists(path) )
if( osgDB::fileExists(path) )
return path;
//path.clear();
path = std::string( "/usr/share/Producer/Config/") + filename;
if( fileExists(path) )
if( osgDB::fileExists(path) )
return path;
// Check local directory
if(fileExists(filename))
if(osgDB::fileExists(filename))
return filename;
// Fail

View File

@@ -231,8 +231,6 @@ class CameraConfig : public osg::Referenced
unsigned int getNumberOfScreens();
static bool fileExists(const std::string& );
osg::Matrix::value_type _offset_matrix[16];
osg::Matrix::value_type _offset_shearx, _offset_sheary;

View File

@@ -221,9 +221,10 @@
#define SUPPORT_CPP 1
#endif
#include <osgDB/fstream>
#include <string.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include "FlexLexer.h"
@@ -2283,7 +2284,7 @@ bool CameraConfig::parseFile( const std::string &file )
else
#endif
{
std::ifstream ifs(fileName.c_str());
osgDB::ifstream ifs(fileName.c_str());
flexer = new yyFlexLexer(&ifs);
cfg = this;
retval = ConfigParser_parse() == 0 ? true : false;

View File

@@ -23,6 +23,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <iomanip>
#include <stdio.h>
@@ -954,7 +955,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);
@@ -996,7 +997,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);

View File

@@ -828,7 +828,7 @@ class ReaderWriterDW : public osgDB::ReaderWriter
FILE *fp;
if( (fp = fopen( fileName.c_str(), "r" )) == (FILE *)0L )
if( (fp = osgDB::fopen( fileName.c_str(), "r" )) == (FILE *)0L )
{
return std::string("Unable to open file \""+fileName+"\"");
}

View File

@@ -17,13 +17,14 @@
#ifndef DXF_READER
#define DXF_READER 1
#include <fstream>
#include <string>
#include <sstream>
#include <osg/Referenced>
#include <osg/ref_ptr>
#include <osgDB/fstream>
class codeValue;
/// readerBase. abstract base class for reading a dxf file
@@ -86,7 +87,7 @@ protected:
};
/// dxfReader. gets you through the dxf file, one group code/value pair at a time.
/// just instanciate, openFile(), then loop while(nextGroupCode())
/// just instantiate, openFile(), then loop while(nextGroupCode())
class dxfReader : public osg::Referenced
{
public:
@@ -95,7 +96,7 @@ public:
bool openFile(std::string fileName);
bool nextGroupCode(codeValue& cv);
protected:
std::ifstream _ifs;
osgDB::ifstream _ifs;
osg::ref_ptr<readerBase> _reader;
};

View File

@@ -33,6 +33,7 @@
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
@@ -397,7 +398,7 @@ class ReaderGEO
osgDB::ReaderWriter::ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options)
{
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.is_open() )
{ // read the input file.
// code for setting up the database path so that internally referenced file are searched for on relative paths.

View File

@@ -5,6 +5,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
class ReaderWriterGLSL : public osgDB::ReaderWriter
@@ -58,7 +59,7 @@ class ReaderWriterGLSL : 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 = readShader(istream, options);
if(rr.validShader()) rr.getShader()->setFileName(file);
@@ -82,7 +83,7 @@ class ReaderWriterGLSL : 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 writeShader(shader, fout);

View File

@@ -34,6 +34,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <stdio.h>
#include <assert.h>
@@ -189,7 +190,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);

View File

@@ -32,6 +32,8 @@
#include <memory.h>
#include <stdio.h>
#include <osgDB/FileUtils>
typedef unsigned char RGBE[4];
#define R 0
#define G 1
@@ -49,7 +51,7 @@ static bool oldDecrunch(RGBE *scanline, int len, FILE *file);
bool HDRLoader::isHDRFile(const char *_fileName)
{
FILE *file;
file = fopen(_fileName, "rb");
file = osgDB::fopen(_fileName, "rb");
if (!file)
return false;
@@ -69,7 +71,7 @@ bool HDRLoader::load(const char *_fileName, const bool _rawRGBE, HDRLoaderResult
char str[200];
FILE *file;
file = fopen(_fileName, "rb");
file = osgDB::fopen(_fileName, "rb");
if (!file)
return false;

View File

@@ -112,8 +112,8 @@
#include <osg/Notify>
#include <osg/io_utils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <fstream>
#include <sstream>
using namespace ive;
@@ -1424,7 +1424,7 @@ void DataOutputStream::writeImage(IncludeImageMode mode, osg::Image *image)
// Include image file in stream
if(image && !(image->getFileName().empty())) {
std::string fullPath = osgDB::findDataFile(image->getFileName(),_options.get());
std::ifstream infile(fullPath.c_str(), std::ios::in | std::ios::binary);
osgDB::ifstream infile(fullPath.c_str(), std::ios::in | std::ios::binary);
if(infile) {
//Write filename

View File

@@ -5,6 +5,7 @@
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/Registry>
using namespace osg;
@@ -51,7 +52,7 @@ class ReaderWriterIVE : public ReaderWriter
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 istream(fileName.c_str(), std::ios::in | std::ios::binary);
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
return readImage(istream, local_opt.get());
}
@@ -67,7 +68,7 @@ class ReaderWriterIVE : public ReaderWriter
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 istream(fileName.c_str(), std::ios::in | std::ios::binary);
osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
return readNode(istream,local_opt.get());
}
@@ -121,7 +122,7 @@ class ReaderWriterIVE : public ReaderWriter
osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
if(local_opt->getDatabasePathList().empty())
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
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;
WriteResult result = writeImage(image, fout, local_opt.get());
fout.close();
@@ -138,7 +139,7 @@ class ReaderWriterIVE : public ReaderWriter
if(local_opt->getDatabasePathList().empty())
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
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;
WriteResult result = writeNode(node, fout, local_opt.get());

View File

@@ -230,7 +230,7 @@ class LOGOReaderWriter : public osgDB::ReaderWriter
Logos::RelativePosition pos = Logos::LowerRight;
FILE *fp;
if( (fp = fopen( fileName.c_str(), "r")) == NULL )
if( (fp = osgDB::fopen( fileName.c_str(), "r")) == NULL )
return NULL;
while( !feof(fp))
{

View File

@@ -15,11 +15,10 @@
#include <osg/LightModel>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include "lwo2parser.h"
#include <fstream>
using namespace lwosg;
namespace
@@ -268,7 +267,7 @@ osg::Group *Converter::convert(const std::string &filename)
std::string file = osgDB::findDataFile(filename, db_options_.get());
if (file.empty()) return 0;
std::ifstream ifs(file.c_str(), std::ios_base::in | std::ios_base::binary);
osgDB::ifstream ifs(file.c_str(), std::ios_base::in | std::ios_base::binary);
if (!ifs.is_open()) return 0;
std::vector<char> buffer;

View File

@@ -29,7 +29,6 @@
#include <vector>
#include <map>
#include <string>
#include <fstream>
#include <osg/Referenced>
#include <osg/Vec2>
@@ -38,6 +37,8 @@
#include <osg/Group>
#include <osg/Notify>
#include <osgDB/fstream>
using namespace osg;
using namespace std;
@@ -64,7 +65,7 @@ class Lwo2
Lwo2Layer* _current_layer;
vector< string > _tags;
vector< string > _images;
ifstream _fin;
osgDB::ifstream _fin;
unsigned char _read_char();
unsigned short _read_short();

View File

@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include <osgDB/FileUtils>
#define MK_ID(a,b,c,d) ((((guint32)(a))<<24)| \
(((guint32)(b))<<16)| \
(((guint32)(c))<< 8)| \
@@ -326,7 +328,7 @@ static void read_pnts(FILE *f, gint nbytes, lwObject *lwo)
gint lw_is_lwobject(const char *lw_file)
{
FILE *f = fopen(lw_file, "rb");
FILE *f = osgDB::fopen(lw_file, "rb");
if (f) {
gint32 form = read_long(f);
gint32 nlen = read_long(f);
@@ -348,7 +350,7 @@ lwObject *lw_object_read(const char *lw_file, std::ostream& output)
gint32 read_bytes = 0;
/* open file */
f = fopen(lw_file, "rb");
f = osgDB::fopen(lw_file, "rb");
if (f == NULL) {
output << "can't open file "<<lw_file<<std::endl;
return NULL;

View File

@@ -14,10 +14,10 @@
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/fstream>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <fstream>
#include <sstream>
using namespace lwosg;
@@ -92,7 +92,7 @@ osg::Group *SceneLoader::load(const std::string &filename, const osgDB::ReaderWr
fname = filename;
}
std::ifstream ifs(fname.c_str());
osgDB::ifstream ifs(fname.c_str());
if (!ifs.is_open()) return 0;
clear();

View File

@@ -38,6 +38,7 @@
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/fstream>
#include <osgUtil/TriStripVisitor>
#include <osgUtil/SmoothingVisitor>
@@ -80,14 +81,14 @@ public:
if (!acceptsExtension(osgDB::getFileExtension(fileName)))
return WriteResult(WriteResult::FILE_NOT_HANDLED);
std::ofstream f(fileName.c_str());
osgDB::ofstream f(fileName.c_str());
std::string materialFile = osgDB::getNameLessExtension(fileName) + ".mtl";
OBJWriterNodeVisitor nv(f, osgDB::getSimpleFileName(materialFile));
// we must cast away constness
(const_cast<osg::Node*>(&node))->accept(nv);
std::ofstream mf(materialFile.c_str());
osgDB::ofstream mf(materialFile.c_str());
nv.writeMaterials(mf);
return WriteResult(WriteResult::FILE_SAVED);
@@ -668,7 +669,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream fin(fileName.c_str());
osgDB::ifstream fin(fileName.c_str());
if (fin)
{

View File

@@ -13,7 +13,6 @@
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <stdio.h>
@@ -23,6 +22,7 @@
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/fstream>
using namespace obj;
@@ -597,7 +597,7 @@ bool Model::readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* optio
osg::notify(osg::INFO) << "--" << fullPathFileName << "--" << std::endl;
if (!fullPathFileName.empty())
{
std::ifstream mfin( fullPathFileName.c_str() );
osgDB::ifstream mfin( fullPathFileName.c_str() );
if (mfin)
{
readMTL(mfin);

View File

@@ -6,6 +6,7 @@
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
#include "osgDB/fstream"
#include "Matrix.h"
@@ -83,7 +84,7 @@ bool FragmentProgram_readLocalData(Object& obj, Input& fr)
fr += 2;
iteratorAdvanced = true;
ifstream vfstream( filename.c_str() );
osgDB::ifstream vfstream( filename.c_str() );
if( vfstream ) {
ostringstream vstream;

View File

@@ -6,6 +6,7 @@
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
@@ -47,7 +48,7 @@ class OSGReaderWriter : public ReaderWriter
osg::ref_ptr<Options> local_opt = opt ? static_cast<Options*>(opt->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName));
std::ifstream fin(fileName.c_str());
osgDB::ifstream fin(fileName.c_str());
if (fin)
{
return readObject(fin, local_opt.get());
@@ -108,7 +109,7 @@ class OSGReaderWriter : public ReaderWriter
osg::ref_ptr<Options> local_opt = opt ? static_cast<Options*>(opt->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName));
std::ifstream fin(fileName.c_str());
osgDB::ifstream fin(fileName.c_str());
if (fin)
{
return readNode(fin, local_opt.get());

View File

@@ -6,6 +6,7 @@
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
#include "osgDB/fstream"
#include "Matrix.h"
@@ -85,7 +86,7 @@ bool VertexProgram_readLocalData(Object& obj, Input& fr)
fr+=2;
iteratorAdvanced = true;
ifstream vfstream( filename.c_str() );
osgDB::ifstream vfstream( filename.c_str() );
if( vfstream )
{

View File

@@ -57,7 +57,7 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter
osg::ref_ptr<Options> local_opt = opt ? static_cast<Options*>(opt->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
std::ifstream fin(fileName.c_str());
osgDB::ifstream fin(fileName.c_str());
if (fin)
{
return readNode(fin, local_opt.get());

View File

@@ -66,7 +66,7 @@ public:
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
// code for setting up the database path so that internally referenced file are searched for on relative paths.
std::ifstream fin(fileName.c_str());
osgDB::ifstream fin(fileName.c_str());
if (fin)
{
return readObject(fin, options);

View File

@@ -95,7 +95,7 @@ class OSGA_Archive : public osgDB::Archive
mutable OpenThreads::ReentrantMutex _serializerMutex;
class IndexBlock;
class IndexBlock;
friend class IndexBlock;
class IndexBlock : public osg::Referenced
@@ -177,7 +177,7 @@ class OSGA_Archive : public osgDB::Archive
const osgDB::ReaderWriter::Options* _options;
};
protected:
protected:
struct ReadObjectFunctor;
struct ReadImageFunctor;
struct ReadHeightFieldFunctor;
@@ -204,8 +204,8 @@ class OSGA_Archive : public osgDB::Archive
static float s_currentSupportedVersion;
float _version;
ArchiveStatus _status;
std::ifstream _input;
std::fstream _output;
osgDB::ifstream _input;
osgDB::fstream _output;
std::string _masterFileName;
IndexBlockList _indexBlockList;

View File

@@ -108,7 +108,7 @@ int *numComponents_ret)
unsigned char palette[256][3];
unsigned char * tmpbuf, * buffer, * ptr;
FILE *fp = fopen(filename, "rb");
FILE *fp = osgDB::fopen(filename, "rb");
if (!fp) return NULL;
picerror = ERROR_NO_ERROR;

View File

@@ -8,6 +8,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <stdio.h>
@@ -273,7 +274,7 @@ class ReaderWriterPNM : public osgDB::ReaderWriter
int max_value = 0;
// Open file.
fp = fopen(fileName.c_str(), "rb");
fp = osgDB::fopen(fileName.c_str(), "rb");
// Read header items.
int row;
@@ -476,7 +477,7 @@ class ReaderWriterPNM : public osgDB::ReaderWriter
// only support rgb images right now.
if (image.getPixelFormat()!=GL_RGB || image.getDataType()!=GL_UNSIGNED_BYTE) return WriteResult("Error image pixel format not supported by pnm writer.");
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(image,fout,options);

View File

@@ -523,7 +523,7 @@ class ReaderWriterRGB : 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 = readRGBStream(istream);
if(rr.validImage()) rr.getImage()->setFileName(file);
@@ -655,7 +655,7 @@ class ReaderWriterRGB : 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 writeRGBStream(img,fout,fileName);

View File

@@ -1,5 +1,6 @@
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/Registry>
#include <osgTerrain/Locator>
@@ -80,7 +81,7 @@ class ESRIShapeReaderWriter : public osgDB::ReaderWriter
std::string projFileName(osgDB::getNameLessExtension(fileName) + ".prj");
if (osgDB::fileExists(projFileName))
{
std::ifstream fin(projFileName.c_str());
osgDB::ifstream fin(projFileName.c_str());
if (fin)
{
std::string projstring;

View File

@@ -119,7 +119,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& fil
osg::notify(osg::INFO) << "ReaderWriterSTL::readNode(" << fileName.c_str() << ")\n";
// determine ASCII vs. binary mode
FILE* fp = fopen(fileName.c_str(), "rb");
FILE* fp = osgDB::fopen(fileName.c_str(), "rb");
if (!fp) {
return ReadResult::FILE_NOT_FOUND;
}
@@ -169,7 +169,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& fil
if (!isBinary)
{
fclose(fp);
fp = fopen(fileName.c_str(), "r");
fp = osgDB::fopen(fileName.c_str(), "r");
}
// read

View File

@@ -6,6 +6,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <stdio.h>
#include <assert.h>
@@ -535,7 +536,7 @@ class ReaderWriterTGA : 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 = readTGAStream(istream);
if(rr.validImage()) rr.getImage()->setFileName(file);

View File

@@ -11,10 +11,9 @@
* OpenSceneGraph Public License for more details.
*/
#include <fstream>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/Registry>
#include <osg/Notify>
@@ -38,7 +37,7 @@ class ReaderWriterTXF : public osgDB::ReaderWriter
std::string fileName = osgDB::findDataFile(file, options);
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream stream;
osgDB::ifstream stream;
stream.open(fileName.c_str(), std::ios::in | std::ios::binary);
if (!stream.is_open()) return ReadResult::FILE_NOT_FOUND;

View File

@@ -16,6 +16,7 @@
#include <osgDB/FileUtils>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/fstream>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgSim/Sector>
@@ -23,7 +24,6 @@
#include <osgSim/LightPointNode>
#include <osgSim/BlinkSequence>
#include <iostream>
#include <fstream>
#if defined(linux)
# include <unistd.h>
@@ -599,7 +599,7 @@ bool TXPArchive::loadTextStyles()
std::map< std::string, std::string > fontmap;
std::string fmapfname = std::string(getDir())+"\\fontmap.txt";
std::ifstream fmapfile;
osgDB::ifstream fmapfile;
fmapfile.open(fmapfname.c_str(),std::ios::in);
if (fmapfile.is_open())

View File

@@ -13,6 +13,8 @@
************************
*/
#include <osgDB/FileUtils>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -75,7 +77,7 @@ trpgFilePrintBuffer::trpgFilePrintBuffer(FILE *inFp)
trpgFilePrintBuffer::trpgFilePrintBuffer(char *file)
{
isMine = true;
fp = fopen(file,"w");
fp = osgDB::fopen(file,"w");
valid = fp != NULL;
}

View File

@@ -13,6 +13,8 @@
************************
*/
#include <osgDB/FileUtils>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -64,7 +66,7 @@ bool trpgr_Archive::OpenFile(const char *name)
CloseFile();
if (!(fp = fopen(file,"rb")))
if (!(fp = osgDB::fopen(file,"rb")))
return false;
// Look for a magic # and endianness
@@ -138,7 +140,7 @@ bool trpgr_Archive::ReadSubArchive(int row, int col, trpgEndian cpuNess)
//open the block archive
// the block archive will be in the base dir + \\cols\\row\\archive.txp
sprintf(blockpath,"%s%s%d%s%d%sarchive.txp",dir,PATHSEPERATOR,col,PATHSEPERATOR,row,PATHSEPERATOR);
FILE *bfp = fopen(blockpath,"rb");
FILE *bfp = osgDB::fopen(blockpath,"rb");
if(!bfp) {
return false;
}
@@ -383,7 +385,7 @@ bool trpgr_Archive::ReadExternalTile(uint32 x,uint32 y,uint32 lod,trpgMemReadBuf
// Open the file and read the contents
FILE *fp= 0;
try {
if (!(fp = fopen(filename,"rb"))) {
if (!(fp = osgDB::fopen(filename,"rb"))) {
throw 1;
}

View File

@@ -12,6 +12,9 @@
Tel: (520) 323-7990
************************
*/
#include <osgDB/FileUtils>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -465,7 +468,7 @@ void trpgrAppFile::Init(trpgEndian inNess,const char *fileName)
ness = inNess;
cpuNess = trpg_cpu_byte_order();
if (!(fp = fopen(fileName,"rb")))
if (!(fp = osgDB::fopen(fileName,"rb")))
return;
valid = true;

View File

@@ -13,6 +13,8 @@
************************
*/
#include <osgDB/FileUtils>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -410,7 +412,7 @@ bool trpgwArchive::OpenFile(const char *in_dir,const char *name)
sprintf(filename,"%s" PATHSEPERATOR "%s",dir,name);
if (!(fp = fopen(filename,"wb")))
if (!(fp = osgDB::fopen(filename,"wb")))
return false;
return true;
@@ -831,7 +833,7 @@ bool trpgwArchive::WriteTile(unsigned int x,unsigned int y,unsigned int lod, flo
char filename[1024];
// Note: Windows specific
sprintf(filename,"%s" PATHSEPERATOR "tile_%d_%d_%d.tpt",dir,x,y,lod);
if (!(tfp = fopen(filename,"wb")))
if (!(tfp = osgDB::fopen(filename,"wb")))
return false;
// Write the header first

View File

@@ -13,6 +13,8 @@
************************
*/
#include <osgDB/FileUtils>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -342,12 +344,12 @@ void trpgwAppFile::Init(trpgEndian inNess,const char *fileName,bool reuse)
cpuNess = trpg_cpu_byte_order();
if (reuse==false) {
if (!(fp = fopen(fileName,"wb")))
if (!(fp = osgDB::fopen(fileName,"wb")))
return;
lengthSoFar = 0;
valid = true;
} else {
if (!(fp = fopen(fileName,"ab")))
if (!(fp = osgDB::fopen(fileName,"ab")))
return;
// ftell is still zero, dammit. Arg.
fseek(fp,0,SEEK_END);

View File

@@ -35,6 +35,7 @@
#include <math.h>
#include <osg/Notify>
#include <osgDB/fstream>
using namespace DX;
using namespace std;
@@ -63,7 +64,7 @@ bool Object::load(const char* filename)
if (!filename)
return false;
ifstream fin(filename);
osgDB::ifstream fin(filename);
if (fin.bad()) {
osg::notify(osg::WARN) << "Object::load: Unable to open: " << filename << endl;
return false;