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

@@ -28,5 +28,6 @@
#cmakedefine OSG_USE_FLOAT_BOUNDINGSPHERE
#cmakedefine OSG_USE_FLOAT_BOUNDINGBOX
#cmakedefine OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION
#cmakedefine OSG_USE_UTF8_FILENAME
#endif

View File

@@ -10,6 +10,7 @@ SET(HEADER_PATH ${OpenSceneGraph_SOURCE_DIR}/include/${LIB_NAME})
SET(LIB_PUBLIC_HEADERS
${HEADER_PATH}/Archive
${HEADER_PATH}/AuthenticationMap
${HEADER_PATH}/ConvertUTF
${HEADER_PATH}/DatabasePager
${HEADER_PATH}/DotOsgWrapper
${HEADER_PATH}/DynamicLibrary
@@ -20,6 +21,7 @@ SET(LIB_PUBLIC_HEADERS
${HEADER_PATH}/FileCache
${HEADER_PATH}/FileNameUtils
${HEADER_PATH}/FileUtils
${HEADER_PATH}/fstream
${HEADER_PATH}/ImageOptions
${HEADER_PATH}/ImagePager
${HEADER_PATH}/Input
@@ -41,6 +43,7 @@ ADD_LIBRARY(${LIB_NAME}
${LIB_PUBLIC_HEADERS}
Archive.cpp
AuthenticationMap.cpp
ConvertUTF.cpp
DatabasePager.cpp
DotOsgWrapper.cpp
DynamicLibrary.cpp
@@ -50,6 +53,7 @@ ADD_LIBRARY(${LIB_NAME}
FileCache.cpp
FileNameUtils.cpp
FileUtils.cpp
fstream.cpp
ImageOptions.cpp
ImagePager.cpp
Input.cpp

90
src/osgDB/ConvertUTF.cpp Normal file
View File

@@ -0,0 +1,90 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgDB/ConvertUTF>
#include <osg/Notify>
#if defined(WIN32) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
namespace osgDB
{
std::string convertUTF16toUTF8(const wchar_t* source, unsigned sourceLength)
{
#if defined(WIN32) && !defined(__CYGWIN__)
if (sourceLength == 0)
{
return std::string();
}
int destLen = WideCharToMultiByte(CP_UTF8, 0, source, sourceLength, 0, 0, 0, 0);
if (destLen <= 0)
{
osg::notify(osg::WARN) << "Cannot convert UTF-16 string to UTF-8." << std::endl;
return std::string();
}
std::string sDest(destLen, '\0');
destLen = WideCharToMultiByte(CP_UTF8, 0, source, sourceLength, &sDest[0], destLen, 0, 0);
if (destLen <= 0)
{
osg::notify(osg::WARN) << "Cannot convert UTF-16 string to UTF-8." << std::endl;
return std::string();
}
return sDest;
#else
//TODO: Implement for other platforms
osg::notify(osg::WARN) << "ConvertUTF16toUTF8 not implemented." << std::endl;
return std::string();
#endif
}
std::wstring convertUTF8toUTF16(const char* source, unsigned sourceLength)
{
#if defined(WIN32) && !defined(__CYGWIN__)
if (sourceLength == 0)
{
return std::wstring();
}
int destLen = MultiByteToWideChar(CP_UTF8, 0, source, sourceLength, 0, 0);
if (destLen <= 0)
{
osg::notify(osg::WARN) << "Cannot convert UTF-8 string to UTF-16." << std::endl;
return std::wstring();
}
std::wstring sDest(destLen, L'\0');
destLen = MultiByteToWideChar(CP_UTF8, 0, source, sourceLength, &sDest[0], destLen);
if (destLen <= 0)
{
osg::notify(osg::WARN) << "Cannot convert UTF-8 string to UTF-16." << std::endl;
return std::wstring();
}
return sDest;
#else
//TODO: Implement for other platforms
osg::notify(osg::WARN) << "ConvertUTF8toUTF16 not implemented." << std::endl;
return std::wstring();
#endif
}
}

View File

@@ -11,7 +11,7 @@
* OpenSceneGraph Public License for more details.
*/
// currently this impl is for _all_ platforms, execpt as defined.
// currently this impl is for _all_ platforms, except as defined.
// the mac version will change soon to reflect the path scheme under osx, but
// for now, the above include is commented out, and the below code takes precedence.
@@ -64,6 +64,8 @@
# define S_ISDIR(mode) (mode&__S_IFDIR)
#endif
#include <osg/Config>
#include <osgDB/ConvertUTF>
#include <osg/Notify>
#include <osgDB/FileUtils>
@@ -73,7 +75,33 @@
#include <errno.h>
#include <stack>
namespace osgDB
{
#ifdef OSG_USE_UTF8_FILENAME
#define OSGDB_STRING_TO_FILENAME(s) osgDB::convertUTF8toUTF16(s)
#define OSGDB_FILENAME_TO_STRING(s) osgDB::convertUTF16toUTF8(s)
#define OSGDB_FILENAME_TEXT(x) L ## x
#define OSGDB_WINDOWS_FUNCT(x) x ## W
typedef wchar_t filenamechar;
typedef std::wstring filenamestring;
#else
#define OSGDB_STRING_TO_FILENAME(s) s
#define OSGDB_FILENAME_TO_STRING(s) s
#define OSGDB_FILENAME_TEXT(x) x
#define OSGDB_WINDOWS_FUNCT(x) x ## A
typedef char filenamechar;
typedef std::string filenamestring;
#endif
}
FILE* osgDB::fopen(const char* filename, const char* mode)
{
#ifdef OSG_USE_UTF8_FILENAME
return ::_wfopen(convertUTF8toUTF16(filename).c_str(), convertUTF8toUTF16(mode).c_str());
#else
return ::fopen(filename, mode);
#endif
}
bool osgDB::makeDirectory( const std::string &path )
{
@@ -84,7 +112,11 @@ bool osgDB::makeDirectory( const std::string &path )
}
struct stat64 stbuf;
#ifdef OSG_USE_UTF8_FILENAME
if( _wstat64( OSGDB_STRING_TO_FILENAME(path).c_str(), &stbuf ) == 0 )
#else
if( stat64( path.c_str(), &stbuf ) == 0 )
#endif
{
if( S_ISDIR(stbuf.st_mode))
return true;
@@ -103,7 +135,11 @@ bool osgDB::makeDirectory( const std::string &path )
if( dir.empty() )
break;
#ifdef OSG_USE_UTF8_FILENAME
if( _wstat64( OSGDB_STRING_TO_FILENAME(dir).c_str(), &stbuf ) < 0 )
#else
if( stat64( dir.c_str(), &stbuf ) < 0 )
#endif
{
switch( errno )
{
@@ -132,7 +168,11 @@ bool osgDB::makeDirectory( const std::string &path )
}
#endif
#ifdef OSG_USE_UTF8_FILENAME
if ( _wmkdir(OSGDB_STRING_TO_FILENAME(dir).c_str())< 0 )
#else
if( mkdir( dir.c_str(), 0755 )< 0 )
#endif
{
osg::notify(osg::DEBUG_INFO) << "osgDB::makeDirectory(): " << strerror(errno) << std::endl;
return false;
@@ -174,13 +214,21 @@ void osgDB::convertStringPathIntoFilePathList(const std::string& paths,FilePathL
bool osgDB::fileExists(const std::string& filename)
{
#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
}
osgDB::FileType osgDB::fileType(const std::string& filename)
{
struct stat64 fileStat;
if ( stat64(filename.c_str(), &fileStat) != 0 )
#ifdef OSG_USE_UTF8_FILENAME
if ( _wstat64(OSGDB_STRING_TO_FILENAME(filename).c_str(), &fileStat) != 0 )
#else
if ( stat64(filename.c_str(), &fileStat) != 0 )
#endif
{
return FILE_NOT_FOUND;
} // end if
@@ -381,15 +429,15 @@ static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath)
{
osgDB::DirectoryContents contents;
WIN32_FIND_DATA data;
HANDLE handle = FindFirstFile((dirName + "\\*").c_str(), &data);
OSGDB_WINDOWS_FUNCT(WIN32_FIND_DATA) data;
HANDLE handle = OSGDB_WINDOWS_FUNCT(FindFirstFile)((OSGDB_STRING_TO_FILENAME(dirName) + OSGDB_FILENAME_TEXT("\\*")).c_str(), &data);
if (handle != INVALID_HANDLE_VALUE)
{
do
{
contents.push_back(data.cFileName);
contents.push_back(OSGDB_FILENAME_TO_STRING(data.cFileName));
}
while (FindNextFile(handle, &data) != 0);
while (OSGDB_WINDOWS_FUNCT(FindNextFile)(handle, &data) != 0);
FindClose(handle);
}
@@ -497,14 +545,14 @@ static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath)
// 1. The directory from which the application loaded.
DWORD retval = 0;
const DWORD size = MAX_PATH;
char path[size];
retval = GetModuleFileName(NULL, path, size);
filenamechar path[size];
retval = OSGDB_WINDOWS_FUNCT(GetModuleFileName)(NULL, path, size);
if (retval != 0 && retval < size)
{
std::string pathstr(path);
std::string executableDir(pathstr, 0,
pathstr.find_last_of("\\/"));
convertStringPathIntoFilePathList(executableDir, filepath);
filenamestring pathstr(path);
filenamestring executableDir(pathstr, 0,
pathstr.find_last_of(OSGDB_FILENAME_TEXT("\\/")));
convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(executableDir), filepath);
}
else
{
@@ -514,11 +562,12 @@ static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath)
// 2. The system directory. Use the GetSystemDirectory function to
// get the path of this directory.
char systemDir[(UINT)size];
retval = GetSystemDirectory(systemDir, (UINT)size);
filenamechar systemDir[(UINT)size];
retval = OSGDB_WINDOWS_FUNCT(GetSystemDirectory)(systemDir, (UINT)size);
if (retval != 0 && retval < size)
{
convertStringPathIntoFilePathList(std::string(systemDir),
convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(systemDir),
filepath);
}
else
@@ -533,13 +582,13 @@ static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath)
// the path of this directory, but it is searched.
// 4. The Windows directory. Use the GetWindowsDirectory function to
// get the path of this directory.
char windowsDir[(UINT)size];
retval = GetWindowsDirectory(windowsDir, (UINT)size);
filenamechar windowsDir[(UINT)size];
retval = OSGDB_WINDOWS_FUNCT(GetWindowsDirectory)(windowsDir, (UINT)size);
if (retval != 0 && retval < size)
{
convertStringPathIntoFilePathList(std::string(windowsDir) +
convertStringPathIntoFilePathList(std::string(OSGDB_FILENAME_TO_STRING(windowsDir)) +
"\\System", filepath);
convertStringPathIntoFilePathList(std::string(windowsDir),
convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(windowsDir),
filepath);
}
else
@@ -557,14 +606,18 @@ static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath)
// 6. The directories that are listed in the PATH environment
// variable. Note that this does not include the per-application
// path specified by the App Paths registry key.
char* ptr;
if ((ptr = getenv( "PATH" )))
filenamechar* ptr;
#ifdef OSG_USE_UTF8_FILENAME
if (ptr = _wgetenv(OSGDB_FILENAME_TEXT("PATH")))
#else
if (ptr = getenv("PATH"))
#endif
{
// Note that on any sane Windows system, some of the paths above
// will also be on the PATH (the values gotten in systemDir and
// windowsDir), but the DLL search goes sequentially and stops
// when a DLL is found, so I see no point in removing duplicates.
convertStringPathIntoFilePathList(ptr, filepath);
convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(ptr), filepath);
}
appendInstallationLibraryFilePaths(filepath);

View File

@@ -29,7 +29,7 @@ Output::Output()
init();
}
Output::Output(const char* name) : ofstream(name)
Output::Output(const char* name) : osgDB::ofstream(name)
{
init();
_filename = name;
@@ -70,7 +70,7 @@ void Output::setOptions(const ReaderWriter::Options* options)
void Output::open(const char *name)
{
init();
ofstream::open(name);
osgDB::ofstream::open(name);
_filename = name;
}

View File

@@ -28,6 +28,7 @@
#include <osgDB/Registry>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/fstream>
#include <osgDB/Archive>
#include <algorithm>
@@ -574,7 +575,7 @@ bool Registry::readPluginAliasConfigurationFile( const std::string& file )
return false;
}
std::ifstream ifs;
osgDB::ifstream ifs;
ifs.open( fileName.c_str() );
if (!ifs.good())
{

61
src/osgDB/fstream.cpp Normal file
View File

@@ -0,0 +1,61 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgDB/fstream>
#include <osgDB/ConvertUTF>
#include <osg/Config>
namespace osgDB
{
#ifdef OSG_USE_UTF8_FILENAME
#define OSGDB_CONVERT_UTF8_FILENAME(s) convertUTF8toUTF16(s).c_str()
#else
#define OSGDB_CONVERT_UTF8_FILENAME(s) s
#endif
fstream::fstream(){}
fstream::fstream(const char* filename,
std::ios_base::openmode mode) : std::fstream(OSGDB_CONVERT_UTF8_FILENAME(filename), mode)
{}
fstream::~fstream(){}
void fstream::open(const char* filename,
std::ios_base::openmode mode)
{
std::fstream::open(OSGDB_CONVERT_UTF8_FILENAME(filename), mode);
}
ifstream::ifstream(){}
ifstream::ifstream(const char* filename,
std::ios_base::openmode mode) : std::ifstream(OSGDB_CONVERT_UTF8_FILENAME(filename), mode)
{}
ifstream::~ifstream(){}
void ifstream::open(const char* filename,
std::ios_base::openmode mode)
{
std::ifstream::open(OSGDB_CONVERT_UTF8_FILENAME(filename), mode);
}
ofstream::ofstream(){}
ofstream::ofstream(const char* filename,
std::ios_base::openmode mode) : std::ofstream(OSGDB_CONVERT_UTF8_FILENAME(filename), mode)
{}
ofstream::~ofstream(){}
void ofstream::open(const char* filename,
std::ios_base::openmode mode)
{
std::ofstream::open(OSGDB_CONVERT_UTF8_FILENAME(filename), mode);
}
}

View File

@@ -1,6 +1,6 @@
#include <osgGA/AnimationPathManipulator>
#include <fstream>
#include <osgDB/fstream>
using namespace osgGA;
@@ -29,7 +29,7 @@ AnimationPathManipulator::AnimationPathManipulator( const std::string& filename
_isPaused = false;
std::ifstream in(filename.c_str());
osgDB::ifstream in(filename.c_str());
if (!in)
{

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;

View File

@@ -16,7 +16,6 @@
#include <limits.h>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <osgDB/FileNameUtils>
@@ -506,7 +505,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
// In the future this will need to be written continuously, rather
// than all at once.
std::ofstream out(_filename.c_str());
osgDB::ofstream out(_filename.c_str());
osg::notify(osg::NOTICE)<<"Writing camera file: "<<_filename<<std::endl;
_animPath->write(out);
out.close();

View File

@@ -172,7 +172,7 @@ bool PythonEngine::runFile(const std::string& filePath) {
return false;
}
FILE* f = fopen(filePath.c_str(), "r");
FILE* f = osgDB::fopen(filePath.c_str(), "r");
PyObject* r = PyRun_File(f, filePath.c_str(), Py_file_input, _data->main, _data->main);
fclose(f);