Finding folder/files in the application folder

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Finding folder/files in the application folder

Post by Thierry » Fri Nov 15, 2019 10:26 am

jmk_phd wrote: Your experience seems really important for those of us who create macOS standalones.
(I'm assuming that your broken apps were written in LC.) Perhaps you've reported on this elsewhere
Hi Jeff,

Well, I think you're overestimating my knowledge in this area.

In fact, I've put aside my development, waiting for new information.
I'm also still waiting for a third-party application I need to behave well with latest MacOS systems.
Otherwise, it's not a real problem for me as it's an interesting tool for only few developers.
And no, I didn't report anything in the forum.

And yes, it's a LC app using 2 others apps (not LC), all 3 delivered in a DMG.

I guess helping you with your problem I might gain some more experience too;
so it's a good deal for both of us.
But helping in your case, means testing in live your app - there I have a long practice;
otherwise most of what have been said so far is mere speculation as far as your problem is concerned.

That said, I'm still happy to test your app, and then ask you specific questions based on these tests
to narrow down your problem and might be that the light will come, or not.

Good luck,

Thierry


PS: apologizes for my French-English writing
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Finding folder/files in the application folder

Post by jacque » Fri Nov 15, 2019 8:15 pm

Why can't LC figure out a way to identify the path to the folder that encloses a macOS standalone?
Since you can't write to that folder for updates, I'm not sure why you'd need that info.

It sounds like the best approach would be to store copies of essential files in a writable location and load them from there when the app needs them. That way you can download and update individual files and you don't need to worry about the application bundle at all. On first launch after an initial install, copy the files from the bundle into Documents, Application Support, or Preferences and you can read/write from there.

If you want the convenience of referring to stacks with their short names, put entries into the stackFiles. The app should behave just as you have it now, but without the permission constraints.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmk_phd
Posts: 213
Joined: Sat Apr 15, 2017 8:29 pm

Re: Finding folder/files in the application folder

Post by jmk_phd » Sat Nov 16, 2019 2:41 am

Jacque --
Since you can't write to that folder for updates, I'm not sure why you'd need that info.
Of course it's not possible for an app to write to the Applications folder. That was never my intention. (When my app launches, it looks for a named subfolder in the Documents folder, and creates this if not found. Thereafter, all documents generated by the app are written to that subfolder.) All support documents are read-only.

Upon opening, my app simply searched -- using the previously documented routine -- for the path to the folder enclosing the standalone, then appending to this "/" and name of the folder or file to be identified. This has worked through macOS Sierra.

Not having personal experience beyond macOS Sierra, it was my assumption that it was still possible for a user to download a program folder from a website to her/his Downloads folder, then drag-copy this to the Applications folder. So, for example, the user could download an updated read-only file and manually copy this to the program's subfolder, replacing the older file.

If this is no longer possible, I suppose that I could create an initial installer to copy the 254 MB folder of .wav files to Application Support, separate from installing the standalone. (My client is still modifying these audio files, so substituting or adding selected files is not easily doable.) This still would require embedding some updates into the standalone, complicating updates.

For now, the strategy I've employed has worked for the Windows standalone and for macOS standalones through Sierra.

It's very unfortunate if recent changes to macOS -- including the failure to trace back from the standalone path to the path of the enclosing folder -- is no longer possible.

Thanks for your reply.

jeff k

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Finding folder/files in the application folder

Post by [-hh] » Sat Nov 16, 2019 9:10 am

jmk_phd wrote:effective filename : /Applications/EAS folder/EAS-SABE.app/Contents/MacOS/EAS-SABE
sFP("engine") : /Applications/EAS folder/EAS-SABE.app/Contents/MacOS
sFP("resources") : /Applications/EAS folder/EAS-SABE.app/Contents/Resources/_MacOS

In each case, one still must delete each last element of the path (up to and including EAS-SABE.app) -- the routine to which I referred as "acrobatics" -- in order to get the path to the enclosing folder -- after which on appends "/EAS_Audiofiles" for the path to that folder and "/EAS_norms.txt" for the path to the text file.
No, one certainly must NOT. This is only one (childish) way to shorten the path, like doing "multiply x by 5" as "x+x+x+x+x".
Here is another possibility, using any of the above for variable eF:

Code: Select all

put the effective filename of this stack into eF
put char 1 to offset("EAS-SABE.app",eF)-1 of eF into f0 -- or EAS_SABE?
put f0 & "EAS_Audiofiles" into audiofiles
put f0 & "EAS_norms.txt" into normstxt
This works here on Catalina (10.15.1) using 9.5/9.0.5. Especially the latter one is much better than 8.1.10 (because 9.0.5 closed a lot of memory leaks).

p.s. In your scripts and examples you switch between "EAS-SABE" and EAS_SABE". Did you doublecheck that?
shiftLock happens

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Finding folder/files in the application folder

Post by bogs » Sat Nov 16, 2019 12:27 pm

Nifty Hermann, very nice.
Image

jmk_phd
Posts: 213
Joined: Sat Apr 15, 2017 8:29 pm

Re: Finding folder/files in the application folder

Post by jmk_phd » Sat Nov 16, 2019 4:13 pm

Hi Hermann --

Many thanks for your reply. Your solution is truly elegant (in the mathematical sense), and -- as bogs put it -- simply nifty!

(I assume that the amateurish routine I'd borrowed from the Live Code Lesson "Get Path to Stack Folder" was intended to illustrate the *principle* of extracting the path from a Mac application bundle more transparently than might have been the case with your very concise code.)

Very important to me also is knowing that you found your solution to work even in Catalina.

BTW, as regards the naming discrepancy, my client decided late in development that he didn't like an underscore in the name of the standalone, so I simply change this to a hyphen in the Standalone Application Settings. This has not been an problem.

Best wishes also to everyone who's contributed to resolving this issue for me.

jeff k

Post Reply

Return to “Mac OS”