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::set_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="envset_app_dispatch.html" title="DbEnv::set_app_dispatch()" /> 12 <link rel="next" href="envset_create_dir.html" title="DbEnv::set_create_dir()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::set_data_dir()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_app_dispatch.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="envset_create_dir.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="envset_data_dir"></a>DbEnv::set_data_dir()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_data_dir(const char *dir); </pre> 42 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> 43 <h3 class="title">Note</h3> 44 <p> 45 This interface has been deprecated. You should use 46 <a class="xref" href="envadd_data_dir.html" title="DbEnv::add_data_dir()">DbEnv::add_data_dir()</a> 47 and <a class="xref" href="envset_create_dir.html" title="DbEnv::set_create_dir()">DbEnv::set_create_dir()</a> 48 instead. 49 </p> 50 </div> 51 <p> 52 Set the path of a directory to be used as the location of the access 53 method database files. Paths specified to the 54 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> function will be 55 searched relative to this path. Paths set using this method are 56 additive, and specifying more than one will result in each specified 57 directory being searched for database files. If any directories are 58 specified, database files will always be created in the first 59 path specified. 60 </p> 61 <p> 62 If no database directories are specified, database files must be named 63 either by absolute paths or relative to the environment home 64 directory. See <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a> for more information. 65 </p> 66 <p> 67 The database environment's data directories may also be configured 68 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 69 syntax of the entry in that file is a single line with the string 70 "set_data_dir", one or more whitespace characters, and the directory 71 name. 72 </p> 73 <p> 74 The <code class="methodname">DbEnv::set_data_dir()</code> method configures operations performed 75 using the specified <a class="link" href="env.html" title="Chapter��5.�� The DbEnv Handle">DbEnv</a> 76 handle, not all operations performed on the underlying database environment. 77 </p> 78 <p> 79 The <code class="methodname">DbEnv::set_data_dir()</code> method may not be called after the 80 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is called. 81 If the database environment already exists when 82 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> is called, the 83 information specified to <code class="methodname">DbEnv::set_data_dir()</code> must be consistent 84 with the existing environment or corruption can occur. 85 </p> 86 <p> 87 The <code class="methodname">DbEnv::set_data_dir()</code> <span> 88 89 <span> 90 method either returns a non-zero error value or throws an 91 exception that encapsulates a non-zero error value on 92 failure, and returns 0 on success. 93 </span> 94 </span> 95 </p> 96 <div class="sect2" lang="en" xml:lang="en"> 97 <div class="titlepage"> 98 <div> 99 <div> 100 <h3 class="title"><a id="id1669516"></a>Parameters</h3> 101 </div> 102 </div> 103 </div> 104 <div class="sect3" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h4 class="title"><a id="id1669318"></a>dir</h4> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <span class="bold"><strong>dir</strong></span> parameter is a directory to 114 be used as a location for database files. 115 </p> 116 <p> 117 When using a Unicode build on Windows (the default), this argument will be interpreted 118 as a UTF-8 string, which is equivalent to ASCII for Latin characters. 119 </p> 120 </div> 121 </div> 122 <div class="sect2" lang="en" xml:lang="en"> 123 <div class="titlepage"> 124 <div> 125 <div> 126 <h3 class="title"><a id="id1669465"></a>Errors</h3> 127 </div> 128 </div> 129 </div> 130 <p> 131 The <code class="methodname">DbEnv::set_data_dir()</code> <span> 132 133 <span> 134 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter��6.��The DbException Class">DbException</a> 135 exception, encapsulating one of the following non-zero errors, or return one 136 of the following non-zero errors: 137 </span> 138 </span> 139 </p> 140 <div class="sect3" lang="en" xml:lang="en"> 141 <div class="titlepage"> 142 <div> 143 <div> 144 <h4 class="title"><a id="id1669797"></a>EINVAL</h4> 145 </div> 146 </div> 147 </div> 148 <p> 149 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 150 was called; or if an invalid flag value or parameter was specified. 151 </p> 152 </div> 153 </div> 154 <div class="sect2" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h3 class="title"><a id="id1669798"></a>Class</h3> 159 </div> 160 </div> 161 </div> 162 <p> 163 <a class="link" href="env.html" title="Chapter��5.�� The DbEnv Handle">DbEnv</a> 164 </p> 165 </div> 166 <div class="sect2" lang="en" xml:lang="en"> 167 <div class="titlepage"> 168 <div> 169 <div> 170 <h3 class="title"><a id="id1669834"></a>See Also</h3> 171 </div> 172 </div> 173 </div> 174 <p> 175 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 176 </p> 177 </div> 178 </div> 179 <div class="navfooter"> 180 <hr /> 181 <table width="100%" summary="Navigation footer"> 182 <tr> 183 <td width="40%" align="left"><a accesskey="p" href="envset_app_dispatch.html">Prev</a>��</td> 184 <td width="20%" align="center"> 185 <a accesskey="u" href="env.html">Up</a> 186 </td> 187 <td width="40%" align="right">��<a accesskey="n" href="envset_create_dir.html">Next</a></td> 188 </tr> 189 <tr> 190 <td width="40%" align="left" valign="top">DbEnv::set_app_dispatch()��</td> 191 <td width="20%" align="center"> 192 <a accesskey="h" href="index.html">Home</a> 193 </td> 194 <td width="40%" align="right" valign="top">��DbEnv::set_create_dir()</td> 195 </tr> 196 </table> 197 </div> 198 </body> 199</html> 200