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

Re: [MacPerl] Determining free disk space



At 14:24 +0200 1999.10.15, Ian wrote:
>Hi - further to my question on determining the free disk space of a volume,
>I reckon just an AppleEvent would do the trick nicely. I am having
>difficulty building the event though, and was wondering if I could ask for
>some help...I've been through Chris' tutorial, and that's all fine and good,
>but I'm still banging my head a bit.
>
>Looking up dictionaries and so on reveal that I want the 'frsp' of a 'cdis',
>with my target as 'MACS'. Here's what I have (that returns a -1708 error):
>
>%ae = (
>    target  =>  'MACS',
>    class   =>  'cdis',
>    id      =>  'frsp',
>    params  =>["'----':obj {want:type(cobj), " .
>            "from:null(), form:enum(name), seld:TEXT(\@)}", $vol]
>);
>
>
>Any suggestions?

Is there any reason not to use Mac::Glue?

  #!perl -w
  use strict;
  use Mac::Glue;
  my $finder = new Mac::Glue 'Finder';
  my $freespace = $finder->get(
      $finder->prop('free_space',disk => 'Bourque'),
      as => 'doub'
  );


If you want to do a raw Apple Event, you can do this.

  #!perl -wl
  use strict;
  use Mac::AppleEvents::Simple;

  my %ae = (
    target => 'MACS',
    class  => 'core',
    id     => 'getd',
    params => [
      "'----':obj {form:prop, want:type(prop), seld:type(frsp), " .
      "from:obj {form:name, want:type(cdis), seld:TEXT(\@), from:'null'()}}," .
      "rtyp:type(doub)",
      'Bourque',
    ]
  );

  my %freespace = do_event(@ae{qw[class id target]}, @{$ae{params}})->get;

You can see why I prefer the Glue method.  :)

-- 
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