Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Hidden file attribute in Win32

by bitman (Beadle)
on May 21, 2002 at 16:46 UTC ( #168187=perlquestion: print w/ replies, xml ) Need Help??
bitman has asked for the wisdom of the Perl Monks concerning the following question:

Is there any 'nice' way to check if a file is hidden in windows without THIS :-

my $hideflag=`attrib $src`; if ( $hideflag=~m/^ H/ ) {

stat & file test operators seem to not have anything to offer.

Title edit by tye (was "Hide well Frodo")

Replies are listed 'Best First'.
Re: Hidden file attribute in Win32 (was: Hide well Frodo)
by VSarkiss (Monsignor) on May 21, 2002 at 17:14 UTC

    You can use the Win32::File module, which is a little simpler than Win32API::File, like so:

    use Win32::File qw(GetAttributes HIDDEN); my $attr; if (GetAttributes($src, $attr)) { if ($attr & HIDDEN) { # whatever.... } } else { warn "Error getting attributes of $src"; }
    I don't do a lot of Win32 programming but just happened to know this one because I had to do something similar a while ago....

    Added code to check return value of GetAttributes. Shame on me for forgetting. Forty Hail Larrys.

Re: Hidden file attribute in Win32 (was Hide well Frodo)
by particle (Vicar) on May 21, 2002 at 17:03 UTC
    use Win32API::File;
    i think GetHandleInformation is the method, and FILE_ATTRIBUTE_HIDDEN is the flag you'll want. sorry i don't have a complete example for you.

    ~Particle *accelerates*

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://168187]
Approved by VSarkiss
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2016-06-30 19:18 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (403 votes). Check out past polls.