Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Idiot-proof path to app resources



Have you tried something like this as soon as the application is launched?

tell app "Finder" to set resourceAlias to resource path of main bundle as alias

In theory, the alias form should be resilient even if the path changes within the same volume.

-Ted

On 7-May-08, at 9:54 AM, Craig Hunter wrote:

I've been using various means to get the resource path of my app bundles for
the last few years, the most useful being "resource path of main bundle".
Other ways include variations on "path to me". These all seem to provide
the path of the app when it is first launched, which theoretically should be
fine. Unfortunately, I have found that a small number of users like to move
apps while they're running, which invalidates the resource path determined
at launch time. And then many of the "do shell script" calls in my apps go
haywire as the files they're referring to are not in the right place.


Does anyone have an idiot-proof way to determine the app bundle path in real
time that would be practical for on-the-fly location of resources to be used
in do shell script calls? Right now, I found I can sort of handle the
situation by doing a "path to me" call within a try block at top level
handlers in my script, and when it fails, I put up a dialog telling the user
the app was moved and needs to be quit now. But if there's an efficient way
to avoid the situation altogether, that would be even better.


I've also been running into users who skip the advice to install my apps
directly in /Applications and stick them in folders with names like "~~
Bill's <freakin> Wonderful! $oftware Folder ~~", which wreaks havoc with do
shell script when it tries to refer to resources in the app bundle, but I
think that is best handled with a warning at launch time, since I can detect
it right away. But if anyone has ideas on that, I'd like to hear them as
well. Generally, the judicious application of quotes (or quoted form of)
can handle most meta-character that have special meaning in the UNIX shell,
but there are some oddball situations.


Thanks,
Craig

--
Dr. Craig Hunter
NASA Langley Research Center
Configuration Aerodynamics Branch
email@hidden
(757) 864-3020

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list (email@hidden )
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden


This email sent to email@hidden

________________________________________________________________ ////////////////// // LAMONTAGNE // GEOPHYSICS LTD ////////////////// GEOPHYSIQUE LTEE 115 Grant Timmins Dr. Kingston ON Canada

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
References: 
 >Idiot-proof path to app resources (From: Craig Hunter <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.