Identifying App folder Redux

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: Identifying App folder Redux

Post by jmk_phd » Mon Feb 03, 2020 6:36 pm

Jacque --

I definitely will provide the one current Catalina user a build that includes much more robust error checking, so hopefully we'll get more informative error messages.

I was remiss in not appending "for read" in the call to "open file", which might have caused the failure in Catalina (inasmuch as "open file" apparently defaults to the "update" option, presumably not allowed when opening a file in the Applications folder).

Still, it's puzzling that the audioclips -- .wav files in a subfolder -- do not play in Catalina, inasmuch as these are intrinsically "read only." I'll add additional error-checking for this as well.

Thanks as always for your help.

jeff k

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

Re: Identifying App folder Redux

Post by jacque » Mon Feb 03, 2020 10:39 pm

I was remiss in not appending "for read" in the call to "open file", which might have caused the failure in Catalina
Yeah, that could very well be the problem. Fingers crossed, and let us know. That would be a permissions change the rest of us would need to know about.
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: Identifying App folder Redux

Post by jmk_phd » Wed Feb 05, 2020 3:15 am

Okay. I provided the student running macOS Catalina with a $10 gift card and a standalone version of the application (built with LC Indy 8.10) named EAS-SABE-CHK that included a zillion error checks.

At least with this build, the specialFolderPath("engine") apparently is broken in Catalina. (sorry, bogs)

For me (running macOS SnowLeopard) and she (running macOS Catalina), the sfp("engine") path to the enclosing folder yielded...

** Me: "The location of the EAS-SABE folder was identified as: /Applications/EAS-SABE-CHK"
** She: "The location of the EAS-SABE folder was identified as: /private/var/folders/0q/p2xmw_bb6t7bn81n_j94g1c4000gp/T/AppTranslocation/F7394C36-14C8-4118-9B33-91F011FCB804/d"

Although for me the EAS_Audiofiles subfolder (/Applications/EAS-SABE-CHK/EAS_Audiofiles) was readily found, she received my error msg:
** She: "The EAS_Audiofiles subfolder could not be found. Please locate it manually."

This error message then displayed an ask folder dialog, with the default location set to the spf("engine"). She reported having selected the needed folder, and received the following mesage:
** She: "The chosen file path is /Applications/EAS-SABE-CHK/EAS_Audiofiles"

When she actually tried the test, the path to an audioclip -- i.e., /Applications/EAS-SABE-CHK/EAS_Audiofiles/Itm1.wav --*did* work properly, which is to say that the audioclips *did* play as expected.

Unsurprisingly, whereas the location employing the sfp("engine") worked fine for me, it failed in Catalina when identifying the path to one of the text files:

** Me: "The location of the norms_eas.txt file was identified as : /Applications/EAS-SABE-CHK/norms_eas.txt"
whereas she got the error message:
** She: “Will search for file norms_eas.txt using path:
/private/var/folders/0q/p2xmw_bb6t7bn81n_j94g1c4000gp/T/AppTranslocation/F7394C36-14C8-4118-9B33-91F011FCB804/d/norms_eas.txt”

then the followup message displaying an ask file dialog:
**She: "The file norms_eas.txt could not be found. Please locate it manually."

Upon chosing the text file, it properly yielded the path
**She: "The chosen file path is /Applications/EAS_SABE_CHK/norms_eas.txt"

The same worked for the other two text files. BTW, I omitted deliberately the qualifier "for read" from the code "read file" for the third textfile just in order to check whether this would throw a sysError. Apparently it did not.

Bottom line: It appears that at least in LC Indy 8.10 or before, specialFolderPath("engine") does not yield a readily usable path. Programmers using this or earlier versions of LC who've employed this approach to identify the standalone folder ought to be aware.

I really should've created the standalone while running LC Indy 9.5.1 (under macOS Sierra) in order to check whether the LC folks already have fixed this issue for new standalone builds.

It may cost another $10 gift card, but I'll try to get the student beta-tester to try a standalone created with LC Indy 9.5.1. If this newest version does identify the folder/file paths correctly when using sfp("engine"), then the only issue is for LC programmers to ensure that they update their code when using that function.

