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