Library Version 18.1.25

DB_ENV->set_create_dir()
Prev | Chapter 5. The DB_ENV Handle | Next

## DB_ENV->set_create_dir()

    #include <db.h>

    int
    DB_ENV->set_create_dir(DB_ENV *dbenv, const char *dir);

Sets the path of a directory to be used as the location to create the access method database files. When the DB->open() function is used to create a file it will be created relative to this path.

If no database directories are specified, database files will be created either by absolute paths or relative to the environment home directory. See Berkeley DB File Naming for more information.

The database environment's create directory may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_create_dir", one or more whitespace characters, and the directory name.

The `DB_ENV->set_create_dir()` method configures operations performed using the specified DB_ENV handle, not all operations performed on the underlying database environment.

The `DB_ENV->set_create_dir()` method may be called at any time.

The `DB_ENV->set_create_dir()` method returns a non-zero error value on failure and 0 on success.

### Parameters

#### dir

The dir parameter is a directory to be used to create database files. This directory must be one of the directories specified via a call to DB_ENV->add_data_dir()

When using a Unicode build on Windows (the default), this argument will be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin characters.

### Errors

The `DB_ENV->set_create_dir()` method may fail and return one of the following non-zero errors:

#### EINVAL

If the method was called after DB_ENV->open() was called; or if an invalid flag value or parameter was specified.

### Class

DB_ENV

### See Also

Database Environments and Related Methods

Prev | Up | Next
DB_ENV->set_data_len() | Home | DB_ENV->set_encrypt()