Commits

Herbert Breunung committed 4bd7909

findlib works now srta fast enough still some try will follow

Comments (0)

Files changed (1)

 
 package FindKephraLib;
 use Cwd qw(abs_path);
-use File::Find;
 use File::Spec;
+use File::Find::Rule;
 use FindBin qw($RealBin);
 use Wx;
 use base qw(Wx::App);
 	my $app   = shift;
 	my $frame = Wx::Frame->new( undef, -1, __PACKAGE__ , [-1,-1], [1000,800]);
 	my $ed = Wx::TextCtrl->new($frame, -1, '',[-1,-1], [-1,-1], &Wx::wxTE_MULTILINE | &Wx::wxTE_READONLY);
-	find({ preprocess => sub {
-			grep {1 unless -d $_
-			} 
-			@_;
-		}, 
-		wanted => sub {
-			return unless -r $_;
-			if (-f $_ and substr($_, -9) eq 'Kephra.pm') {
-				#$File::Find::dir #$File::Find::name # $_
-		 		my $path = File::Spec->catdir( $RealBin, $File::Find::name );
-		 		$path = File::Spec->canonpath( $path );
-		 		$path = abs_path( $path );
-				$ed->AppendText( $File::Find::name . "\n");
-			}
-			#$ed->AppendText( $_ . "\n")
-	}, follow => 0, no_chdir => 1 }, '/');
+	my @dirs = File::Find::Rule->file->name('Kephra.pm')->in($ENV{'HOME'});
+	$ed->AppendText( $_ . "\n") for @dirs;
+	$ed->AppendText( "-----\n");
+	for (@INC){
+		my $file = File::Spec->catfile( $_, 'Kephra.pm' );
+		$ed->AppendText( "$file\n") if -e $file;
+	}
+
+	#find({ preprocess => sub {
+	#		grep {1 unless -d $_
+	#		} 
+	#		@_;
+	#	}, 
+	#	wanted => sub {
+	#		return unless -r $_;
+	#		if (-f $_ and substr($_, -9) eq 'Kephra.pm') {
+	#			#$File::Find::dir #$File::Find::name # $_
+	#	 		my $path = File::Spec->catdir( $RealBin, $File::Find::name );
+	#	 		$path = File::Spec->canonpath( $path );
+	#	 		$path = abs_path( $path );
+	#			$ed->AppendText( $File::Find::name . "\n");
+	#		}
+	#		#$ed->AppendText( $_ . "\n")
+	#}, follow => 0, no_chdir => 1 }, '/');
 
 	$frame->Show(1);
 	$app->SetTopWindow($frame);
 	1;
+}
+__END__
+
+my @files;
+my @ignore=(
+  '/usr/bin/',
+  '/home',
+);
+iterate_dirs(
+  # entscheiden ob das Verzeichnis besucht werden soll
+  sub{
+   for(@ignore)
+   { return 0 if( index($_[1],$_)==0 ); }
+   return 1 if( -r $_[0] );
+   return 0;
+  },
+
+  # Auswerten des Eintrags
+  sub{
+    push(@files, $_[1]) if( -f $_[0] and -r $_[0] and substr($_[0],-4,4) eq '.pod' );
+  },
+
+  # die zu durchsuchenden Verzeichnisse
+  '/usr/lib/perl5'
+);
+
+print "$_\n" for( @files );
+
+#################################
+
+sub iterate_dirs {
+  my ($decide_code, $each_code, @stack ) =@_ ;
+
+  my $dir=getcwd;
+
+  my ($p,$dh,$path,$tmp);
+  while(@stack)
+  {
+    $path = pop(@stack);
+    chdir( $path ) or die "chdir($path) failed: $!";;
+    opendir( $dh, '.' ) or die "Unable to open $path: $!\n";
+    for( readdir( $dh ) )
+    {
+      next if( $_ eq '.' or $_ eq '..' );
+      $tmp=$path.'/'.$_;
+      push(@stack, $tmp) if( -d $_ and $decide_code->( $_, $tmp ) );
+      $each_code->( $_, $tmp );
+    }
+    closedir ($dh);
+  }
+
+  chdir ( $dir ) or die "chdir($dir) failed: $!\n";
+  return 1;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.