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

@@ -3,13 +3,13 @@
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/fstream>
#include <iostream>
#include <fstream>
void writeShader(osg::Shader* shader, const std::string& cppFileName, const std::string& variableName)
{
std::ofstream fout(cppFileName.c_str());
osgDB::ofstream fout(cppFileName.c_str());
if (!fout)
{
std::cout<<"Error: could not open file `"<<cppFileName<<"` for writing."<<std::endl;

View File

@@ -9,18 +9,18 @@
#include <assert.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <osg/Geometry>
#include <osg/Geode>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
bool Utility::readFile(const char* fName, std::string& s)
{
std::string foundFile = osgDB::findDataFile(fName);
if (foundFile.empty()) return false;
std::ifstream is;//(fName);
osgDB::ifstream is;//(fName);
is.open(foundFile.c_str());
if (is.fail())
{
@@ -73,7 +73,7 @@ double Utility::getNoise(unsigned x, unsigned y, unsigned random)
int n = x + y * 57 + random * 131;
n = (n<<13) ^ n;
double noise = (1.0f - ( (n * (n * n * 15731 + 789221) +
1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);
1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);
return noise;
}
@@ -86,13 +86,13 @@ double Utility::smoothNoise(unsigned width, unsigned height, unsigned x, unsigne
return noise[x + y*width];
double corners = (noise[x-1 + (y-1) *width]
+noise[x+1 + (y-1)*width]
+noise[x-1 + (y+1) * width]
+noise[x+1 + (y+1) * width]) / 16.0;
+noise[x+1 + (y-1)*width]
+noise[x-1 + (y+1) * width]
+noise[x+1 + (y+1) * width]) / 16.0;
double sides = (noise[x-1 + y*width]
+noise[x+1 + y*width]
+noise[x + (y-1)*width]
+noise[x + (y+1)*width]) / 8.0;
+noise[x+1 + y*width]
+noise[x + (y-1)*width]
+noise[x + (y+1)*width]) / 8.0;
double center = noise[x + y*width] / 4.0;
return corners + sides + center;

View File

@@ -21,7 +21,6 @@
#include <iostream>
#include <list>
#include <string>
#include <fstream>
#include <sstream>
#include <osg/Geode>
@@ -48,6 +47,7 @@
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
int runApp(std::string xapp);
@@ -249,7 +249,7 @@ void readConfFile(const char* confFile)
}
std::ifstream in(fileName.c_str());
osgDB::ifstream in(fileName.c_str());
if (!in)
{
osg::notify(osg::INFO) << "File " << fileName << " can not be opened!" << std::endl;

View File

@@ -21,10 +21,10 @@
#include <osg/GLU>
#include <osg/Notify>
#include <osgDB/ReadFile>
#include <osgDB/fstream>
#include <osg/GraphicsContext>
#include <fstream>
#include <iostream>
@@ -78,7 +78,7 @@ PhotoArchive::PhotoArchive(const std::string& filename)
bool PhotoArchive::readPhotoIndex(const std::string& filename)
{
std::ifstream in(filename.c_str());
osgDB::ifstream in(filename.c_str());
char* fileIndentifier = new char [FILE_IDENTIFER.size()];
in.read(fileIndentifier,FILE_IDENTIFER.size());
@@ -124,7 +124,7 @@ osg::Image* PhotoArchive::readImage(const std::string& filename,
target_t <= photoHeader.thumbnail_t &&
photoHeader.thumbnail_position != 0)
{
std::ifstream in(_archiveFileName.c_str(),std::ios::in | std::ios::binary);
osgDB::ifstream in(_archiveFileName.c_str(),std::ios::in | std::ios::binary);
// find image
in.seekg(photoHeader.thumbnail_position);
@@ -150,7 +150,7 @@ osg::Image* PhotoArchive::readImage(const std::string& filename,
photoHeader.fullsize_t &&
photoHeader.fullsize_position != 0)
{
std::ifstream in(_archiveFileName.c_str(),std::ios::in | std::ios::binary);
osgDB::ifstream in(_archiveFileName.c_str(),std::ios::in | std::ios::binary);
// find image
in.seekg(photoHeader.fullsize_position);
@@ -211,7 +211,7 @@ void PhotoArchive::buildArchive(const std::string& filename, const FileNameList&
MyGraphicsContext context;
// open up the archive for writing to
std::ofstream out(filename.c_str(), std::ios::out | std::ios::binary);
osgDB::ofstream out(filename.c_str(), std::ios::out | std::ios::binary);
// write out file indentifier.
out.write(FILE_IDENTIFER.c_str(),FILE_IDENTIFER.size());

View File

@@ -46,6 +46,7 @@
#include <osg/CoordinateSystemNode>
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/ReadFile>
#include <osgText/Text>
@@ -243,7 +244,7 @@ int main(int argc, char **argv)
std::string flightpath_filename;
while (arguments.read("--flight-path",flightpath_filename))
{
std::ifstream fin(flightpath_filename.c_str());
osgDB::ifstream fin(flightpath_filename.c_str());
if (fin)
{
osg::AnimationPath* path = new osg::AnimationPath;

View File

@@ -17,6 +17,7 @@
*/
#include <osgViewer/Viewer>
#include <osgDB/fstream>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
@@ -499,7 +500,7 @@ int main( int argc, char **argv )
FileList fileList;
// extract the filenames from the a file, one filename per line.
while (arguments.read("-files",filename)) {
std::ifstream is(filename.c_str());
osgDB::ifstream is(filename.c_str());
if (is) {
std::string line;
while (std::getline(is,line,'\n')) fileList.push_back(line);

View File

@@ -30,6 +30,7 @@
#include <osgDB/FileUtils>
#include <osgDB/fstream>
#include <osgDB/ReadFile>
#include <osgUtil/GLObjectsVisitor>
@@ -120,7 +121,7 @@ public:
bool readMasterFile(Files& files) const
{
std::ifstream fin(_filename.c_str());
osgDB::ifstream fin(_filename.c_str());
if (fin)
{
osgDB::Input fr;

View File

@@ -27,10 +27,11 @@
#include <osg/Timer>
#include <osg/Notify>
#include <osgDB/fstream>
#include <string>
#include <vector>
#include <list>
#include <fstream>
/**
@@ -119,7 +120,7 @@ private:
TraceLevel _traceLevel;
std::ostream* _outputStreamPtr;
std::ofstream _nullStream;
osgDB::ofstream _nullStream;
};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

View File

@@ -1447,7 +1447,7 @@ struct WriteRowOperator
osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent, int numberOfComponents, const std::string& endian, const std::string& raw_filename)
{
std::ifstream fin(raw_filename.c_str(), std::ifstream::binary);
osgDB::ifstream fin(raw_filename.c_str(), std::ifstream::binary);
if (!fin) return 0;
GLenum pixelFormat;
@@ -1711,7 +1711,7 @@ osg::TransferFunction1D* readTransferFunctionFile(const std::string& filename)
std::cout<<"Reading transfer function "<<filename<<std::endl;
osg::TransferFunction1D::ValueMap valueMap;
std::ifstream fin(foundFile.c_str());
osgDB::ifstream fin(foundFile.c_str());
while(fin)
{
float value, red, green, blue, alpha;
@@ -1958,7 +1958,7 @@ int main( int argc, char **argv )
std::string raw_filename, transfer_filename;
int xdim(0), ydim(0), zdim(0);
std::ifstream header(vh_filename.c_str());
osgDB::ifstream header(vh_filename.c_str());
if (header)
{
header >> raw_filename >> transfer_filename >> xdim >> ydim >> zdim >> xSize >> ySize >> zSize;
@@ -1977,7 +1977,7 @@ int main( int argc, char **argv )
if (!transfer_filename.empty())
{
std::ifstream fin(transfer_filename.c_str());
osgDB::ifstream fin(transfer_filename.c_str());
if (fin)
{
osg::TransferFunction1D::ValueMap valueMap;