Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: filtering hidden files on Win32

by Mr. Muskrat (Canon)
on Aug 30, 2002 at 16:38 UTC ( #194164=note: print w/replies, xml ) Need Help??

in reply to filtering hidden files on Win32

Same basic code... just a few tweaks here and there to get the constant working.

#!perl -w use strict; use Cwd; use Win32::File; my $attribs; my $dir = cwd(); print $dir,$/; opendir( DIR, $dir ) or die "Couldn't open $main::DIR: $!\n"; my @vis_files = grep { -f $dir.'/'.$_ and Win32::File::GetAttributes($_, $attribs) and !($attribs & HIDDEN) } readdir(DIR); closedir( DIR ) or warn "Couldn't close $main::DIR: $!\n"; print $_, $/ for @vis_files;

Replies are listed 'Best First'.
Re: Answer: filtering hidden files on Win32
by (anonymized user) (Curate) on Jan 14, 2016 at 13:36 UTC
    When writing a fire-and-forget duplicates finder just now, I found this thread very useful. My coding style and approach seems rather different though. But whether low code granularity is good is often a highly debated issue.
    sub dfind { my ($dref, $top) = @_; hidden( $top ) and return; if (-d $top) { for my $file (glob( "$top/*" )) { dfind( $dref, $file ); } } else { register( $dref, $top ); # add to HoA } } sub hidden { my $file = shift; my $attribs; Win32::File::GetAttributes($file, $attribs); return $attribs & HIDDEN; }
    Update: note that hidden directories and files are both filtered out owing to how the recursion is contructed.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://194164]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2021-04-19 19:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found