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

Re: [MacPerl] Name of drives



At 10.28 -0500 1998.12.19, PwrSurge wrote:
>I have a feeling that this is possible; but I am as knowledgeable on
>modules as perl is on programming itself.  :P
>
>I'd like to know if when a PERL script is executing (specifically, MacPERL)
>- and a disk (floppy, ZIP, SyQuest, whatever) is inserted; I'd like to know
>how to get the name of that disk -OR- how to reference it.  IE drive a:
>
>I just have this feeling making a script like that, would maintain files
>easily..

Without hacking at XS, I don't know there is a way to know if a given disk
is in the floppy drive, but you can get all the mounted volumes:

  @volumes = MacPerl::Volumes;

That gives the FSSpec for each.  To get paths:

  @volumes = map {MacPerl::MakePath($_)} MacPerl::Volumes;

If you want to detect a change, you can do:

  #!perl -w
  %volumes = map {(MacPerl::MakePath($_), 1)} MacPerl::Volumes;
  CHECK: while (sleep(1)) {
    my @volumes = map {MacPerl::MakePath($_)} MacPerl::Volumes;
    foreach my $vol (@volumes) {
       if (!exists($volumes{$vol})) {
         print "$vol !\n";
         last CHECK;
       }
    }
  }

--
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 mac-perl-request@iis.ee.ethz.ch