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.)
# 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.)