Commits

Anonymous committed 1bb5f98

Made current_path a _top method instead of an ::internal method.

Comments (0)

Files changed (2)

lib/File/Find/Object.pm

     my ($self) = @_;
     while (1) {
         my $current = $self->_current();
-        $current->_process_current and return $self->{item} = $current->current_path;
+        $current->_process_current and return $self->{item} = $self->current_path($current);
         $current = $self->_current();
         if(!$self->movenext) {
             $current->me_die and return $self->{item} = undef;
         $self->{_action}{$_} = 1;
         if($_ eq 'a') {
             if ($self->_top->{callback}) {
-                $self->_top->{callback}->($self->current_path());
+                $self->_top->{callback}->($self->_top->current_path($self));
             }
             return 1;
         }
 sub filter {
     my ($self) = @_;
     return defined($self->_top->{filter}) ?
-        $self->_top->{filter}->($self->current_path()) :
+        $self->_top->{filter}->($self->_top->current_path($self)) :
         1;
 }
 
     {
         return 1;
     }
-    my @st = stat($current->current_path());
+    my @st = stat($self->current_path($current));
     if (!-d _)
     {
         return 0;
     }
-    if (-l $current->current_path() && !$current->_top->{followlink})
+    if (-l $self->current_path($current) && !$current->_top->{followlink})
     {
         return 0;
     }
     }
     if ($rc) {
         printf(STDERR "Avoid loop " . $ptr->_father->{dir} . " => %s\n",
-            $current->current_path());
+            $self->current_path($current));
         return 0;
     }
     return 1;
 }
 
 sub current_path {
-    my ($self) = @_;
-    return $self->{currentfile};
+    my ($self, $current) = @_;
+
+    if ($self eq $current)
+    {
+        return $self->{currentfile};
+    }
+
+    my $p = $current->_father->{dir};
+    $p =~ s!/+$!!; #!
+    $p .= '/' . $current->{currentfile};
+
+    return $p;
 }
 
 sub open_dir {

lib/File/Find/Object/internal.pm

     my ($class, $from, $index) = @_;
     my $self = {
         _top => $from->_top,
-        dir => $from->current_path,
+        dir => $from->_top->current_path($from),
         idx => $index,
     };
 
 }
 
 
-sub current_path {
-    my ($self) = @_;
-    my $p = $self->_father->{dir};
-    $p =~ s!/+$!!; #!
-    $p .= '/' . $self->{currentfile};
-}
-
 1;