Robert Osfield wrote:
> Hi Andrew,
> 
> I just reviewed you changes but am curious about a couple of parts to it:
> 
>         const unsigned int bufSize = 261;
>         char path[bufSize];
>         if ( !dImg->getInit_from()->getValue().getPath( path, bufSize ) )
>         {
>           osg::notify( osg::WARN ) << "Unable to get path from URI." <<
>     std::endl;
>           return NULL;
>         }
> 
> 
> Is there a reason for fixed size of 261?
I believe Windows has a max filepath length of 260 characters. I don't
know if *nix machines have similar restrictions. We could dynamically
allocate the buffer if you think it would be better.

unsigned int bufSize = 1; //for the null char
if ( dImg->getInit_from()->getValue().getFilepath() != NULL )
{
    bufSize += strlen( dImg->getInit_from()->getValue().getFilepath() );
}
if ( dImg->getInit_from()->getValue().getFile() != NULL )
{
    bufSize += strlen( dImg->getInit_from()->getValue().getFile() );
}
char *path = new char[bufSize+1];
if ( !dImg->getInit_from()->getValue().getPath( path, bufSize ) )
{
    osg::notify( osg::WARN ) << "Unable to get path from URI." << std::endl;
    return NULL;
}

Just remember to delete it afterwards.

> 
>     #ifdef WIN32
>         std::string filename( path+1 );
>     #else
>         std::string filename( path );
>     #endif
> 
> 
> Why the +1 in the case of WIN32?  Is there a Win32 specific character
> appended on the front on the Win32 version of the COLLADA DOM?
There isn't any platform specific handling of URI's in the DOM. The
reason for the +1 is that we get back a leading '/' that needs to be
removed on Win32 systems, ie. /c:/path/file
>  
> 
>         img = osgDB::readImageFile( filename.c_str() );
> 
> 
> 
> Since readImageFile takes a c char* pointer perhaps we could just pass
> in the path rather than converting to std::string, then back to c_str()
> as above.
Thats an oversight on my part. Yeah it would be better to pass in the
path directly without converting to std::string.
> 
> Thoughts?
> Robert.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to