Monday, 15 April 2013

c++ - fopen with a .app file -



c++ - fopen with a .app file -

this question has reply here:

qt - accessing bundle path 1 reply

i working on qt project maps vowels onto chart have *.sym format.

my goal load initial ipa chart this.

i have *.sym files , can load them after application starts, i'm not sure executable executing.

i have directory format (after building)

project |_ source |_ build |_ source |_ charts |_ load_at_start.sym |_ project.app |_ contents |_ macos |_ project (executable)

this makes using fopen phone call quite difficult. assumed fopen consider current working directory place executable rested, tried this...

file *stream = fopen("./../../../charts/load_at_start.sym", "r");

but doesn't work. can help me?

you'll want create sure .sym file ends within app bundle (the .app directory), under contents/resources.

then can utilize qcoreapplication::applicationdirpath obtain directory of application (e.g. "/applications/project.app/contents/macos/") , append relative path file (e.g. "../resources/charts/load_at_start.sym").

something this:

qdir dir(qcoreapplication::applicationdirpath()); dir.cd("../resources/charts"); file* stream = fopen(dir.filepath("load_at_start.sym").toutf8().constdata());

although might want consider using qt's i/o facilities instead of c's.

c++ qt fopen executable-path

No comments:

Post a Comment