Forum > Operating Systems

Path to application on Mac?

(1/2) > >>

Spoonhorse:
I’m using Lazarus on the Mac for the first time, trying to port/finish a little app in preparation for porting a bigger app.

In order to locate the resources for the app, I figured I needed to know where it was located. (If I’m wrong, and I’m setting y’all an XY problem, please let me know.)

But whether I use Paramstr(0) or the more approved Application.ExeName, then on the Mac instead of getting the actual file path /Users/myname/Documents/Hamsters/project1, I instead get /Users/myname/Documents/Hamsters/project1.app/Contents/MacOS/project1

This doesn’t exist. >:D

Any advice? Thanks for your help.

Leledumbo:
https://wiki.freepascal.org/Multiplatform_Programming_Guide#On_Unix_there_is_no_.22application_directory.22

wp:
I'm not a mac specialist, but this questions might be related to application bundles: https://wiki.freepascal.org/Multiplatform_Programming_Guide#macOS_2

Spoonhorse:
Thank you both. OK, Macs are weird, converting my Big Project's source from Windows to Windows-and-Mac is going to be a doozy I can see. I think I can finish off this little one now though.

Spoonhorse:
It still seems strange though.

In both this little practice project and in the big one, what I want to do among other things is (a) include some example files of the type that the app uses, accessible from the File menu of the app (b) include a file that remembers which file you have open and opens it when you open the app, so I can ship it "remembering" that it's looking at '/examples/example1.foo' in the app directory.

This has all been a great deal of trouble to try to get it to work under all circumstances and yet it seems such an obvious and modest thing to want to do. All I need is for the app to be able to find out where it is. Why should this be difficult?

Navigation

[0] Message Index

[#] Next page

Go to full version