---
name: "xdf_open"
section: "3"
platform: "linux"
package: "libxdffileio-dev"
version: "0.3-4+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/xdf_open"
---

# xdf\_open(3)

Open a xDF file for reading or writing

## NAME

xdf\_open - Open a xDF file for reading or writing

## SYNOPSIS

**#include \<xdfio.h\>**

**struct xdf\* xdf\_open(const char\*** *filename***, int** *mode***,**\
                      **enum xdffiletype** *type***);**\

## DESCRIPTION

**xdf\_open**() opens a xDF the file refered by the path *filename* for reading or writing.

If *mode* is **XDF\_READ**, the file is opened for reading. Thus it must exist and *type* should be either **XDF\_ANY** or set to the type of the file refered by *type*. Otherwise, the function will fail.

If *mode* is **XDF\_WRITE**, the file is opened for writing. Thus the path *filename* must not refered to an existing file: the function will fail if the file exist. This behavior prevents to overwrite any previous recording. *type* should be also be set to the desired type of data format (**XDF\_ANY** will result in a error).

The possible file type values are defined in the header file *\<xdfio.h\>*

## RETURN VALUE

The function returns an handle to xDF file opened in case of success. Otherwise, NULL is returned and *errno* is set appropriately.

## ERRORS

In addition to the errors related to calls to **open**(3) or [**read**(3)](/read/3.md), the following errors can occur:

- **EILSEQ**

  The file that is being opened does not correspond to a supported file format or is not of the type specified.

- **ENOMEM**

  The system is unable to allocate resources.

- **EINVAL**

  *mode* is neither **XDF\_READ** nor **XDF\_WRITE**, or *filename* is NULL.

## SEE ALSO

[**xdf\_close**(3)](/xdf_close/3.md)
