Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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")

Comment on Hidden file attribute in Win32
Download Code
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*

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.

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 drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2015-07-06 07:10 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (70 votes), past polls