I welcome the input of anyone able to make sense of the paths yielded by specialFolderPath("engine") in Catalina.

Thanks.

jeff k

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

Re: Identifying App folder Redux

Post by bogs » Wed Feb 05, 2020 11:15 am

Okay. I provided the student running macOS Catalina with a $10 gift card and a standalone version of the application (built with LC Indy 8.10) named EAS-SABE-CHK that included a zillion error checks.

At least with this build, the specialFolderPath("engine") apparently is broken in Catalina. (sorry, bogs)
What is this "specialFolderPath" thingie of which you speak :mrgreen:

I always say you should do your own error checking, even for the most mundane things, for exactly this type of problem, but of course it is always so much easier to just rely on the force and get to it later (Hey, I'm guilty of that myself :wink: )
I welcome the input of anyone able to make sense of the paths yielded by specialFolderPath("engine") in Catalina.
Well, I'm not a mac-centric type, but as you may have guessed by now, it looks like Apple is clamping down on the accessibility of the application folder types. Even back to Snow Leopard, you could see this coming, but the words in the path shown from the Catalina run makes me think they are creating a temporary copy of the contents of the request, and returning the path to that copy.

Things like this may be why Klaus consistently says things like "Use the Documents folder" for storing things your program needs to get too, such as these files, where the end user should have full permissions for access. Of course, if the test answers are in those files, you might want to encrypt/decrypt the files on storage heh.

Like I said, I'm not mac-centric, someone else may know the why or, at least, have a work around for it.
Image

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

Re: Identifying App folder Redux

Post by jmk_phd » Wed Feb 05, 2020 8:36 pm

bogs --

You're right of course about error checking. The application did originally check upon launch for the support files, but I'd assumed (incorrectly) that if "there is no file filePath" returned true, this was simply because the file didn't exist (e.g., had been deleted or renamed by the user) and let it go at that.

I'm ever more wary of workarounds -- what works for now can still break in the next version of an OS -- so the recommendation to use the Documents folder even for the read-only support files seems the safest and wisest approach.

No big deal for this and my other testing applications. The first time the application is launched, it does already -- even in macOS Catalina, as in previous versions of macOS as well as in Windows -- successfully create a subfolder in Documents, to which the datafiles generated by the test are written and from which these can be read for scoring and generating test reports. It just means I've got to inform the user upon first launch to place the support files in that Documents subfolder before running the actual test.

Bottom-line, I'm a convert to the Klaus doctrine regarding the Documents folder. Thanks again to you and to Jacque and to all who've weighed in on this problem.

jeff k

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifying App folder Redux

Post by Klaus » Wed Feb 05, 2020 8:39 pm

Okie Dokie, that makes five bucks then! :D

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

Re: Identifying App folder Redux

Post by jmk_phd » Wed Feb 05, 2020 11:12 pm

Klaus --

Thanks for promoting the strategy of saving all read/write program files to the macOS and Win Documents folder.

Where should I send the check?

jeff k

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifying App folder Redux

Post by Klaus » Wed Feb 05, 2020 11:23 pm

Hi Jeff,

just have a beer on me! :-)


Best

Klaus

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

Re: Identifying App folder Redux

Post by jmk_phd » Thu Feb 06, 2020 10:28 am

One last quick question (understanding that this forum is specific to macOS):

I will of course implement Klaus' recommendation and have my Mac users copy (manually) the subfolder containing my application's support files to its corresponding Documents subfolder, created automatically upon the initial launch of the application.

However, I'm essentially ignorant with respect to Windows. Not having heard to the contrary -- from what currently may be my only Windows user (who happens to be the client) -- I believe that the original strategy, i.e., employing sfp("engine"), currently still works in Windows 10.

I don't want to break the app in Windows 10, so I'm wondering whether I should employ an if/else depending upon the system.

Is it all that hard to expect that Windows users know how to copy the subfolder containing the application's support files to the Documents subfolder created the first time that the application runs? (This would permit using the same code when identifying the path to those support files.)

