Recent

Author Topic: [SOLVED] Read file inside app bundle MacOs  (Read 2101 times)

jamie

  • Hero Member
  • *****
  • Posts: 6813
Re: [SOLVED] Read file inside app bundle MacOs
« Reply #15 on: May 12, 2024, 03:27:13 pm »
Ok, another reason to stay away from it. :(
The only true wisdom is knowing you know nothing

madref

  • Hero Member
  • *****
  • Posts: 1102
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: [SOLVED] Read file inside app bundle MacOs
« Reply #16 on: May 14, 2024, 11:25:47 pm »
I found out that the real environment and the design environment need two separate approaches because when designing in Lazarus for Mac the actual running file is stored in the same directory as the app-bundle, BUT in the real environment the running file is stored INSIDE the bundle.


So I came up with this solution:
Code: Pascal  [Select][+][-]
  1.   String1 := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0)));
  2.   String2 := 'MacOS';
  3.   if Pos(String2, String1) <> 0 then
  4.     // Work Environment
  5.     ProgramDir := copy(String1, 1, length(String1) - 6)
  6.   else
  7.     // Design Environment
  8.     ProgramDir := Application.ExeName + '.app/Contents/';
« Last Edit: May 15, 2024, 10:12:05 am by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7.4
Lazarus 4.99 (rev main_4_99-1378-ga4855f6fa5) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

 

TinyPortal © 2005-2018