1
2
3
4
5
6
7
8
9gd_rename(3) GETDATA gd_rename(3)
10
11
12
14 gd_rename — change the name of a Dirfile field or alias
15
16
18 #include <getdata.h>
19
20 int gd_rename(DIRFILE *dirfile, const char *old_code, const char
21 *new_name, unsigned int flags);
22
23
25 The gd_rename() function changes the name of the field or alias speci‐
26 fied by old_code, which should not contain a representation suffix, de‐
27 fined in the dirfile specified by dirfile to new_name. If the new name
28 is the same as the old name, this function does nothing and returns no
29 error.
30
31 When renaming a metafield, the metafield should be specified in
32 old_code by its full (slashed) field code, while new_name should only
33 contain the new name (without slash).
34
35 If old_code specifies a top-level field with meta subfields, the sub‐
36 fields will be renamed, too. By default, this function also updates
37 ALIAS entries whose target contains old_code to point to the new field.
38 Similarly, specifying the GD_REN_UPDB flag will cause this function to
39 modify any field entry containing old_code. As a result, this function
40 may cause more than one metadata fragment to be modified.
41
42 The flags parameter should be zero or more of the following flags, bit‐
43 wise or'd together:
44
45 GD_REN_DANGLE
46 Don't update ALIAS entries, instead turning them into dangling
47 aliases.
48
49 GD_REN_DATA
50 if old_code specifies a RAW field, the binary file associated
51 with the field will be renamed as well. Without this flag, no
52 changes are made to the binary file. In this case, the field's
53 I/O pointer will be reset to the beginning-of-frame. If
54 field_code specifies a field of type other than RAW, this flag
55 is ignored.
56
57 GD_REN_FORCE
58 When updating field metadata (either the target of an alias, or
59 else when specified along with GD_REN_UPDB), skip updating
60 field codes which would be invalid (due to /INCLUDE affixes).
61 Without this flag, such invalid field codes causes this func‐
62 tion to fail with the error GD_E_BAD_CODE.
63
64 GD_REN_UPDB
65 Rename the field in any other field specifications which use
66 this field as an input (either as a vector input field to a de‐
67 rived field, or else as a scalar field parameter). Without
68 this flag, fields which depend on the old name of this field
69 are left unmodified.
70
71
73 On success, gd_rename() returns zero. On error, a negative-valued er‐
74 ror code is returned. Possible error codes are:
75
76 GD_E_ACCMODE
77 The specified dirfile was opened read-only.
78
79 GD_E_ALLOC
80 The library was unable to allocate memory.
81
82 GD_E_BAD_CODE
83 The field specified by old_code was not found. Or else the re‐
84 sultant metadata update tried to change a field code into some‐
85 thing prohibited by a fragment's affixes.
86
87 GD_E_BAD_DIRFILE
88 The supplied dirfile was invalid.
89
90 GD_E_BAD_FIELD_TYPE
91 An attempt was made to rename the immutable INDEX field.
92
93 GD_E_DUPLICATE
94 The new name specified is already in use by another entry.
95
96 GD_E_IO An I/O error occurred while attempting to rename the binary
97 file.
98
99 GD_E_PROTECTED
100 The metadata of the format specification fragment containing
101 the renamed entry, or another entry affected by this change,
102 was protected from change, or the binary data of the fragment
103 was protected from change and a binary file move was requested.
104
105 GD_E_UNKNOWN_ENCODING
106 The encoding scheme of the specified field could not be deter‐
107 mined or was not understood by GetData.
108
109 GD_E_UNSUPPORTED
110 The encoding scheme of the field does not support binary file
111 renaming.
112
113 The error code is also stored in the DIRFILE object and may be re‐
114 trieved after this function returns by calling gd_error(3). A descrip‐
115 tive error string for the error may be obtained by calling
116 gd_error_string(3).
117
118
120 The dirfile_rename() function appeared in GetData-0.5.0. It had no
121 flags argument. In its place was int move_data. Passing a non-zero
122 value for this parameter has the same effect as the GD_REN_DATA flag
123 does now.
124
125 In GetData-0.7.0, this function was renamed to gd_rename().
126
127 In GetData-0.8.0, the move_data parameter was replaced with the flags
128 parameter. The only flags available were GD_REN_DATA and GD_REN_UBDB.
129
130 The flags GD_REN_DANGLE and GD_REN_FORCE flags appeared in GetDa‐
131 ta-0.9.0.
132
133 In GetData-0.10.0, the error return from this function changed from -1
134 to a negative-valued error code.
135
136
138 gd_error(3), gd_error_string(3), gd_metaflush(3), gd_open(3),
139 dirfile(5), dirfile-format(5)
140
141
142
143Version 0.10.0 25 December 2016 gd_rename(3)