gd_rename—change the name of a Dirfile field or alias
int gd_rename(DIRFILE *dirfile, const char *old_code, const char *new_name, unsigned int flags);
The gd_rename() function changes the name of the field or alias specified by old_code, which should not contain a representation suffix, defined in the dirfile specified by dirfile to new_name. If the new name is the same as the old name, this function does nothing and returns no error.
When renaming a metafield, the metafield should be specified in old_code by its full (slashed) field code, while new_name should only contain the new name (without slash).
If old_code specifies a top-level field with meta subfields, the subfields will be renamed, too. By default, this function also updates ALIAS entries whose target contains old_code to point to the new field. Similarly, specifying the GD_REN_UPDB flag will cause this function to modify any field entry containing old_code. As a result, this function may cause more than one metadata fragment to be modified.
The flags parameter should be zero or more of the following flags, bitwise or'd together:
On success, gd_rename() returns zero. On error, a negative-valued error code is returned. Possible error codes are:
The error code is also stored in the DIRFILE object and may be retrieved after this function returns by calling gd_error(3). A descriptive error string for the error may be obtained by calling gd_error_string(3).
The dirfile_rename() function appeared in GetData-0.5.0. It had no flags argument. In its place was int move_data. Passing a non-zero value for this parameter has the same effect as the GD_REN_DATA flag does now.
In GetData-0.7.0, this function was renamed to gd_rename().
In GetData-0.8.0, the move_data parameter was replaced with the flags parameter. The only flags available were GD_REN_DATA and GD_REN_UBDB.
The flags GD_REN_DANGLE and GD_REN_FORCE flags appeared in GetData-0.9.0.
In GetData-0.10.0, the error return from this function changed from −1 to a negative-valued error code.
gd_error(3), gd_error_string(3), gd_metaflush(3), gd_open(3), dirfile(5), dirfile-format(5)