> -----Original Message----- > From: Steffen Mueller [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 21, 2008 8:34 AM > To: Bob Davis > Cc: par@perl.org > Subject: Re: BUG? PAR::par_handle($0) on cygwin > > Bob Davis wrote: > > Put an executable (or any file?) in a sub directory called parinc. > > I tried different file names other than $0 and if didn't seem to make a > > difference. > > > > ./hello.exe fails > > hello.exe works if on path > > /c/scripts/hello.exe works > > c:/scripts/hello.exe works > > [...] > > > #!/usr/bin/perl > > use strict; > > > > # doesnt work with ./hello.exe > > #my $Exe="$FindBin::Bin/$FindBin::Script"; > > print "ziparch=$0\n"; > > #my $zip = PAR::par_handle($Exe); > > my $zip = PAR::par_handle($0); > > print "zip=$zip\n"; > > if ($zip) { > > my $file = "cygrunsrv.exe"; > > if ($zip->extractMemberWithoutPaths("parinc/$file") == 0) { > > print "$file extracted\n"; > > my $num = chmod 0777, "$file"; > > print "chmod 777 $num $file\n"; > > } else { > > print "$file missing\n"; > > } > > } > > > > =pod > > > > # this works with any calling path > > my $file = "cygrunsrv.exe"; > > my $cyg = PAR::read_file("parinc/$file"); > > open (TMP, ">$file") or print "cant open output $file $!\n"; > > binmode(TMP); > > print TMP $cyg; > > close TMP; > > my $num = chmod 0777, "$file"; > > print "chmod 777 $num $file\n"; > > > > =cut > > > > print "hello bob\n"; > > In PAR.pm, those functions are both quite simple and implemented as follows: > > sub par_handle { > my $par = pop; > return $LibCache{$par}; > } > > This just returns the handle for a particular .par or executable file -- > *using a particular path*. It also strikes me as problematic that case > insensitive file systems will break big time in this context... > > sub read_file { > my $file = pop; > > foreach my $zip (@LibCache) { > my $member = _first_member($zip, $file) or next; > return scalar $member->contents; > } > > return; > } > > This always scans *all* loaded .par's or executables for the specified > file. That's why it always works: It doesn't matter under which > path/name your .par/.exe was cached. > > The behaviour of par_handle can most definitely be considered a bug. I'm > not sure how to fix it, though. (As usual, I know, sorry.) > > Best regards, > Steffen
Thanks Steffen I was just trying to report what I considered a bug/pitfall. So now that I read the code I see how I could use the zlib functions directly. Thanks again Bob