Index: gs2-extensions/tdb/trunk/perllib/DBDrivers/GDBMTXTGZ.pm
===================================================================
--- gs2-extensions/tdb/trunk/perllib/DBDrivers/GDBMTXTGZ.pm	(revision 30338)
+++ gs2-extensions/tdb/trunk/perllib/DBDrivers/GDBMTXTGZ.pm	(revision 30339)
@@ -32,15 +32,21 @@
 use util;
 use FileUtils;
-use DBDrivers::GDBM;
+# - OO inheritence
+use parent 'DBDrivers::GDBM';
 
-sub BEGIN
-{
-    @DBDrivers::GDBMTXTGZ::ISA = ( 'DBDrivers::GDBM' );
-}
 
 sub new
 {
     my $class = shift(@_);
-    return bless ($self, $class);
+    my $self = DBDrivers::GDBM->new();
+    # Default TDB file extension
+    $self->{'default_file_extension'} = 'txt.gz';
+    # note: file separator agnostic
+    $self->{'executable_path'} = $ENV{'GSDLHOME'} . '/bin/' . $ENV{'GSDLOS'};
+    $self->{'read_executable'} = 'gzip --decompress --to-stdout';
+    $self->{'keyread_executable'} = $self->{'read_executable'};
+    $self->{'write_executable'} = 'gzip -';
+    bless ($self, $class);
+    return $self;
 }
 
@@ -49,9 +55,14 @@
 # -----------------------------------------------------------------------------
 
-# With infodb_handle already set up, these functions work the same as parent version
-# sub close_infodb_write_handle {}
-# sub delete_infodb_entry {}
-# sub write_infodb_entry {}
-# sub write_infodb_rawentry {}
+# Handled by BaseDBDriver
+# sub get_infodb_file_path(string, string)
+
+# Handled by 70HyphenFormat
+# sub close_infodb_write_handle(filehandle) => void
+# sub delete_infodb_entry(filehandle, string) => void
+# sub read_infodb_file(string, hashmap) => void
+# sub read_infodb_keys(string, hashmap) => void
+# sub write_infodb_entry(filehandle, string, hashmap) => void
+# sub write_infodb_rawentry(filehandle, string, string) => void
 
 
@@ -67,99 +78,26 @@
 # other
 #
+# All this function does now is turn the optional 'append' argument into the
+# appropriate operator for either appending to or clobbering gzip file.
+#
 sub open_infodb_write_handle
 {
+    my $self = shift(@_);
     my $infodb_file_path = shift(@_);
-
-    # Greenstone ships with gzip for windows, on $PATH
-    my $infodb_file_handle = undef;
-    if (!open($infodb_file_handle, "| gzip - > \"$infodb_file_path\"")) {
-        print STDERR "Error: Failed to open pipe to gzip - > \"$infodb_file_path\"\n";
-        print STDERR "       $!\n";
-        return undef;
+    my $opt_append = shift(@_);
+    my $infodb_file_handle;
+    if (defined $opt_append) {
+	my $output_operator = '>'; # clobber
+	if ($opt_append eq "append") {
+	    $output_operator = '>>'; # append
+	}
+	$infodb_file_handle = $self->open_infodb_write_handle($infodb_file_path, $output_operator);
     }
-    binmode($infodb_file_handle,":utf8");
+    else {
+	$infodb_file_handle = $self->open_infodb_write_handle($infodb_file_path);
+    }
     return $infodb_file_handle;
 }
 ## open_infodb_write_handle(string) => filehandle ##
-
-
-## @function get_infodb_file_path(string, string)
-#
-sub get_infodb_file_path
-{
-    my $collection_name = shift(@_);
-    my $infodb_directory_path = shift(@_);
-
-    my $infodb_file_name = &util::get_dirsep_tail($collection_name).".txt.gz";
-    return &util::filename_cat($infodb_directory_path, $infodb_file_name);
-}
-## get_infodb_file_path(string, string) => string ##
-
-
-## @function read_infodb_file(string, hashmap)
-#
-sub read_infodb_file
-{
-    my $infodb_file_path = shift(@_);
-    my $infodb_map = shift(@_);
-
-    my $cmd = "gzip --decompress --to-stdout \"$infodb_file_path\"";
-
-    open (PIPEIN, "$cmd |") || die "Error: Couldn't open pipe from gzip: $!\n  $cmd\n";
-
-    binmode(PIPEIN,":utf8");
-    my $infodb_line = "";
-    my $infodb_key = "";
-    my $infodb_value = "";
-    while (defined ($infodb_line = <PIPEIN>)) {
-        $infodb_line =~ s/(\r\n)+$//; # more general than chomp
-
-        if ($infodb_line =~ /^\[([^\]]+)\]$/) {
-            $infodb_key = $1;
-        }
-        elsif ($infodb_line =~ /^-{70}$/) {
-            $infodb_map->{$infodb_key} = $infodb_value;
-            $infodb_key = "";
-            $infodb_value = "";
-        }
-        else {
-            $infodb_value .= $infodb_line;
-        }
-    }
-
-    close (PIPEIN);
-}
-## read_infodb_file(string, hashmap) => void ##
-
-
-## @function read_infodb_keys(string, hashmap)
-#
-sub read_infodb_keys
-{
-    my $infodb_file_path = shift(@_);
-    my $infodb_map = shift(@_);
-
-    my $cmd = "gzip --decompress --to-stdout \"$infodb_file_path\"";
-
-    open (PIPEIN, "$cmd |") || die "Error: Couldn't open pipe from gzip: $!\n  $cmd\n";
-
-    binmode(PIPEIN,":utf8");
-    my $infodb_line = "";
-    my $infodb_key = "";
-    while (defined ($infodb_line = <PIPEIN>)) {
-        $infodb_line =~ s/(\r\n)+$//; # more general than chomp
-
-        if ($infodb_line =~ /^\[([^\]]+)\]$/) {
-            $infodb_key = $1;
-        }
-        elsif ($infodb_line =~ /^-{70}$/) {
-            $infodb_map->{$infodb_key} = 1;
-            $infodb_key = "";
-        }
-    }
-
-    close (PIPEIN);
-}
-## read_infodb_keys(string, hashmap) => void ##
 
 
@@ -168,8 +106,5 @@
 sub set_infodb_entry
 {
-    my $infodb_file_path = shift(@_);
-    my $infodb_key = shift(@_);
-    my $infodb_map = shift(@_);
-
+    my $self = shift(@_);
     print STDERR "***** gdbmtxtgz::set_infodb_entry() not implemented yet!\n";
 }
