On Wed, 2006-11-29 at 12:58 +0000, Roger James wrote:
> Zach,
> 
> Are you running on windows.
> 
> On windows I get
> 
>  
> <init_from>../../../../../textures/rm_big_tree1.rgba</init_from>

This is a relative URI. What is it relative to?

> The code that puts the file name in looks like this at the moment
> 
> std::string imgstr = "/" 
>   + osgDB::convertFileNameToUnixStyle(

All this function does is change '\' to '/', it seems as part of file to
URL normalization.

The statement is a very simplistic creation of an absolute URL from the
results of findDataFile(). It is saying that the leading '/' is the base
URI. Since the supporting code doesn't normalize on this, there should
be a check for a pre-existing leading '/' at the very least.

The goal up to this point seems to be to create an absolute path URL
with file scheme implied.

>     osgDB::findDataFile( osgimg->getFileName() ) );

The internals of this function calls convertFileNameToNativeStyle()
first and that handles Unix/Windows Style.

It then interates over the expression

    std::string path = itr->empty() ? filename : *itr + '/'+ filename;

... so it is doing a simple prepend of search directories and returning
a result is not normalized (absolute/relative). So clients of the
function need to check the results before editing the string further
(see above).

> #ifdef WIN32
> daeURI uri( _strlwr( (char *)imgstr.c_str() ) );
> #else
> daeURI uri( imgstr.c_str() );
> #endif

For Windows this completes file to URL normalization by making it
lowercase. This could be a source of problems because the path portion
of a URL is case sensitive, so this should be a transient operation and
not persisted in the output (ie it must be case preserving).

> uri.validate();
> imgif->setValue( uri.getURI() );
> //imgif->setValue( imgstr.c_str() );
> //imgif->getValue().validate();

This assumes that a valid URI has been assembled at this point and
assigns it. What about checking for errors here?

> #ifdef WIN32
> std::string docUriString = doc->getDocumentURI()->getFilepath();
> docUriString += doc->getDocumentURI()->getFile();
> daeURI docUri( _strlwr( (char *)docUriString.c_str() ) );
> imgif->getValue().makeRelativeTo( &docUri );
> #else
> imgif->getValue().makeRelativeTo( doc->getDocumentURI() ); 
> #endif

This is attempting to make the (possibly invalid) URL relative to the
document. That needs to be assured and the entire operation needs to be
case preserving too.

Regards,
Marcus


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

Reply via email to