I'm barely able to navigate an old version of Windows on a borrowed computer, so I have no idea whether it's reasonable to expect that Windows users will know how to copy that support folder to the subfolder created automatically in their Documents directory.

jeff k

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifying App folder Redux

Post by Klaus » Thu Feb 06, 2020 11:12 am

I've just read the whole thread and I actually did not recommend anything in THIS thread? :shock:

My (usual) proposal to use the users DOCUMENTS folder is actually meant for the mobile platform,
since that its the only folder we have write permissions on Mobile!

So this thread is about how to access a bunch of audio files inside of the app, right?

Did you add the folder EAS_Audiofiles via the "Add files" tab in the "Standalone Application Settings"?
If yes, then you will find your sounds in -> specialfolderpath("resources") on all platforms:

Code: Select all

...
set the filename of player 1 to (specialfolderpath("resources") & "/EAS_Audiofiles/a_sound.wav")
...
If not, you should, since this is the official and recommended way to add files and folders to your standalone.

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

Re: Identifying App folder Redux

Post by bogs » Thu Feb 06, 2020 11:24 am

LOL Klaus,
I did not say you recommended anything in this thread, I said you "generally recommend" (as in, "I've read in a lot of other posts you've authored").

If anyone else, or the OP themselves was confused by this, my apologies.
Image

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifying App folder Redux

Post by Klaus » Thu Feb 06, 2020 11:37 am

No problem, I was just wondering why noone mentioned this so far:
Did you add the folder EAS_Audiofiles via the "Add files" tab in the "Standalone Application Settings"?
If yes, then you will find your sounds in -> specialfolderpath("resources") on all platforms:
Been using this for years and never had any problems.

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

Re: Identifying App folder Redux

Post by bogs » Thu Feb 06, 2020 11:48 am

That I do not know, did you try it on Catalina (which appears to be the problem child he is dealing with) ? A lot of techniques that worked for years apparently failed on that system.
Image

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifying App folder Redux

Post by Klaus » Thu Feb 06, 2020 12:13 pm

Did not upgrade to Catalina yet.

But I did not read anything about this*** on the LC mailing lists, which is up-to-date usually.
But will ask again there...

***specialfolderpath() not working

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

Re: Identifying App folder Redux

Post by jmk_phd » Thu Feb 06, 2020 9:28 pm

Klaus --

I did mention in passing that I'd opted not to include the support files (audiofiles and plain-text norms files) in the standalone bundle in order to streamline the distribution of updates to the test norms.

There are 740 audioclips (totaling about 250 MB), which are not expected to change in the future. In contrast, the three text files that contain the means and standard deviations for the 35 test scales will need periodic updating as the author of the test adds additional subjects to his normative sample. Each of these text files is only about 750 bytes, so distributing updates is a trivial matter if these simply can be substituted for the existing files by dropping them into a subfolder (originally envisioned as being in the folder enclosing the standalone in Applications, but now more likely to be in the subfolder that I create in Documents the first time my application is launched in order to store the datafiles generated by the test).

The reasons are practical: Because my application can create from individual datafiles a .csv-formatted batch file that can be imported into Excel or SPSS, he doesn't need me to recalculate the statistics in order to create and distribute updated norms files. However, if these norms were embedded in the standalone bundle, he'd need me to rebuild the standalone each time these changed. Inasmuch as each .zipped package (standalone plus support files) is about 215 MB, it takes me about an hour to upload both Mac and Windows versions to his website via FTP. (Moreover, because he insists upon giving away the application for free -- presumably as his "legacy" to the psychological/psychiatric community -- I'm averaging an unsustainable $8 per hour for developing this program.)

If including the support files in the standalone bundle is the only alternative, so be it. But -- while acknowledging your correction that your recommendation to employ the Documents folder was meant to apply specifically to Mobile apps -- I'm still inclined to cut my losses by storing the resources in the Documents folder.

Thanks much for your input.

jeff k

Post Reply

Return to “Mac OS”