Re: TCL Paths in Apple bundles
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: TCL Paths in Apple bundles

From: Kevin Walzer <sw@wordtech-software.com>
Date: Sun Feb 26 2006 - 20:22:26 CET

Brett the James wrote:
> Hi, I was wondering if anyone knew how to pull a path out of an apple
> bundle.
>
> I've packaged a program in an apple bundle (which is really just a
> file) and I'm letting people start it via the user interface. The
> trouble is, there are dependent files, both other tcl files and files
> that require processing. I access these files both through TCL commands
> and exec commands, like CP and such. The trouble is, once the program
> starts, it's not sensitive to the starting path.
>
> I've tried a number of things to get it. If I use the TCL pwd or 'exec
> pwd' I get '/' as the response. If I use 'file dirname [program]', I
> get '.' as a reply. I finally got it to work by pulling it directly
> from the PID:
> ---snip---
> set procLoc [exec ps -p [pid] -o command]
> set clean1 [string first / $procLoc]
> set clean2 [string last MacOS $procLoc]
> set clean2 [expr $clean2 - 1]
> set procLoc [string range $procLoc $clean1 $clean2]
> cd $procLoc/Resources
> ---snip---
> But the process seems unwieldy and the results are flakey. Anyone know
> of a good way to do this? Either in the bundle information (info.plist)
> or within the program itself?
>
> I'd really prefer not to make the path static (e.g.
> /Applications/Application.app/Contents/)
>
> Thanks,
> Brett
>

file join [file dirname [info script]] returns a path to your script.
I've also used [info nameofexecutable], which provides a path to
myapp.app/Contents/MacOS/Wish (or whatever you've named it).

-- 
Kevin Walzer
iReveal: File Search Tool
http://www.wordtech-software.com
Received on Sun Apr 30 02:16:12 2006