- my $prePath = $_[0], my $stub = $_[1], my $postPath = $_[2], my $desc = $_[3];
- my $path = "/db/".$stub.".status", my $handle = new FileHandle;
- print "V: Opening $desc $stub\n" if $Globals{ 'verbose' };
- print "D2: (DBase) $path found as data path\n" if $Globals{ 'debug' } > 1;
- if( ! -r $Globals{ "work-dir" } . $path ) {
- my $dir;
- $path = $prePath. &NameToPathHash($stub) .$postPath;
- $dir = basename($path);
- if( ! -d $Globals{ "work-dir" } . $dir ) {
- print "D1 (DBase) making dir $dir\n" if $Globals{ 'debug' };
- mkdir $Globals{ "work-dir" } . $dir, umask();
+ my ($prePaths, $stub, $postPath, $desc, $new) = (shift, shift, shift, shift, shift);
+ my $path;
+ foreach my $prePath (@$prePaths) {
+ $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 ) {
+ $path = "/" . $prePath . "/" . &NameToPathHash($stub) . $postPath;
+ print "D2: (DBase) trying $path\n" if $Globals{ 'debug' } > 1;
+ if( ! -r $Globals{ "work-dir" } . $path ) {
+ next if( !$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);
+ }
+ return $path;