Loading xml



  • Hello,
    I have one problem with loading game resources.

    If I try to load an xml file, located in current or parent directory using relative path, file will be loaded:
    Resources gameResources;
    gameResources.loadXML("../resources.xml");

    But if I try to load an xml file, located in a directory that hierarchically above than parent using relative path, file will not be loaded:
    Resources gameResources;
    gameResources.loadXML("../../resources.xml");

    If I use absolute path, file will be loaded successfully anywhere.
    Can I solve this problem without using getcwd() or similar function?


  • administrators

    Hi, need more info

    1. show hierarchy tree
    2. what Working Dir?
    3. show log with error

    btw, if you trying to "leave" working dir it wont work



  • Apperantly, Working Dir is directory with result executable binary file.
    For example, my directory with executable file is "~/project/bin/build-x/".

    If the xml file also placed in this directory, I can load it using this code:
    gameResources.loadXML("resources.xml");

    If I place the xml file in the directory "~/project/bin/", I can load it using this code:
    gameResources.loadXML("../resources.xml");

    But if I place the xml file in the directory "~/project/", I can't load it using this:
    gameResources.loadXML("../../resources.xml");
    Consequently, I can't load the xml file if it placed in any of a child directory of "~/project/", for example "~/project/data" or similar.

    Log with errors in this case:
    054 error: can't read file: resources.xml to buffer
    054 error: can't load xml file: '../../resources.xml'
    054 error: Assert! !"can't find xml file"


  • administrators

    @arcanius said in Loading xml:

    Apperantly, Working Dir is directory with result executable binary file.

    you are not right
    working dir is root directory with all resources, you should not exit from it
    binary file could be located anywhere


Log in to reply
 

Looks like your connection to Oxygine was lost, please wait while we try to reconnect.