Changeset 18657

Show
Ignore:
Timestamp:
11.03.2009 13:12:31 (10 years ago)
Author:
kjdon
Message:

added a method for renaming a gdbm database from ldb/bdb to gdb

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/util.pm

    r18469 r18657  
    10561056} 
    10571057 
     1058# makes sure that the file has a gdb extension 
     1059sub rename_gdbm_file { 
     1060    my ($filename_no_ext) = @_; 
     1061 
     1062    my $new_filename = "$filename_no_ext.gdb"; 
     1063    return if (-f $new_filename); # if gdb file exists, don't need to do anything 
     1064    # try ldb 
     1065    my $old_filename = "$filename_no_ext.ldb"; 
     1066     
     1067    if (-f $old_filename) { 
     1068     
     1069    rename ($old_filename, $new_filename); 
     1070    if (-f $old_filename) { 
     1071        print STDERR "old $old_filename still there\n"; 
     1072    } 
     1073    return; 
     1074    } 
     1075    # try bdb 
     1076    $old_filename = "$filename_no_ext.bdb"; 
     1077    if (-f $old_filename) { 
     1078     
     1079    rename ($old_filename, $new_filename); 
     1080    return; 
     1081    } 
     1082 
     1083    print STDERR "no $filename_no_ext.ldb/bdb file to rename\n"; 
     1084} 
     1085 
     1086 
     1087 
    105810881;