AW: How to keep dir structure when building standalone?

Devin Asay devin_asay at byu.edu
Wed Jul 2 12:03:33 EDT 2008


Hi Tiemo,

On Jul 2, 2008, at 8:44 AM, Tiemo Hollmann TB wrote:

> I don't know if I am completely confused, is it a bug or just wrong
> implementation?
> I still have troubles with getting the right path for my DB,  
> developing with
> 2.9 on Win XP, testing on Mac. Testing on Win, everything works  
> fine. I'll
> try to describe my problem again.
> In my development environment my DB is located in a subfolder /db/
> To access my DB in my program I tried two ways to set the path:
> A: relative "/db/"
> B: absolute "/users/.../db/"
> 1. When creating the standalone, my DB is put into the same folder  
> as my
> program: myApp.app/Contents/MacOS (and not as expected in a subfolder:
> myApp.app/Contents/MacOS/db) Why?
> 2. The DB file, which is copied into the standalone package has 0  
> kb. Why?
> I copied manually the DB file into the package and replaced the 0  
> kb file.
> 3. Now I copied the whole package to a Mac and tested, but my program
> doesn't find the DB in the expected path /db/ neither with method A  
> nor B
> 4. Only when creating a folder "db" with the DB on the Mac in the same
> folder as my App, my program finds the DB. But this can't be the way,
> because now the folder with the DB is outside of the app.package.
>
> Where is my fault?
> Thanks for any help for a runaway :)

I might not be understanding your problem exactly, but this  
explanation of how Rev in Mac OS X handles the defaultFolder  
situation might be helpful.

Condition 1: You never explicitly set the defaultFolder in your stack.
In the development environment the defaultFolder points to the folder  
containing the Revolution executable, usually something like / 
Applications/Revolution Enterprise/2.9.0-gm-1.
In the standalone environment the defaultFolder is the folder  
containing your application bundle--the .app file. Therefore in this  
case all relative paths will be relative to this folder. So if you  
distribute your standalone in its own folder, myAppStuff, the  
defaultFolder would be something like /Applications/myAppStuff.

Condition 2: You explicitly set the defaultFolder in your stack to  
the folder containing your stack.
In the development environment the defaultFolder points to the folder  
containing your stack.
In the standalone environment the defaultFolder points to the MacOS  
folder inside the myApp.app bundle. That would be something like / 
Applications/myApp.app/Contents/MacOS. Therefore all relative paths  
will be relative to this folder.

To deal with the difference between the IDE and standalone in Mac OS  
X, I often include the scripting similar to this in my mainstack's  
stack script:

on preOpenStack
   # set the root folder for all resources
   if the environment is "development" then
     set the defaultFolder to enclosingFolder(the name of me)
   end if

   ## Do this for local data and media files.
   set the baseDir of me to the defaultFolder & "/" & "resources"
end preOpenStack

function enclosingFolder pStName
   get the filename of pStName
   set the itemDelimiter to "/"
   return item 1 to -2 of it
end enclosingFolder

Hope this helps.

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list