Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: seatle fmx osx relative file path



Permlink Replies: 1 - Last Post: Oct 15, 2016 9:25 AM Last Post By: Richard Walborn
Richard Walborn

Posts: 15
Registered: 10/28/11
seatle fmx osx relative file path
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 14, 2016 9:36 PM
I have an FMX OS X application which updates the firmware in a USB connected device. In the App, I include the hex file in Application bundle under Content//MacOS. When the App starts , the app is to automatically load the hex file. Everything works fine when in debug. However, when the application is deployed , the program can not find the hex file. How do set up a path relative to the application bundle, so even if the application get moved it can always fidn hte file? .
Richard Walborn

Posts: 15
Registered: 10/28/11
Re: seatle fmx osx relative file path
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 15, 2016 9:25 AM   in response to: Richard Walborn in response to: Richard Walborn
Richard Walborn wrote:
I have an FMX OS X application which updates the firmware in a USB connected device. In the App, I include the hex file in Application bundle under Content//MacOS. When the App starts , the app is to automatically load the hex file. Everything works fine when in debug. However, when the application is deployed , the program can not find the hex file. How do set up a path relative to the application bundle, so even if the application get moved it can always find the file? .

I solved my own problem!

First of all in release deployment I added the hex file to the Contents\Resources\ remote path

then I used the following

CFBundleRef mainBundle = CFBundleGetMainBundle();

// Get a reference to the file's URL
CFURLRef hexURL = CFBundleCopyResourceURL(mainBundle, CFSTR("AMC_RACK_5_05D.X.production"), CFSTR("hex"), NULL);

// Convert the URL reference into a string reference
CFStringRef hexPath = CFURLCopyFileSystemPath(hexURL, kCFURLPOSIXPathStyle);

// Get the system encoding method
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();

// Convert the string reference into a C string
const char *path = CFStringGetCStringPtr(hexPath, encodingMethod);

Then File->LoadFromFile(path);
If the user moves the app , the procedure always gets the correct location of the file
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02