[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Setting the "label" on folders



At 12:08 PM -0400 10/7/98, Chris Nandor wrote:
>At 21.27 -0400 1998.10.06, Fred Giorgi wrote:
>>Does anyone know how to set the label field on folders with perl?
...
>
>Well, as usual, three ways.  :-)  
...
>
>Method 3:
>
>I don't know yet.  

I thought maybe Richard Dreyfus would chuckle and say there isn't
any method 3. :-)

Anyway, it also can be done without AppleEvents.  

use Mac::Files;

sub get_finder_label_index { # uses Mac::Files
	my $path = shift;
	my $catinfo = FSpGetCatInfo($path) || die($^E);
	my $finfo = $catinfo->ioFlFndrInfo() or die($^E);
	my $i = ((($finfo->fdFlags + 0) & 0xE) >> 1);
	return (8 - $i) % 8; # 0 means "none"
}

sub set_finder_label_index { # uses Mac::Files
	my $path = shift;
	my $label_index = shift; # 0 means "none"
	my $i = (8 - $label_index) % 8;
	my $catinfo = FSpGetCatInfo($path) || die $^E;
	my $finfo = $catinfo->ioFlFndrInfo() or die $^E;
	$finfo->fdFlags( ($finfo->fdFlags & ! 0xE) | (($i << 1) & 0xE) );
	$catinfo->ioFlFndrInfo($finfo) or die $^E;
	FSpSetCatInfo($path, $catinfo) || die $^E;
}


Jim

--
Jim Miner          jfm@winternet.com

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch