On 8/22/07, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:
> Wagner, David --- Senior Programmer Analyst --- WGO wrote:
> > Any insights would be greatly appreciated on getting owner of a
> > file under Win32.
>
> There is a Win32::File module with a GetAttributes() function. Sounds
> promising, doesn't it?
>
> However, reading the docs for that module makes me feel stupid:
>
> <quote>
> GetAttributes(filename, returnedAttributes)
> Gets the attributes of a file or directory. returnedAttributes
> will be set to the OR-ed combination of the filename
> attributes.
> </quote>
>
> What on earth is an "OR-ed combination"? Anybody who can translate that
> para in the POD to English ( or Swedish ;-) )?
Here is an explanation in Perl:
#!/usr/bin/perl
use strict;
use warnings;
use constant READ_ONLY => 1;
use constant ARCHIVED => 2;
use constant HIDDEN => 4;
my $file = READ_ONLY | HIDDEN;
print "\$file is READ_ONLY: ";
if ($file & READ_ONLY) {
print "true\n";
} else {
print "false\n";
}
print "\$file is READ_ONLY and HIDDEN: ";
if ($file & READ_ONLY and $file & HIDDEN) {
print "true\n";
} else {
print "false\n";
}
print "\$file is READ_ONLY and ARCHIVED: ";
if ($file & READ_ONLY and $file & ARCHIVED) {
print "true\n";
} else {
print "false\n";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/