]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2000-05-01 18:56:34 by doogie]
authordoogie <>
Tue, 2 May 2000 01:56:34 +0000 (17:56 -0800)
committerdoogie <>
Tue, 2 May 2000 01:56:34 +0000 (17:56 -0800)
Changed OpenFile to GetFileName.  If the last parameter of 'new' is passed
to GetFileName, it'll return the name from the first dir in the array
passed to it.  Modified OpenRecord to pass an array of ["db", "archive"] to
OpenFile.

Debbugs/DBase.pm

index 10c4a1d5a16dc204005e418b0128ce2fcda232e8..6927faee53eb3d5b1ffcdda3d96533382d1dd2fa 100644 (file)
@@ -111,11 +111,12 @@ sub WriteRecord
     }
 }
 
-sub OpenFile
+sub GetFileName
 {
     my ($prePaths, $stub, $postPath, $desc, $new) = (shift, shift, shift, shift, shift);
+    my $path;
     foreach my $prePath (@$prePaths) {
-       my $path = "/" . $prePath . "/" . $stub . $postPath, my $handle = new FileHandle;
+       $path = "/" . $prePath . "/" . $stub . $postPath;
        print "V: Opening $desc $stub\n" if $Globals{ 'verbose' };
        print "D2: (DBase) trying $path\n" if $Globals{ 'debug' } > 1;
        if( ! -r $Globals{ "work-dir" } . $path ) {
@@ -125,17 +126,28 @@ sub OpenFile
                next if( !$new =~ "new" );
            }
        }
-       open( $handle, $Globals{ "work-dir" } . $path ) && return $handle;
-       if(defined($new) && $new =~ "new") {
+       if( -r $Globals{ "work-dir" } . $path ) {
+           return $path;
+       }
+       if( ( ! -r $Globals{ "work-dir" } . $path ) && defined($new) && $new =~ "new") {
            my $dir = dirname( $path );
            if ( ! -d $Globals{ "work-dir" } . $dir ) {
                mkpath($Globals{ "work-dir" } . $dir);
            }
-           open( $handle, ">" . $Globals{ "work-dir" } . $path ) && return $handle;
+           return $path;
        }
     }
-    return;
+    return undef;
+}
+sub OpenFile
+{
+    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 OpenRecord
 {
     my $record = $_[0];
@@ -159,8 +171,7 @@ sub OpenLogfile
     my $record = $_[0];
     if ( $record ne $OpenedLog )
     {
-       $LogfileHandle = OpenFile("db", $record, ".log", "log");
-       seek( $FileHandle, 0, 2 );
+       $LogfileHandle = OpenFile(["db", "archive"], $record, ".log", "log");
        $OpenedLog = $record;
     }
 }