Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Idiot-proof path to app resources
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Idiot-proof path to app resources



With your shell script and garbling characters, I think a combination of quoting the path and writing a handler to replace these characters with the escaped form would be part of the way to solving your problem. Add that to the alias method and you're probably some way there.


On 7 May 2008, at 14:54:45, 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:

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Studio mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: 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 © 2011 Apple Inc. All rights reserved.