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

Re: [MacPerl] how to get VREF with macperl?




Thanks Chris!

I also found this in the list archive, which I think you wrote as well:

$vref = FSpGetCatInfo("CW11 Gold Tools:")->ioVRefNum();

-dave

On Fri, 18 Feb 2000, Chris Nandor wrote:

> At 14.08 -0500 2000.02.18, David Ackerman wrote:
> >I hope someone can point me in the right direction with this.  I'm trying
> >to use the  FindFolder() function from Files.pm.  It requires as the first
> >param the Volume ref number you wish to serach on.  The only examples I
> >can fine use the kOnSystemDisk constant.  However I need to search on
> >whatever volume the user saves another file to.  I've looked through
> >Inside Macintosh and found the GetVRefNum () funtion, but can not find
> >that function documented in the perl toolbox modules.  What is the
> >prefered method of getting the volume ref number in macperl?
> 
> Well, here is a hack I came up with awhile back.
> 
> #!perl -wl
> use Mac::Files;
> use Mac::MoreFiles;
> use strict;
> 
> # ex 1
> for my $vol (MacPerl::Volumes()) {
>     print FindFolder(hex(substr($vol, 1, 4)), kTrashFolderType);
> }
> 
> # ex 2
> my $file = 'Bourque:Desktop Folder:mytestfile';
> (my $vol = $file) =~ s/^(.*?:).*$/$1/;
> 
> print FindFolder(hex(substr(MacPerl::MakeFSSpec($vol), 1, 4)),
>     kTrashFolderType);
> 
> __END__
> 
> 
> That is, you can loop over MacPerl::Volumes() to get the VREF for each:
> 
> #!perl -wl
> for my $vol (MacPerl::Volumes()) {
>    (my $name = $vol) =~ s/^[^:]+://;
>    printf "%-32s: %s\n", $name, hex substr $vol, 1, 4;
> }
> __END__
> 
> That should do it.
> 
> -- 
> Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
> %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])
> 


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org