12e5b6d6dSopenharmony_ci#!/usr/bin/perl -w 
22e5b6d6dSopenharmony_ci#
32e5b6d6dSopenharmony_ci# Copyright (C) 2012, 2017: Unicode, Inc. and others.
42e5b6d6dSopenharmony_ci# License & terms of use: http://www.unicode.org/copyright.html
52e5b6d6dSopenharmony_ci#
62e5b6d6dSopenharmony_ci#####################################################################
72e5b6d6dSopenharmony_ci# Name          : find_textfiles                                    #
82e5b6d6dSopenharmony_ci# Full path     : /home/umesh/bin/find_textfiles                    #
92e5b6d6dSopenharmony_ci# Type          : Perl Script. Needs Perl 5.                        #
102e5b6d6dSopenharmony_ci# Description   : Finds the text files under a directory            #
112e5b6d6dSopenharmony_ci#                 Prunes CVS directories if -nocvs is provided      #
122e5b6d6dSopenharmony_ci#                 Prunes RCS directories if -norcs is provided      #
132e5b6d6dSopenharmony_ci#                 Prunes SCCS directories if -nosccs is provided    #
142e5b6d6dSopenharmony_ci# Author        : Umesh Nair (umesh@google.com)                     #
152e5b6d6dSopenharmony_ci#                                                                   #
162e5b6d6dSopenharmony_ci#-------------------------------------------------------------------#
172e5b6d6dSopenharmony_ci# Maintenance Block:                                                #
182e5b6d6dSopenharmony_ci# Date            Changed by        Description                     #
192e5b6d6dSopenharmony_ci# ----            ----------        -----------                     #
202e5b6d6dSopenharmony_ci# May 2000        Umesh Nair        Initial version of the script   #
212e5b6d6dSopenharmony_ci# Mar 2002        Umesh Nair        Added -h option                 #
222e5b6d6dSopenharmony_ci# May 2008        Umesh Nair        Added -nosvn and -novc          #
232e5b6d6dSopenharmony_ci#                                                                   #
242e5b6d6dSopenharmony_ci#####################################################################
252e5b6d6dSopenharmony_ci
262e5b6d6dSopenharmony_ciuse strict;
272e5b6d6dSopenharmony_ciuse File::Find;
282e5b6d6dSopenharmony_ci
292e5b6d6dSopenharmony_cimy ($skipCvs, $skipRcs, $skipSccs, $skipSvn, $skipVc, $skipEclipse) = (0, 0, 0, 0, 0);
302e5b6d6dSopenharmony_cimy $help = 0;
312e5b6d6dSopenharmony_ci
322e5b6d6dSopenharmony_ciwhile ((defined $ARGV[0]) and ($ARGV[0] =~ /\A\-/)) {
332e5b6d6dSopenharmony_ci   my $option = shift;
342e5b6d6dSopenharmony_ci   chomp $option;
352e5b6d6dSopenharmony_ci   ($skipCvs = 1) if ($option =~ /nocvs/);
362e5b6d6dSopenharmony_ci   ($skipSccs = 1) if ($option =~ /nosccs/);
372e5b6d6dSopenharmony_ci   ($skipSvn = 1) if ($option =~ /nosvn/);
382e5b6d6dSopenharmony_ci   ($skipVc = 1) if ($option =~ /novc/);
392e5b6d6dSopenharmony_ci   ($skipEclipse = 1) if ($option =~ /noeclipse/);
402e5b6d6dSopenharmony_ci   ($help = 1) if ($option =~ /h/);
412e5b6d6dSopenharmony_ci}
422e5b6d6dSopenharmony_ci
432e5b6d6dSopenharmony_ciif ($help) {
442e5b6d6dSopenharmony_ci    exec "pod2man $0 | nroff -man |". ($ENV{"PAGER"} || 'more -s');
452e5b6d6dSopenharmony_ci}
462e5b6d6dSopenharmony_ci
472e5b6d6dSopenharmony_ciif (@ARGV == 0) {
482e5b6d6dSopenharmony_ci   find (\&wanted, '.');
492e5b6d6dSopenharmony_ci} else {
502e5b6d6dSopenharmony_ci   find (\&wanted, @ARGV);
512e5b6d6dSopenharmony_ci}
522e5b6d6dSopenharmony_ci
532e5b6d6dSopenharmony_cisub wanted {
542e5b6d6dSopenharmony_ci  unless (($skipVc and (/\.vcproj$/ or /\.vcxproj$/ or /\.sln$/ or /\.dsp$/ or /\.dsw$/ or /\.filters$/))
552e5b6d6dSopenharmony_ci    or ($skipEclipse and (/\.project$/ or /\.classpath$/ or /\.prefs$/ or /\.launch$/))) {
562e5b6d6dSopenharmony_ci    print "$File::Find::name\n" if (-f and -T );
572e5b6d6dSopenharmony_ci  }
582e5b6d6dSopenharmony_ci  ($File::Find::prune = 1) 
592e5b6d6dSopenharmony_ci    if (
602e5b6d6dSopenharmony_ci        ($skipCvs and /^CVS$/) or
612e5b6d6dSopenharmony_ci        ($skipRcs and /^RCS$/) or
622e5b6d6dSopenharmony_ci        ($skipSccs and /^SCCS$/) or
632e5b6d6dSopenharmony_ci        ($skipSvn and /^\.svn$/) 
642e5b6d6dSopenharmony_ci       );
652e5b6d6dSopenharmony_ci}
662e5b6d6dSopenharmony_ci
672e5b6d6dSopenharmony_ci__END__
682e5b6d6dSopenharmony_ci
692e5b6d6dSopenharmony_ci=head1 NAME
702e5b6d6dSopenharmony_ci
712e5b6d6dSopenharmony_cifind_textfiles - Finds the text files under a directory
722e5b6d6dSopenharmony_ci
732e5b6d6dSopenharmony_ci=head1 SYNOPSIS
742e5b6d6dSopenharmony_ci
752e5b6d6dSopenharmony_cifind_textfiles [C<-nocvs>] [C<-norcs>] [C<-nosccs>]  [C<-nosvn>]  [C<-novc>] [C<-noeclipse>] [ dir1 [ dir2 ] .... ]
762e5b6d6dSopenharmony_ci
772e5b6d6dSopenharmony_cifind_textfiles [C<-h>]
782e5b6d6dSopenharmony_ci
792e5b6d6dSopenharmony_ci=head1 DESCRIPTION
802e5b6d6dSopenharmony_ci
812e5b6d6dSopenharmony_ciThis script recursively searches the specified directories (current
822e5b6d6dSopenharmony_cidirectory if no parameter is passed) for text files, and lists the
832e5b6d6dSopenharmony_cifilenames on the standard output, one file per line.
842e5b6d6dSopenharmony_ci
852e5b6d6dSopenharmony_ciThe directories named 'CVS', 'RCS' and 'SCCS' may be skipped by
862e5b6d6dSopenharmony_cispecifying the switches -nocvs, -norcs and -nosccs respectively.
872e5b6d6dSopenharmony_ci
882e5b6d6dSopenharmony_ci=head1 OPTIONS
892e5b6d6dSopenharmony_ci
902e5b6d6dSopenharmony_ci=over 4
912e5b6d6dSopenharmony_ci
922e5b6d6dSopenharmony_ci=item C<-h> 
932e5b6d6dSopenharmony_ci
942e5b6d6dSopenharmony_ciDisplays this help document.
952e5b6d6dSopenharmony_ci
962e5b6d6dSopenharmony_ci=item C<-nocvs>
972e5b6d6dSopenharmony_ci
982e5b6d6dSopenharmony_ciPrunes all directories named 'CVS' and everything under that.
992e5b6d6dSopenharmony_ci
1002e5b6d6dSopenharmony_ci=item C<-norcs>
1012e5b6d6dSopenharmony_ci
1022e5b6d6dSopenharmony_ciPrunes all directories named 'RCS' and everything under that.
1032e5b6d6dSopenharmony_ci
1042e5b6d6dSopenharmony_ci=item C<-nosccs>
1052e5b6d6dSopenharmony_ci
1062e5b6d6dSopenharmony_ciPrunes all directories named 'SCCS' and everything under that.
1072e5b6d6dSopenharmony_ci
1082e5b6d6dSopenharmony_ci=item C<-nosvn>
1092e5b6d6dSopenharmony_ci
1102e5b6d6dSopenharmony_ciPrunes all directories named '.svn' and everything under that.
1112e5b6d6dSopenharmony_ci
1122e5b6d6dSopenharmony_ci=item C<-novc>
1132e5b6d6dSopenharmony_ci
1142e5b6d6dSopenharmony_ciExcludes all VC++ files, i.e., *.vcproj, *vcxproj, *.dsw, *.dsp, *.filters.
1152e5b6d6dSopenharmony_ci
1162e5b6d6dSopenharmony_ci=item C<-noeclipse>
1172e5b6d6dSopenharmony_ci
1182e5b6d6dSopenharmony_ciExcludes all Eclipse files, i.e., .project, .classpath, *.prefs, *.launch.
1192e5b6d6dSopenharmony_ci
1202e5b6d6dSopenharmony_ci=back
1212e5b6d6dSopenharmony_ci
1222e5b6d6dSopenharmony_ci=head1 SEE ALSO
1232e5b6d6dSopenharmony_ci
1242e5b6d6dSopenharmony_cifind_binaries
1252e5b6d6dSopenharmony_ci
1262e5b6d6dSopenharmony_ci=head1 AUTHOR
1272e5b6d6dSopenharmony_ci
1282e5b6d6dSopenharmony_ciUmesh Nair, 2000.
1292e5b6d6dSopenharmony_ci
1302e5b6d6dSopenharmony_ci=cut
1312e5b6d6dSopenharmony_ci
132