---
name: "gd_nframes"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_nframes"
---

# gd\_nframes(3)

report the size of a Dirfile

## NAME

gd\_nframes — report the size of a Dirfile

## SYNOPSIS

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

**off\_t gd\_nframes(DIRFILE \****dirfile***);**

## DESCRIPTION

The **gd\_nframes**() function queries a [dirfile(5)](/dirfile/5.md) database specified by *dirfile* and returns the number of frames in the database.  Since different fields may have differing number of frames, the Dirfile Standards (see [dirfile(5)](/dirfile/5.md)) dictate that the number of frames in the database is defined to be equal to the number of frames in the reference field defined by the **/REFERENCE** directive (see [dirfile-format(5)](/dirfile-format/5.md)) or, if no such reference field is defined, by the first raw field specified in the format specification.

If no vector fields are defined in the database, **gd\_nframes**() returns zero and succeeds.

The  *dirfile* argument must point to a valid DIRFILE object previously created by a call to [**gd\_open**(3)](/gd_open/3.md).

## RETURN VALUE

Upon successful completion, **gd\_nframes**() returns the number of frames in the dirfile, which is never negative.  On error, it returns a negative-valued error code.  Possible error codes are:\
  .TP 8 **GD\_E\_ALLOC** The library was unable to allocate memory.\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_IO** An I/O error occurred while determining the number of samples in the data file associated with the reference field.\
  .TP 8 **GD\_E\_UNKNOWN\_ENCODING** The number of samples available for the reference field could not be determined because the encoding used to store the reference field's data file was not understood.\
  .TP 8 **GD\_E\_UNSUPPORTED** GetData does not support determining the number of samples for the encoding of of the data file associated with the reference field.

The error code is also stored in the **DIRFILE** object and may be retrieved after this function returns by calling [**gd\_error**(3)](/gd_error/3.md). A descriptive error string for the error may be obtained by calling [**gd\_error\_string**(3)](/gd_error_string/3.md).

## HISTORY

The **get\_nframes**() function appeared in GetData-0.3.0.

In GeData-0.7.0, this function was renamed to **gd\_nframes**().

## SEE ALSO

[dirfile(5)](/dirfile/5.md), [dirfile-encoding(5)](/dirfile-encoding/5.md), [**gd\_open**(3)](/gd_open/3.md), [**gd\_bof**(3)](/gd_bof/3.md), [**gd\_eof**(3)](/gd_eof/3.md), [**gd\_error**(3)](/gd_error/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md)
