--- trunk/all2xml.pl 2003/07/14 10:52:13 101 +++ trunk/all2xml.pl 2003/07/14 17:09:36 106 @@ -293,7 +293,6 @@ # output current progress indicator my $last_p = 0; -print STDERR "## show_progress: $show_progress ##\n"; # XXX sub progress { return if (! $show_progress); my $current = shift; @@ -307,6 +306,7 @@ my $fake_dir = 1; sub fakeprogress { + return if (! $show_progress); my $current = shift @_; my @ind = ('-','\\','|','/','-','\\','|','/', '-'); @@ -328,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 "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) { + 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"; @@ -343,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;