---
name: "VCP::DB_File"
section: "3pm"
platform: "linux"
package: "libvcp-perl"
version: "0.9-20050110-1"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/VCP::DB_File"
---

# VCP::DB\_File(3pm)

VCP::DB\_File - Persistant storage for vcp\_state data

```
    use base qw( VCP::DB_File );
```

By default, most VCP::Dest::\* drivers keep track of the relationship between the id field assigned by the (original) VCP::Source::\* driver and the final name and rev\_id (or whatever fields are important to it) in the destination repository so that the previous\_id fields, which refer to the original id, may be resolved when backfilling or branching. The VCP::\*::revml drivers do not do this; they do not need to resolve id fields. The intent for this file is to serve as a base class so that individual sites may write their own ", ref `$self`, " plugins to, for instance, store this state in a RDBMS table.  This is not quite offered at this time; we need to add an option to the appropriate VCP::Dest::\* modules to allow the appropriate ", ref `$self`, " file to be loaded. To write your own ", ref `$self`, " file, see VCP::DB\_File::sdbm.\
 **Methods**

```
   VCP::DB_File::foo->new(
      StoreLoc => $dir,  ## path to a dir to keep the state store in
   );
```

The `"Store"` field indicates where the ", ref `$self`, " should be stored, for instance a DBI specification string or a directory to place a "revmap.db" file in.  There is no control over the filename, as different storage modes may need different conventions. Gets (does not set) the StoreLoc field as an absolute path.

```
   $db->delete_db;
```

Deletes the persitent store.  This should remove all files, lock files, etc.  for filesystem stores and drop any tables for RDBMS stores.

Default action is to call close\_db; subclasses should perform the deletion.

(subclasses should call `"$self-"`SUPER::delete\_db before doing anything else in their *delete\_db()* overrides).

```
   $db->open_db;
```

Creates a new or opens an existing db.

(subclasses should call `"$self-"`SUPER::open\_db before doing anything else in their *open\_db()* overrides).

```
   $db->close_db;
```

(subclasses should call `"$self-"`SUPER::close\_db before doing anything else in their *close\_db()* overrides).

```
   $db->set( $key, @values );
```

Sets the values for `$key`.

```
   my @values = $db->get( $key );
```

Gets the values for `$key`.

```
   my @keys = $db->keys;
```

Returns a list of ARRAY references.  Each ARRAY ref is a key. These are provided to make subclassing a tad easier

```
   $self->mkdir_store_loc;
```

A helper method for subclasses' *open\_db()*s to create the directory referred to by store\_loc and any missing parent dirs.

```
   $self->rmdir_store_loc;
```

A helper method for subclasses' *delete\_db()*s to remove the directory referred to by store\_loc.

```
   my $v = $self->pack_values( @values );
```

Combines the parameters in to a single string.

```
   my @v = $self->unpack_values( $v );
```

Barrie Slaymaker \<barries@slaysys.com\> Copyright (c) 2000, 2001, 2002 Perforce Software, Inc. All rights reserved. See VCP::License (`"vcp help license"`) for the terms of use.
