1
# This program is free software; you can redistribute it and/or modify
2
# it under the terms of the GNU General Public License as published by
3
# the Free Software Foundation; version 2 of the License.
5
# This program is distributed in the hope that it will be useful, but
6
# WITHOUT ANY WARRANTY; without even the implied warranty of
7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8
# General Public License for more details.
10
# You should have received a copy of the GNU General Public License
11
# along with this program; if not, write to the Free Software
12
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
15
package GenTest::Generator::FromDirectory;
18
@ISA = qw(GenTest::Generator GenTest);
21
use GenTest::Constants;
22
use GenTest::Generator;
24
use constant GENERATOR_DIRECTORY_NAME => 0;
25
use constant GENERATOR_DIRECTORY_HANDLE => 1;
30
my $generator = $class->SUPER::new({
31
'directory_name' => GENERATOR_DIRECTORY_NAME
34
opendir($generator->[GENERATOR_DIRECTORY_HANDLE], $generator->[GENERATOR_DIRECTORY_NAME]) or die("Unable to open directory $generator->[GENERATOR_DIRECTORY_NAME]: $!");
39
my $generator = shift;
42
my $next_file = readdir($generator->[GENERATOR_DIRECTORY_HANDLE]);
43
if (($next_file eq '.') || ($next_file eq '..')) {
45
} elsif (not defined $next_file) {
46
closedir($generator->[GENERATOR_DIRECTORY_HANDLE]);
47
return undef; # All files have been read
49
my $next_file = $generator->[GENERATOR_DIRECTORY_NAME].'/'.$next_file;
50
open(QUERYFILE, $next_file) or die("Unable to open $next_file: $!");
51
read(QUERYFILE, my $query , -s $next_file);