[30318] | 1 | ###############################################################################
|
---|
| 2 | #
|
---|
| 3 | # GDBM.pm -- utility functions for writing to gdbm databases
|
---|
| 4 | #
|
---|
| 5 | # A component of the Greenstone digital library software from the New Zealand
|
---|
| 6 | # Digital Library Project at the University of Waikato, New Zealand.
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 1999-2015 New Zealand Digital Library Project
|
---|
| 9 | #
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | # the terms of the GNU General Public License as published by the Free Software
|
---|
| 12 | # Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | # version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
| 17 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
---|
| 18 | # more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License along with
|
---|
| 21 | # this program; if not, write to the Free Software Foundation, Inc., 675 Mass
|
---|
| 22 | # Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | #
|
---|
| 24 | ###############################################################################
|
---|
| 25 |
|
---|
| 26 | package DBDrivers::GDBM;
|
---|
| 27 |
|
---|
| 28 | # Pragma
|
---|
| 29 | use strict;
|
---|
| 30 |
|
---|
[30347] | 31 | BEGIN
|
---|
| 32 | {
|
---|
| 33 | if (!defined $ENV{'GSDLHOME'} || !defined $ENV{'GSDLOS'}) {
|
---|
| 34 | die("Error! Environment not prepared. Have you sourced setup.bash?\n");
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[30318] | 38 | # Libraries
|
---|
| 39 | use util;
|
---|
| 40 | use FileUtils;
|
---|
[30337] | 41 | use parent 'DBDrivers::70HyphenFormat';
|
---|
[30318] | 42 |
|
---|
| 43 |
|
---|
[30337] | 44 | ## @function constructor
|
---|
| 45 | #
|
---|
[30318] | 46 | sub new
|
---|
| 47 | {
|
---|
| 48 | my $class = shift(@_);
|
---|
[30337] | 49 | my $self = DBDrivers::70HyphenFormat->new(@_);
|
---|
| 50 | $self->{'default_file_extension'} = 'gdb';
|
---|
| 51 | # note: file separator agnostic
|
---|
| 52 | $self->{'executable_path'} = $ENV{'GSDLHOME'} . '/bin/' . $ENV{'GSDLOS'};
|
---|
| 53 | $self->{'read_executable'} = 'db2txt';
|
---|
| 54 | $self->{'keyread_executable'} = 'gdbmkeys';
|
---|
| 55 | $self->{'write_executable'} = 'txt2db';
|
---|
[30347] | 56 | # Optional Support
|
---|
[30342] | 57 | $self->{'supports_set'} = 1;
|
---|
[30337] | 58 | bless($self, $class);
|
---|
| 59 | return $self;
|
---|
[30318] | 60 | }
|
---|
[30337] | 61 | ## new(void) => GDBM ##
|
---|
[30318] | 62 |
|
---|
[30337] | 63 |
|
---|
[30318] | 64 | # -----------------------------------------------------------------------------
|
---|
| 65 | # GDBM IMPLEMENTATION
|
---|
| 66 | # -----------------------------------------------------------------------------
|
---|
| 67 |
|
---|
[30337] | 68 | # Handled by BaseDBDriver
|
---|
[30347] | 69 | # sub get_infodb_file_path(string, string) => string
|
---|
[30318] | 70 |
|
---|
[30337] | 71 | # Handled by 70HyphenFormat
|
---|
[30347] | 72 | # sub open_infodb_write_handle(string, string?) => filehandle
|
---|
[30337] | 73 | # sub close_infodb_write_handle(filehandle) => void
|
---|
| 74 | # sub delete_infodb_entry(filehandle, string) => void
|
---|
| 75 | # sub read_infodb_entry(string, string) => hashmap
|
---|
| 76 | # sub read_infodb_file(string, hashmap) => void
|
---|
| 77 | # sub read_infodb_keys(string, hashmap) => void
|
---|
| 78 | # sub read_infodb_rawentry(string, string) => string
|
---|
| 79 | # sub set_infodb_entry(string, string, hashmap) => integer
|
---|
| 80 | # sub write_infodb_entry(filehandle, string, hashmap) => void
|
---|
| 81 | # sub write_infodb_rawentry(filehandle, string, string) => void
|
---|
[30318] | 82 |
|
---|
| 83 | 1;
|
---|