From b5ef55d09d7872f8b83faec444dfb32c02c697e3 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Tue, 8 Feb 2000 09:41:52 +0000 Subject: [PATCH] Script changes to fix some problems finding the location of the CodeWarrior IDE, using the file idepath.txt. r=scc git-svn-id: svn://10.0.0.236/trunk@60116 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/build/mac/CodeWarriorLib.pm | 38 ++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/mozilla/build/mac/CodeWarriorLib.pm b/mozilla/build/mac/CodeWarriorLib.pm index ba2156f33c0..1ece03a8dc8 100644 --- a/mozilla/build/mac/CodeWarriorLib.pm +++ b/mozilla/build/mac/CodeWarriorLib.pm @@ -25,6 +25,7 @@ Replaces the AppleScript library I. =cut use strict; +use Cwd; use Mac::Types; use Mac::AppleEvents; use Mac::AppleEvents::Simple; @@ -37,6 +38,7 @@ use vars qw($VERSION); $VERSION = '1.02'; my($app) = 'CWIE'; +my($scriptDir) = cwd(); # 0 == don't switch CWIE to front app in do_event(), 1 == do switch # note: activate() still switches when called @@ -187,16 +189,15 @@ sub activate () { foreach $psi (values(%Process)) { if ($psi->processSignature() eq $app) { $appath = $psi->processAppSpec(), "\n"; - _save_appath($filepath, $appath); - last; + _save_appath($filepath, $appath); + last; } } - if ((!$appath || ! -x $appath) && open(F, $filepath)) { - $appath = ; - close(F); + if (!$appath || !-x $appath) { + $appath = _read_appath($filepath); } - + if (!$appath || ! -x $appath) { # make sure that MacPerl is a front process @@ -369,11 +370,36 @@ sub _get_folder ($$) { } sub _save_appath ($$) { + + my($cwd) = cwd(); # remember the current working dir + chdir($scriptDir); # change dir to the script dir + open(F, '>' . $_[0]) or die $!; print F $_[1]; close(F); + + chdir($cwd); # restore the cwd } +sub _read_appath ($) { + + my($filepath) = @_; + + my($cwd) = cwd(); # remember the current working dir + chdir($scriptDir); # change dir to the script dir + + if (! -e $filepath) { + return ""; + } + open(F, $filepath); + my($appath) = ; + close(F); + + chdir($cwd); # restore the cwd + return($appath); +} + + sub _test ($) { activate(); my($path) = $_[0];