+ my ($prePaths, $stub, $postPath, $desc, $new) = (shift, shift, shift, shift, shift);
+ my $fileName = GetFileName($prePaths, $stub, $postPath, $desc, $new);
+ my $handle = new FileHandle;
+ open( $handle, $Globals{ "work-dir" } . $fileName ) && return $handle;
+ return undef;
+}
+
+sub OpenLogfile
+{
+ my $record = $_[0];
+ if ( $record ne $OpenedLog )
+ {
+ $LogfileHandle = OpenFile(["db", "archive"], $record, ".log", "log");
+ $OpenedLog = $record;
+ }
+}
+
+sub ReadLogfile
+{
+ my $record = $_[0];
+ if ( $record eq $OpenedLog )
+ {
+ seek( $LogfileHandle, 0, 0 );
+ my $log = new Debbugs::DBase::Log;
+ $log->Load($LogfileHandle);
+ }
+}
+
+sub CloseLogfile
+{
+ print "V: Closing log $OpenedLog\n" if $Globals{ 'verbose' };
+ close $LogfileHandle;
+ $OpenedLog = 0;
+}
+sub GetBugList
+{
+# TODO: This is ugly, but the easiest for me to implement.
+# If you have a better way, then please send a patch.
+#
+ my $dir = new FileHandle;
+
+ my $prefix;
+ my $paths = shift;
+ my @paths;
+ if ( !defined($paths) ) {
+ @paths = ("db");
+ } else {
+ @paths = @$paths;
+ }
+ my @ret;
+ my $path;
+ foreach $path (@paths) {
+ $prefix = $Globals{ "work-dir" } . "/" . $path . "/";
+ opendir $dir, $prefix;
+ my @files = readdir($dir);
+ closedir $dir;
+ foreach (grep { /\d*\d\d.status/ } @files) {
+ next if ( ! -s $prefix . "/" . $_ );
+ s/.status$//;
+ push @ret, $_;
+# print "$_ -> $_\n";
+ }
+ foreach (grep { /^[s0-9]$/ } @files) {
+ my $_1 = $_;
+ opendir $dir, $prefix . $_1;
+ my @files = grep { /^\d$/ } readdir($dir);
+ closedir $dir;
+ foreach (@files) {
+ my $_2 = $_;
+ opendir $dir, "$prefix$_1/$_2";
+ my @files = grep { /^\d$/ } readdir($dir);
+ close $dir;
+ foreach (@files) {
+ my $_3 = $_;
+ opendir $dir, "$prefix$_1/$_2/$_3";
+ my @files = grep { /\d*\d\d.status/ } readdir($dir);
+ close $dir;
+ foreach (@files) {
+ next if ( ! -s "$prefix$_1/$_2/$_3/$_" );
+ s/.status$//;
+ push @ret, $_;
+# print "$_ -> $_1/$_2/$_3/$_\n";
+ }
+ }
+ }
+ }
+ }
+ return @ret;