MCPcopy Create free account
hub / github.com/apache/cloudberry / join_path_components

Function join_path_components

src/port/path.c:217–241  ·  view source on GitHub ↗

* join_path_components - join two path components, inserting a slash * * We omit the slash if either given component is empty. * * ret_path is the output area (must be of size MAXPGPATH) * * ret_path can be the same as head, but not the same as tail. */

Source from the content-addressed store, hash-verified

215 * ret_path can be the same as head, but not the same as tail.
216 */
217void
218join_path_components(char *ret_path,
219 const char *head, const char *tail)
220{
221 if (ret_path != head)
222 strlcpy(ret_path, head, MAXPGPATH);
223
224 /*
225 * Remove any leading "." in the tail component.
226 *
227 * Note: we used to try to remove ".." as well, but that's tricky to get
228 * right; now we just leave it to be done by canonicalize_path() later.
229 */
230 while (tail[0] == '.' && IS_DIR_SEP(tail[1]))
231 tail += 2;
232
233 if (*tail)
234 {
235 /* only separate with slash if head wasn't empty */
236 snprintf(ret_path + strlen(ret_path), MAXPGPATH - strlen(ret_path),
237 "%s%s",
238 (*(skip_drive(head)) != '\0') ? "/" : "",
239 tail);
240 }
241}
242
243
244/*

Callers 6

tokenize_inc_fileFunction · 0.85
make_relative_pathFunction · 0.85
find_my_execFunction · 0.85
resolve_symlinksFunction · 0.85
process_fileFunction · 0.85
mainFunction · 0.85

Calls 2

strlcpyFunction · 0.85
skip_driveFunction · 0.85

Tested by

no test coverage detected