Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
ahsan_iqbal
Posts: 26
Registered: ‎04-11-2012
My Device: BlackBerry Play book

Issue reading asset files

I am working on a game using ndk, I have given path to assets folder(which contains two subfolders dirXmls and dirTextures) in bardescripter.xml, dirXmls contains configuration files and dirTextures contains images.

 

Now I am trying to open an xml file named config.xml that exists in dirXmls using following code 

 

FILE *fp=fopen("dirxmls/config.xml","rb");

 

but fopen returns NULL also I have tried following line

 

FILE *fp=fopen("assets/dirXmls/config.xml","rb");

 

but still it return NULL;

 

can anyone guide me where possibly I am doing wrong.

 

Regards

Ahsan

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Issue reading asset files

[ Edited ]

You should read this page, in particular the "Folders accessible to an application" part at the bottom: https://bdsc.webapps.blackberry.com/native/documentation/com.qnx.doc.ide.userguide/topic/files_base_...

 

In short, you like need to put "app/" and probably something else in front of those paths, e.g. "app/native/dirxmls/config.xml", but you may need something else.  The "app/" part is to get from the current directory of your app at run time, down to where the .bar contents are unpacked. 

 

What path you use following that depends on the structure of the data in your .bar file.  If you have never looked, examine it with an "unzip" utility (it's just a .zip file with a different file extension) and figure it out. Most native apps will have everything under a folder "native/", and maybe your files are a level or two below that.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
New Developer
ahsan_iqbal
Posts: 26
Registered: ‎04-11-2012
My Device: BlackBerry Play book

Re: Issue reading asset files

Hi

 

Thanx for your valued response, Now I can read file by appeneding "app/native/assets" at the start of my path, but here I have one more question that can I specify in some configuration that this path should be appended at the start of all paths, so that i dont have to change a lot of code.

 

Regards

Ahsan

Please use plain text.