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

# gd\_fragment\_namespace(3)

report or change the root namespace of a fragment of a dirfile database

## NAME

gd\_fragment\_namespace — report or change the root namespace of a fragment of a dirfile database

## SYNOPSIS

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

**const char \*gd\_fragment\_namespace(DIRFILE \****dirfile***, int** *fragment\_index***, char \****new\_namespace***);**

## DESCRIPTION

The **gd\_fragment\_namespace**() function can be used to update and/or query the root namespace of a fragment in the [dirfile(5)](/dirfile/5.md) database specified by *dirfile*.

If *new\_namespace* is NULL, then the current root namespace of the fragment indexed by *fragment\_index* is returned.  If *new\_namespace* is non-NULL, then the root namespace is first changed to the string provided before being reported.  The new namespace may optionally contain a single, trailing dot (**.**). To remove an existing root namespace, pass a pointer to the empty string (**""**) as *new\_namespace*.

The root namespace of the root format file (the one indexed by *fragment\_index*=0) may not be changed.  It is always the empty string.

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\_fragment\_namespace**() returns a non-NULL pointer to a read-only string containing the current root namespace of the fragment specified.  This will be a copy of the string *new\_namespace*, if that parameter was non-NULL.  If the fragment's root namespace is empty, a pointer to the empty string (**""**) will be returned.

On error, this function returns NULL and sets the dirfile error to a non-zero error value.  Possible dirfile error values are:\
  .TP 8 **GD\_E\_ACCMODE** The dirfile was opened read-only.\
  .TP 8 **GD\_E\_ALLOC** A memory allocation error occurred.\
  .TP 8 **GD\_E\_BAD\_CODE** The supplied *new\_fragment* was not a valid namespace.\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_BAD\_INDEX** The supplied index was out of range.  This error will also be returned if an attempt is made to change the root namespace of the root format file (*fragment\_index* zero).\
  .TP 8 **GD\_E\_DUPLICATE** Attempting to change the root namespace resulted in a duplicated field definition.\
  .TP 8 **GD\_E\_PROTECTED** The protection level of the specified fragment prohibits metadata changes.

The dirfile error may be retrieved by calling [**gd\_error**(3)](/gd_error/3.md). A descriptive error string for the last error encountered can be obtained from a call to [**gd\_error\_string**(3)](/gd_error_string/3.md).

## HISTORY

The **gd\_fragment\_namespace**() function appeared in GetData-0.10.0.

## SEE ALSO

[**gd\_alter\_affixes**(3)](/gd_alter_affixes/3.md), [**gd\_include\_ns**(3)](/gd_include_ns/3.md), [**gd\_open**(3)](/gd_open/3.md), [dirfile(5)](/dirfile/5.md), [dirfile-format(5)](/dirfile-format/5.md)
