in reply to Detecting drive unavailability on ActivePerl
You can use Win32API::File (which should be included with most versions of Perl) to control this. See the module's documentation on SetErrorMode. Since the API is rather broken (Microsoft's fault), here is a sample usage:
Note that this example uses opendir rather than reading the output of "dir /od a:" which can often be a better idea. - tye (but my friends call me "Tye")#!/usr/bin/perl -w use strict; use Win32API::File qw(:ALL); { my $mode= SetErrorMode( 0 ); $mode |= SEM_FAILCRITICALERRORS; SetErrorMode( $mode ); } opendir( DIR, "a:/" ) or die "Can't read directory from a:/; $!\n"; my @files= readdir(DIR); closedir(DIR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Detecting drive unavailability on ActivePerl
by InfiniteSilence (Curate) on Apr 30, 2001 at 19:49 UTC |