| 1 | # Copyright 2009, 2010, 2011, 2014, 2017, 2018, 2019 Kevin Ryde. | ||
| 2 | # | ||
| 3 | # This file is part of File-Locate-Iterator. | ||
| 4 | # | ||
| 5 | # File-Locate-Iterator is free software; you can redistribute it and/or | ||
| 6 | # modify it under the terms of the GNU General Public License as published | ||
| 7 | # by the Free Software Foundation; either version 3, or (at your option) | ||
| 8 | # any later version. | ||
| 9 | # | ||
| 10 | # File-Locate-Iterator is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 13 | # Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License along | ||
| 16 | # with File-Locate-Iterator; see the file COPYING. Failing that, go to | ||
| 17 | # <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | |||
| 20 | package Iterator::Locate; | ||
| 21 | use 5.005; | ||
| 22 | use strict; | ||
| 23 | use File::Locate::Iterator; | ||
| 24 | use base 'Iterator'; | ||
| 25 | use vars qw($VERSION); | ||
| 26 | |||
| 27 | $VERSION = 28; | ||
| 28 | |||
| 29 | sub new { | ||
| 30 | my $class = shift; | ||
| 31 | my $it = File::Locate::Iterator->new (@_); | ||
| 32 | return $class->SUPER::new | ||
| 33 | (sub { | ||
| 34 | if (defined (my $entry = $it->next)) { | ||
| 35 | return $entry; | ||
| 36 | } | ||
| 37 | Iterator::is_done(); | ||
| 38 | }); | ||
| 39 | } | ||
| 40 | |||
| 41 | 1; | ||
| 42 | __END__ |