hi, everyone:

i develop osg application under windows. when i was loading a .shp file,  my 
application was crashed. after i tracked, i found i miss a .bdf  file, and code 
was crashed at red line:

XBaseParser::XBaseParser(const std::string fileName):
    _valid(false)
{
    int fd = 0;
    if (fileName.empty() == false)
    {
#ifdef WIN32
        if( (fd = open( fileName.c_str(), O_RDONLY | O_BINARY )) <= 0 )
#else
        if( (fd = ::open( fileName.c_str(), O_RDONLY )) <= 0 )
#endif
        {
            perror( fileName.c_str() );
            if (fd) close( fd );
            return;
        }
    }
    
    _valid = parse(fd);
}


I looked for "open" function's description, i found this(linux) and 
this(windows), so i think this is a BUG.
code should be like this:

XBaseParser::XBaseParser(const std::string fileName):
    _valid(false)
{
    int fd = 0;
    if (fileName.empty() == false)
    {
#ifdef WIN32
        if( (fd = open( fileName.c_str(), O_RDONLY | O_BINARY )) == 0 )
#else
        if( (fd = ::open( fileName.c_str(), O_RDONLY )) == 0 )
#endif
        {
            perror( fileName.c_str() );
            return;
        }
    }
    
    _valid = parse(fd);
}


chaoswong
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to