modified loadtest() to produce better error message when it fails to load

a test file
This commit is contained in:
Daniel Stenberg 2004-02-26 09:19:16 +00:00
parent 0c3c1b390a
commit 0c03ed6013
1 changed files with 12 additions and 13 deletions

View File

@ -92,21 +92,20 @@ sub getpart {
sub loadtest {
my ($file)=@_;
my $dir;
$dir = $ENV{'srcdir'};
if(!$dir) {
$dir=".";
}
undef @xml;
open(XML, "<$dir/$file") ||
return 1; # failure!
binmode XML; # for crapage systems, use binary
while(<XML>) {
push @xml, $_;
if(open(XML, "<$file")) {
binmode XML; # for crapage systems, use binary
while(<XML>) {
push @xml, $_;
}
close(XML);
}
else {
# failure
print STDERR "file $file wouldn't open!\n";
return 1;
}
close(XML);
return 0;
}