Get Folder Item does not see file

I distribute a RealBASIC app on the web. For Mac users, the app and necessary files are compressed (with DMG or Zip) and I store them on Amazon Web Services. When the user accesses my Web site, they can download the compressed file which is being stored on AWS and they get the file.
Then they decompress the file on their machine and end up with a folder that contains three things

  1. The compiled app itself (called RAAViewer)
  2. A data file called RAAData.rsd
  3. A folder containing many images called RAA_Images.

When the application starts up, it checks to make sure that this configuration has not been “disturbed”, to make sure that the pieces are all in the same folder. I call out with this line of code:

App.dbf = GetFolderItem("RAAData.rsd")

If in response, App.dbf is Nil or App.dbf.Exists is False the user gets a message that the RAAData.rsd file is not in the expected location, i.e. the same folder with the app, and the app shuts down.

A user wrote me that he was getting this error message even though RAAData.rsd was in the same folder. I tested the whole thing locally on my machine (compressing and uncompressing the files) and could not reproduce the problem. BUT if I sent the compressed file to AWS and downloaded it using my Web site and uncompressed the file to create the folder with the three items, I could reproduce the problem. This seemed very bizarre and I tried using both DMG and also zip and the problem persisted.

Confounded, I tried an additional maneuver. I removed the app (RAAViewer) from the reconstituted folder and put it in some other location. (the Desktop for example). Then I put put the app back into the original reconstituted folder and everything now works fine.

I have never had something like this happen. It is as if the Finder itself does not “know” where the file is. I told the user about this work around and he did it on his machine and now things work fine.

Everyone involved is using Sierra. This is not a wildly popular app and is free, which makes feedback spotty, so I do not know how long this problem has existed. But it has been available for 5 years and certainly did not have this problem in the past.

I write this note because I am baffled. I have never heard of this work-around which somehow seems to “reset” things and for me gets around the issue. Until I tried it in desperation, I would never have thought such a thing would work. I do not know why sending the compressed file to AWS and then downloading it and decompressing it would expose the issue.

Does anyone have an experience like this or have an ability to shed light on this peculiar problem?

Sounds like a translocation problem.

You should use a Copy Files step to put RAAData.rsd inside the Resources folder within your app, and then at launch copy the RAAData.rsd file to your own child folder inside SpecialFolder.ApplicationData

This process is made a bunch easier with my TPSF module which gives you easy access to your app’s internal Resources folder, and makes accessing your own child folder inside AppData easy by automatically returning a folder for your app using it’s details (Bundle Identifier on Mac, App name on Windows)

https://github.com/devtimi/TPSF

Even with Code Signing, translocation can still show up as an issue, so your best defense is to restructure your app setup to behave this way.

Tim,

Thats interesting. I knew about translocation in medicine (DNA) where it can be bad. Didn’t know about this Sierra “feature” which is seems certain to be the cause for my problem.

This is an old RealBASIC app not rewritten for Xojo so if I want to work on it further I have various other things that need to be done before I can implement your suggestion. But I very much appreciate the answer and someday I will do the update and deal with this.

On Mac if your files are in the Resources folder, they won’t have any trouble with translocation.

On both Windows and Mac, it is much better to use the Resources folder.

If you must write to these files, copy them on first launch to SpecialFolder.ApplicationData in a subfolder such as com.livingstonsoftware.raaviewer

On subsequent launches, use exists to see if the file is there.

The process that we’re both describing can be done in RealStudio.
However, TPSF uses Cocoa declares (from @Sam Rowlands) on Mac, so you’ll have to roll your own methods for getting at the internal Resources folder. Not terribly difficult, but not as future resistant as using declares.