How to reuse the FS_ wordlist from Win32API::File?

D

Dr.Ruud

#!/usr/bin/perl
# demo GetVolumeInformation() (hi Tad)
use strict;
use warnings;

use Win32API::File qw ( GetVolumeInformation :FS_ );

### Is there a nicer/shorter way to express
## @{$Win32API::File::EXPORT_TAGS{FS_}} ?
#
my $FS_ref = $Win32API::File::EXPORT_TAGS{FS_};

my @GetVolumeInformation_P = qw( sRootPath osVolName lVolName
ouSerialNum
ouMaxNameLen ouFsFlags osFsType
lFsType );
my @GetVolumeInformation = ( 'C:/', undef, undef, undef,
undef, undef, undef,
undef );

GetVolumeInformation( @GetVolumeInformation )
or die "GetVolumeInformation:\t"
. $GetVolumeInformation[0]
. "\n\t $^E\n\t$!";

for my $i ( 0 .. $#GetVolumeInformation )
{
### The next line starts strange; how to do it nicer?
##
#
my $v; $v = defined() ? $_ : '' for $GetVolumeInformation[$i];

# If numeric, then show the hexadecimal representation as well.
printf "%d\t[%s]\t%s%s\n"
, $i
, $GetVolumeInformation_P[$i]
, $v
, ($v =~ /\A[0-9]+\z/) ? sprintf("\t[hex %x]", $v) : '';

# Intermezzo: show the FS_ Flags.
if (5 == $i)
{
local @_;
eval "push \@_, '$_' if $_ & \$v" for @$FS_ref;
print "\t@_\n";
}
}
__END__


See the two questions marked with ###.
Any comments welcome too.

(For info about "BUFFER SIZES", see Win32API::Registry.)
 
D

Dr.Ruud

Dr.Ruud schreef:
my @GetVolumeInformation_P = qw( sRootPath osVolName lVolName
ouSerialNum
ouMaxNameLen ouFsFlags osFsType
lFsType );
my @GetVolumeInformation = ( 'C:/', undef, undef,
undef, undef, undef, undef,
undef );

Blegh, make that:

my @GetVolumeInformation_P =
qw( sRootPath osVolName lVolName ouSerialNum
ouMaxNameLen ouFsFlags osFsType lFsType );

my @GetVolumeInformation =
( 'C:/', undef, undef, undef,
undef, undef, undef, undef );

(just reformatted)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top