Results 1 to 5 of 5

Thread: Converting URIs to file paths

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540

    Converting URIs to file paths

    I'm wondering if there's a C/C++ library or example source that demonstrates how to correctly convert a uri to a file path. This is necessary for loading texture images in Collada, since the <image>/<init_from> element is a uri.

    I've put in some hacks that allow me to properly handle all the uris I've come across, including things like "file:///C:/Program%20Files/3dsmax7/maps/FIR2.TGA", which is exported from Max. I'm sure there are many cases my simple code isn't handling though, so I'm looking for a better solution.

    Does the Collada DOM provide any help with this perhaps?

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771
    See this link for information on URI processing...

    http://www.ietf.org/rfc/rfc3986.txt

    Yes the COLLADA DOM has functions to resolve URI for you.

  3. #3
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    There's a lot of information in that document and I was wondering if someone had already tackled the problem of converting a file-scheme uri to a file path for use with a function like fopen.

    I know the Collada DOM has code to resolve an uri to another Collada element, but I'm not sure if there's code to help me convert "file:///C:/my%20Folder/image.tga" to "C:/myFolder/image.tga". Really I'm only worried about the encoded space there. Everything else I should be able to do with the daeUri class.

    Actually now that I look at it, 20 is just the hexadecimal value of a space in ASCII. If the rule is just "for every %, take the next two characters and treat them as the hexadecimal code of an ASCII value", then it'll be easy to implement that myself. I wonder if the DOM does this when resolving uris.

  4. #4
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    The DOM does handle %20 space encoding for you. Until recently it would only encode on save but we have changed that so it will do it on load as well.
    In the COLLADA document there will be "%20" but the in the DOM memory they will have all become " ".

    As for the file system path... thats still left up to the client. But it would be a very useful contribution if someone were to add functionality to the daeURI class.

    -Andy

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Quote Originally Posted by alorino
    Until recently it would only encode on save but we have changed that so it will do it on load as well.
    More proof that I really need to update to the latest version of the DOM. I'll do that today. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •