Changed the error reporting so that it directs it all via osg::notify, and

only uses the INFO level for reporting that the file to load is not
recognised.  Also add check for LWO2 loading so that it returns FILE_NOT_HANDLED
message correctly.
This commit is contained in:
Robert Osfield 2002-08-04 20:51:03 +00:00
parent cab49a9307
commit 93403a54db
4 changed files with 14 additions and 13 deletions

View File

@ -67,7 +67,7 @@ Lwo2::ReadFile( const string& filename )
_fin.open(filename.c_str(), ios::in | ios::binary );
if (!_fin.is_open())
{
notify(FATAL) << "Can't open file '" << filename << "'" << endl;
notify(NOTICE) << "Can't open file '" << filename << "'" << endl;
return false;
}
@ -75,7 +75,7 @@ Lwo2::ReadFile( const string& filename )
// http://www.lightwave3d.com/developer/75lwsdk/docs/filefmts/eaiff85.html
if (_read_long() != tag_FORM)
{
notify(FATAL) << "File '" << filename << "' is not IFF format file." << endl;
notify(INFO) << "File '" << filename << "' is not IFF format file." << endl;
_fin.close();
return false;
}

View File

@ -70,11 +70,11 @@ osgDB::RegisterReaderWriterProxy<ReaderWriterLWO> g_lwoReaderWriterProxy;
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO2(const std::string& fileName, const osgDB::ReaderWriter::Options*)
{
std::auto_ptr<Lwo2> lwo2(new Lwo2());
lwo2->ReadFile(fileName);
osg::ref_ptr<Group> group = new osg::Group();
if (lwo2->GenerateGroup(*group)) return group.take();
if (lwo2->ReadFile(fileName))
{
osg::ref_ptr<Group> group = new osg::Group();
if (lwo2->GenerateGroup(*group)) return group.take();
}
return ReadResult::FILE_NOT_HANDLED;
}
@ -110,7 +110,7 @@ struct GeometryCollection
// read file and convert to OSG.
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO1(const std::string& fileName, const osgDB::ReaderWriter::Options*)
{
lwObject* lw = lw_object_read(fileName.c_str());
lwObject* lw = lw_object_read(fileName.c_str(),osg::notify(osg::INFO));
if (!lw)
return ReadResult::FILE_NOT_HANDLED;

View File

@ -239,7 +239,7 @@ gint lw_is_lwobject(const char *lw_file)
}
lwObject *lw_object_read(const char *lw_file)
lwObject *lw_object_read(const char *lw_file, std::ostream& output)
{
FILE *f = NULL;
lwObject *lw_object = NULL;
@ -250,13 +250,13 @@ lwObject *lw_object_read(const char *lw_file)
/* open file */
f = fopen(lw_file, "rb");
if (f == NULL) {
g_warning("can't open file %s", lw_file);
output << "can't open file "<<lw_file<<std::endl;
return NULL;
}
/* check for headers */
if (read_long(f) != ID_FORM) {
g_warning("file %s is not an IFF file", lw_file);
output << "file "<<lw_file<<" is not an IFF file"<<std::endl;
fclose(f);
return NULL;
}
@ -264,7 +264,7 @@ lwObject *lw_object_read(const char *lw_file)
read_bytes += 4;
if (read_long(f) != ID_LWOB) {
g_warning("file %s is not a LWOB file", lw_file);
output << "file "<<lw_file<<" is not a LWOB file"<<std::endl;
fclose(f);
return NULL;
}

View File

@ -21,6 +21,7 @@
#define LW_H
#include <osg/GL>
#include <iostream>
#define LW_MAX_POINTS 200
#define LW_MAX_NAME_LEN 500
@ -88,7 +89,7 @@ typedef int gint;
gint lw_is_lwobject(const char *lw_file);
lwObject *lw_object_read(const char *lw_file);
lwObject *lw_object_read(const char *lw_file, std::ostream& output);
void lw_object_free( lwObject *lw_object);
GLfloat lw_object_radius(const lwObject *lw_object);