---
name: "hxsetcreatedir"
section: "3hdf"
platform: "linux"
package: "libhdf4g-dev"
version: "4.0.2-6"
release: "Debian 2.0 (Hamm)"
platforms: ["linux"]
url: "https://new.carta.tech/hxsetcreatedir"
---

# hxsetcreatedir(3hdf)

- intn HXsetcreatedir(const char \*dir)

  *dir*\
   	IN: directory for creating the external file

- Purpose

  Set the directory variable for creating the external file of a new external element

- Return value

  Return SUCCEED if no error, else FAIL.

- Description

  HXsetcreatedir sets the directory variable for creating the external file  according to *dir*. The content of *dir* is copied into private memory of the HDF library. If *dir* is NULL, the directory variable is unset. If HXsetcreatedir encounters any error, the directory variable is not changed.

  When a new external element is created (via functions HXcreate or SDsetexternal), the HDF library, by default, accesses the external file just like the [open(2)](/open/2.md) call. (See HXcreate(3) for when a new or an old file is opened.) Users may override the default action by calling HXsetcreatedir() or by defining the environment variable $HDFEXTCREATEDIR. The HDF library will access the external file in the directory specified by the above override. The precedence is HXsetcreatedir, then $HDXEXTDIR, then just like open().

  Note that the above override does not apply to absolute pathnames, i.e., filenames starting with a slash (/). HDF will access the absolute pathname without change. Also note that HXsetcreatedir and $HDFEXTCREATEDIR are not symmetrical to HXsetdir and $HDFEXTDIR.  The former pair permits only single directory values and is used to compose the filename for access.  The later pair permits multiple directory values which are used for searching a presumably existing file.

- Examples

  Assuming the following,

  ```
  	HXsetcreatedir("/DataVault/ProjectB")
  	$HDFEXTCREATEDIR is "Mydata"
  ```

  For each external filename on the left, HDF will open the file on the right,

  | | |
  | --- | --- |
  | External Filename | HDF opens file |
  |  |
  | datadir/data001 | /DataVault/ProjectB/datadir/data001 |
  | /usr/groupA/ProjectB/data001 | /usr/groupA/ProjectB/data001 |

- FORTRAN

  integer function hxscdir(dir)\
   character\*(\*)	dir
