1<!--$Id: env_set_data_dir.so,v 10.28 2004/09/28 15:04:20 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbEnv::set_data_dir</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbEnv::set_data_dir</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbEnv::set_data_dir(const char *dir); 26<p> 27int 28DbEnv::get_data_dirs(const char ***dirpp); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DbEnv::set_data_dir</b> 32<p>Set the path of a directory to be used as the location of the access 33method database files. Paths specified to the <a href="../api_cxx/db_open.html">Db::open</a> function 34will be searched relative to this path. Paths set using this method 35are additive, and specifying more than one will result in each specified 36directory being searched for database files. If any directories are 37specified, created database files will always be created in the first 38path specified.</p> 39<p>If no database directories are specified, database files must be named 40either by absolute paths or relative to the environment home directory. 41See <a href="../ref/env/naming.html">Berkeley DB File Naming</a> for more 42information.</p> 43<p>The database environment's data directories may also be configured using the 44environment's <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file. The syntax of the entry in that 45file is a single line with the string "set_data_dir", one or more whitespace 46characters, and the directory name. 47</p> 48<p>The DbEnv::set_data_dir method configures operations performed using the specified 49<a href="../api_cxx/env_class.html">DbEnv</a> handle, not all operations performed on the underlying 50database environment.</p> 51<p>The DbEnv::set_data_dir method may not be called after the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is 52called. 53If the database environment already exists when 54<a href="../api_cxx/env_open.html">DbEnv::open</a> is called, the information specified to DbEnv::set_data_dir 55must be consistent with the existing environment or corruption can 56occur.</p> 57<p>The DbEnv::set_data_dir method 58either returns a non-zero error value 59or throws an exception that encapsulates a non-zero error value on 60failure, and returns 0 on success. 61</p> 62<b>Parameters</b> <br> 63 <b>dir</b><ul compact><li>The <b>dir</b> parameter is a directory to be used as a location for 64database files.</ul> 65<p>When using a Unicode build on Windows (the default), the <b>dir</b> 66argument will be interpreted as a UTF-8 string, which is equivalent to 67ASCII for Latin characters.</p> 68<br> 69<br><b>Errors</b> 70<p>The DbEnv::set_data_dir method 71may fail and throw 72<a href="../api_cxx/except_class.html">DbException</a>, 73encapsulating one of the following non-zero errors, or return one of 74the following non-zero errors:</p> 75<br> 76<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_cxx/env_open.html">DbEnv::open</a> was called; or if an 77invalid flag value or parameter was specified.</ul> 78<br> 79<hr size=1 noshade> 80<b>Description: DbEnv::get_data_dirs</b> 81<p>The DbEnv::get_data_dirs method returns the NULL-terminated array of directories.</p> 82<p>The DbEnv::get_data_dirs method may be called at any time during the life of the 83application.</p> 84<p>The DbEnv::get_data_dirs method 85either returns a non-zero error value 86or throws an exception that encapsulates a non-zero error value on 87failure, and returns 0 on success. 88</p> 89<b>Parameters</b> <br> 90 <b>dirpp</b><ul compact><li>The DbEnv::get_data_dirs method returns a reference to the 91NULL-terminated array of directories in <b>dirpp</b>.</ul> 92<br> 93<hr size=1 noshade> 94<br><b>Class</b> 95<a href="../api_cxx/env_class.html">DbEnv</a> 96<br><b>See Also</b> 97<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a> 98</tt> 99<table width="100%"><tr><td><br></td><td align=right> 100<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 101</td></tr></table> 102<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 103</body> 104</html> 105