--- trunk/all2xml.pl 2003/07/14 10:54:34 102 +++ trunk/all2xml.pl 2003/07/14 18:20:27 108 @@ -306,6 +306,7 @@ my $fake_dir = 1; sub fakeprogress { + return if (! $show_progress); my $current = shift @_; my @ind = ('-','\\','|','/','-','\\','|','/', '-'); @@ -327,6 +328,27 @@ $import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); my $db = OpenIsis::open( $isis_db ); + # check if .txt database for OpenIsis is zero length, + # if so, erase it and re-open database + sub check_txt_db { + my $isis_db = shift || die "need isis database name"; + if (-e $isis_db.".TXT") { + print STDERR "WARNING: removing .txt OpenIsis database...\n"; + unlink $isis_db.".TXT" || warn "FATAL: unlink error on '$isis_db.TXT': $!"; + my $db = OpenIsis::open( $isis_db ); + return $db; + } + } + + # EOF error + if ($db == -1) { + $db = check_txt_db($isis_db); + if ($db == -1) { + print STDERR "FATAL: OpenIsis can't open zero size file $isis_db\n"; + next; + } + } + # OpenIsis::ERR_BADF if ($db == -4) { print STDERR "FATAL: OpenIsis can't find file $isis_db\n"; @@ -342,6 +364,13 @@ my $max_rowid = OpenIsis::maxRowid( $db ); + # if 0 records, try to rease isis .txt database + if ($max_rowid == 0) { + # force removal of database + $db = check_txt_db($isis_db); + $max_rowid = OpenIsis::maxRowid( $db ); + } + print STDERR "Reading database: $isis_db [$max_rowid rows]\n"; my $path = $database; @@ -363,6 +392,10 @@ } } } + # for this to work with current version of OpenIsis (0.9.0) + # you might need my patch from + # http://www.rot13.org/~dpavlin/projects/openisis-0.9.0-perl_close.diff + OpenIsis::close($db); print STDERR "\n"; } elsif ($type_base eq "excel") {