Commits

shl...@6f433eb9-a002-0410-945b-ee5462c261ee  committed 4c59516

Refactoring - _current_path now calculates its own _current().

  • Participants
  • Parent commits c25c294

Comments (0)

Files changed (1)

File lib/File/Find/Object.pm

     my $self = {};
     bless $self, $class;
 
-    $self->dir($top->_current_path($from));
+    $self->dir($top->_current_path());
     $self->idx($index);
 
     $self->_last_dir_scanned(undef);
     while (1) {
         if ($self->_process_current())
         {
-            return $self->item($self->_current_path($self->_current()));
+            return $self->item($self->_current_path());
         }
         if(!$self->_movenext) {
             if ($self->_me_die())
     {
         if($action eq 'a') {
             if ($self->callback()) {
-                $self->callback()->($self->_current_path($current));
+                $self->callback()->($self->_current_path());
             }
             return 1;
         }
     my $self = shift;
 
     return defined($self->filter()) ?
-        $self->filter()->($self->_current_path($self->_current())) :
+        $self->filter()->($self->_current_path()) :
         1;
 }
 
 
     # If current is not a directory always return 0, because we may
     # be asked to traverse single-files.
-    my @st = stat($self->_current_path($current));
+    my @st = stat($self->_current_path());
     if (!-d _)
     {
         return 0;
     {
         return 1;
     }
-    if (-l $self->_current_path($current) && !$self->followlink())
+    if (-l $self->_current_path() && !$self->followlink())
     {
         return 0;
     }
     }
     if ($rc) {
         printf(STDERR "Avoid loop " . $self->_father($ptr)->dir() . " => %s\n",
-            $self->_current_path($current));
+            $self->_current_path());
         return 0;
     }
     return 1;
 }
 
 sub _current_path {
-    my ($self, $current) = @_;
+    my $self = shift;
 
-    if ($self eq $current)
+    my $current = $self->_current();
+
+    if ($self eq $self->_current())
     {
         return $self->_curr_file;
     }
     # Remming out because it doesn't work.
     # $self->_father($self->_current)->dir($self->_current->dir());
 
-    $self->_current->dir($self->_current_path($self->_current()));
+    $self->_current->dir($self->_current_path());
 
     # _open_dir can return undef if $self->_current is not a directory.
     if ($self->_open_dir($self->_current))