Page 1 of 1

GetPathPart(ProgramFilename()) problem on Macs

Posted: Mon Nov 04, 2013 10:59 am
by infratec
Hi,

since I'm not a Mac user I stumpled across an ugly thing on Mac OS X:

On windows and linux I use GetPathPart(ProgramFilename()) to store own data files beside the program.
If I do this on a Mac it works, but ...

The files are stored inside the app folders and not beside them.

So if an other program wants to read such a stored file, it has no chance. :cry:

In my opinion ProgramFilename() returns the wrong value on a Mac.
But Ok.

What's the right way todo it right.
I didn't use the home directory, because I want my program 'flat' and don't want to create directories on my
own from what the users don't know something about.
(I hope you understand what I mean)

Bernd

Re: GetPathPart(ProgramFilename()) problem on Macs

Posted: Mon Nov 04, 2013 11:10 am
by IdeasVacuum
The files are stored inside the app folders and not beside them.
Hi infratec - I think you mean something other than what you have said, because if you use the path from GetPathPart(ProgramFilename() in Windows that is the app folder and anything saved to it will be inside the app folder, with the executable.

Re: GetPathPart(ProgramFilename()) problem on Macs

Posted: Mon Nov 04, 2013 11:17 am
by infratec
Yes and no :wink:

On a Mac the app is a folder with the program somewhere inside.
On linux and windows the 'app' is a single file.

Bernd

Re: GetPathPart(ProgramFilename()) problem on Macs

Posted: Mon Nov 04, 2013 12:11 pm
by wilbert
If you take a look at the NSBundle Class reference, you see there 's a method named bundlePath and a method named executablePath.
What you want is bundlePath and what PureBasic returns for ProgramFilename() is executablePath.
So what is returned looks correct to me but it might be different from what you expect.

This code shows the bundle path

Code: Select all

Bundle = CocoaMessage(0, 0, "NSBundle mainBundle")
BundlePath = CocoaMessage(0, Bundle, "bundlePath")
Path.s = PeekS(CocoaMessage(0, BundlePath, "UTF8String"), -1, #PB_UTF8)
Debug Path
Be aware that if you want to sell a an application through the Mac App Store, there are limitations to where you are allowed to store files.

Re: GetPathPart(ProgramFilename()) problem on Macs

Posted: Mon Nov 04, 2013 12:32 pm
by IdeasVacuum
It to had be awkward, it's apple :?