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>DB_ENV->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 DB_ENV Handle" /> 11 <link rel="prev" href="envset_app_dispatch.html" title="DB_ENV->set_app_dispatch()" /> 12 <link rel="next" href="envset_create_dir.html" title="DB_ENV->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">DB_ENV->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 DB_ENV 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>DB_ENV->set_data_dir()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->set_data_dir(DB_ENV *dbenv, 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="DB_ENV->add_data_dir()">DB_ENV->add_data_dir()</a> 47 and <a class="xref" href="envset_create_dir.html" title="DB_ENV->set_create_dir()">DB_ENV->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">DB_ENV->set_data_dir()</code> method configures operations performed 75 using the specified <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 76 handle, not all operations performed on the underlying database environment. 77 </p> 78 <p> 79 The <code class="methodname">DB_ENV->set_data_dir()</code> method may not be called after the 80 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is called. 81 If the database environment already exists when 82 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> is called, the 83 information specified to <code class="methodname">DB_ENV->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">DB_ENV->set_data_dir()</code> <span> 88 <span> 89 method returns a non-zero error value on failure and 0 on success. 90 </span> 91 92 </span> 93 </p> 94 <div class="sect2" lang="en" xml:lang="en"> 95 <div class="titlepage"> 96 <div> 97 <div> 98 <h3 class="title"><a id="id1666937"></a>Parameters</h3> 99 </div> 100 </div> 101 </div> 102 <div class="sect3" lang="en" xml:lang="en"> 103 <div class="titlepage"> 104 <div> 105 <div> 106 <h4 class="title"><a id="id1667128"></a>dir</h4> 107 </div> 108 </div> 109 </div> 110 <p> 111 The <span class="bold"><strong>dir</strong></span> parameter is a directory to 112 be used as a location for database files. 113 </p> 114 <p> 115 When using a Unicode build on Windows (the default), this argument will be interpreted 116 as a UTF-8 string, which is equivalent to ASCII for Latin characters. 117 </p> 118 </div> 119 </div> 120 <div class="sect2" lang="en" xml:lang="en"> 121 <div class="titlepage"> 122 <div> 123 <div> 124 <h3 class="title"><a id="id1667141"></a>Errors</h3> 125 </div> 126 </div> 127 </div> 128 <p> 129 The <code class="methodname">DB_ENV->set_data_dir()</code> <span> 130 <span> 131 method may fail and return one of the following non-zero errors: 132 </span> 133 134 </span> 135 </p> 136 <div class="sect3" lang="en" xml:lang="en"> 137 <div class="titlepage"> 138 <div> 139 <div> 140 <h4 class="title"><a id="id1667022"></a>EINVAL</h4> 141 </div> 142 </div> 143 </div> 144 <p> 145 If the method was called after <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 146 was called; or if an invalid flag value or parameter was specified. 147 </p> 148 </div> 149 </div> 150 <div class="sect2" lang="en" xml:lang="en"> 151 <div class="titlepage"> 152 <div> 153 <div> 154 <h3 class="title"><a id="id1667024"></a>Class</h3> 155 </div> 156 </div> 157 </div> 158 <p> 159 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 160 </p> 161 </div> 162 <div class="sect2" lang="en" xml:lang="en"> 163 <div class="titlepage"> 164 <div> 165 <div> 166 <h3 class="title"><a id="id1667027"></a>See Also</h3> 167 </div> 168 </div> 169 </div> 170 <p> 171 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 172 </p> 173 </div> 174 </div> 175 <div class="navfooter"> 176 <hr /> 177 <table width="100%" summary="Navigation footer"> 178 <tr> 179 <td width="40%" align="left"><a accesskey="p" href="envset_app_dispatch.html">Prev</a>��</td> 180 <td width="20%" align="center"> 181 <a accesskey="u" href="env.html">Up</a> 182 </td> 183 <td width="40%" align="right">��<a accesskey="n" href="envset_create_dir.html">Next</a></td> 184 </tr> 185 <tr> 186 <td width="40%" align="left" valign="top">DB_ENV->set_app_dispatch()��</td> 187 <td width="20%" align="center"> 188 <a accesskey="h" href="index.html">Home</a> 189 </td> 190 <td width="40%" align="right" valign="top">��DB_ENV->set_create_dir()</td> 191 </tr> 192 </table> 193 </div> 194 </body> 195</html> 196