1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DbEnv::add_data_dir()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> 10 <link rel="up" href="env.html" title="Chapter 5. The DbEnv Handle" /> 11 <link rel="prev" href="dbgetenv.html" title="Db::get_env()" /> 12 <link rel="next" href="envclose.html" title="DbEnv::close()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::add_data_dir()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbgetenv.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 5. 23 The DbEnv Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="envclose.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envadd_data_dir"></a>DbEnv::add_data_dir()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::add_data_dir(const char *dir); </pre> 42 <p> 43 Add the path of a directory to be used as the location of the access 44 method database files. Paths specified to the 45 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> function will be 46 searched relative to this path. Paths set using this method are 47 additive, and specifying more than one will result in each specified 48 directory being searched for database files. 49 </p> 50 <p> 51 If no database directories are specified, database files must be named 52 either by absolute paths or relative to the environment home 53 directory. See <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a> for more information. 54 </p> 55 <p> 56 The database environment's data directories may also be configured 57 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 58 syntax of the entry in that file is a single line with the string 59 "add_data_dir", one or more whitespace characters, and the directory 60 name. 61 </p> 62 <p> 63 The <code class="methodname">DbEnv::add_data_dir()</code> method configures operations performed 64 using the specified <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 65 handle, not all operations performed on the underlying database environment. 66 </p> 67 <p> 68 The <code class="methodname">DbEnv::add_data_dir()</code> method may not be called after the 69 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is called. 70 If the database environment already exists when 71 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> is called, the 72 information specified to <code class="methodname">DbEnv::add_data_dir()</code> must be consistent 73 with the existing environment or corruption can occur. 74 </p> 75 <p> 76 The <code class="methodname">DbEnv::add_data_dir()</code> <span> 77 78 <span> 79 method either returns a non-zero error value or throws an 80 exception that encapsulates a non-zero error value on 81 failure, and returns 0 on success. 82 </span> 83 </span> 84 </p> 85 <div class="sect2" lang="en" xml:lang="en"> 86 <div class="titlepage"> 87 <div> 88 <div> 89 <h3 class="title"><a id="id1662153"></a>Parameters</h3> 90 </div> 91 </div> 92 </div> 93 <div class="sect3" lang="en" xml:lang="en"> 94 <div class="titlepage"> 95 <div> 96 <div> 97 <h4 class="title"><a id="id1662630"></a>dir</h4> 98 </div> 99 </div> 100 </div> 101 <p> 102 The <span class="bold"><strong>dir</strong></span> parameter is a directory to 103 be used as a location for database files. 104 </p> 105 <p> 106 When using a Unicode build on Windows (the default), this argument will be interpreted 107 as a UTF-8 string, which is equivalent to ASCII for Latin characters. 108 </p> 109 </div> 110 </div> 111 <div class="sect2" lang="en" xml:lang="en"> 112 <div class="titlepage"> 113 <div> 114 <div> 115 <h3 class="title"><a id="id1662777"></a>Errors</h3> 116 </div> 117 </div> 118 </div> 119 <p> 120 The <code class="methodname">DbEnv::add_data_dir()</code> <span> 121 122 <span> 123 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 124 exception, encapsulating one of the following non-zero errors, or return one 125 of the following non-zero errors: 126 </span> 127 </span> 128 </p> 129 <div class="sect3" lang="en" xml:lang="en"> 130 <div class="titlepage"> 131 <div> 132 <div> 133 <h4 class="title"><a id="id1662589"></a>EINVAL</h4> 134 </div> 135 </div> 136 </div> 137 <p> 138 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 139 was called; or if an invalid flag value or parameter was specified. 140 </p> 141 </div> 142 </div> 143 <div class="sect2" lang="en" xml:lang="en"> 144 <div class="titlepage"> 145 <div> 146 <div> 147 <h3 class="title"><a id="id1662154"></a>Class</h3> 148 </div> 149 </div> 150 </div> 151 <p> 152 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 153 </p> 154 </div> 155 <div class="sect2" lang="en" xml:lang="en"> 156 <div class="titlepage"> 157 <div> 158 <div> 159 <h3 class="title"><a id="id1662712"></a>See Also</h3> 160 </div> 161 </div> 162 </div> 163 <p> 164 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 165 </p> 166 </div> 167 </div> 168 <div class="navfooter"> 169 <hr /> 170 <table width="100%" summary="Navigation footer"> 171 <tr> 172 <td width="40%" align="left"><a accesskey="p" href="dbgetenv.html">Prev</a> </td> 173 <td width="20%" align="center"> 174 <a accesskey="u" href="env.html">Up</a> 175 </td> 176 <td width="40%" align="right"> <a accesskey="n" href="envclose.html">Next</a></td> 177 </tr> 178 <tr> 179 <td width="40%" align="left" valign="top">Db::get_env() </td> 180 <td width="20%" align="center"> 181 <a accesskey="h" href="index.html">Home</a> 182 </td> 183 <td width="40%" align="right" valign="top"> DbEnv::close()</td> 184 </tr> 185 </table> 186 </div> 187 </body> 188</html> 189