Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2014-07-12 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls