Herbert Breunung avatar Herbert Breunung committed 0b98b75

other candidate to solve findlib.pl

Comments (0)

Files changed (1)

 
   chdir ( $dir ) or die "chdir($dir) failed: $!\n";
   return 1;
-}
+}
+
+use Cwd;
+
+sub myfind {
+    my $wd = shift;
+    my @dirs = listdir($wd, "dirs", "fullname");
+    foreach my $adir (@dirs) {
+        print "$adir\n";
+        # Printing files inside directories:
+        my @fnames = listdir($adir, "all", "localname");
+        foreach my $afile (@fnames) {
+            print "$afile\n";
+        }
+        print "\n";
+        myfind($adir);
+    }
+}
+
+sub listdir {
+    my $dir = shift;
+    my $select = shift;
+    my $basename = shift;
+    my $filename;
+    my @files;
+    opendir(DIR, $dir) or die;
+    while($filename = readdir(DIR)) {
+        next if ($filename eq "." || $filename eq "..");
+        my $fullfname = "$dir/$filename";
+        next if ($select eq "dirs" && ! -d $fullfname);
+        if ($basename eq "fullname") {
+            push(@files, $fullfname);
+        } else {
+            push(@files, $filename);
+        }
+    }
+    close(DIR);
+    return @files;
+}
+
+myfind(getcwd());
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.