* 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. */
| 215 | * ret_path can be the same as head, but not the same as tail. |
| 216 | */ |
| 217 | void |
| 218 | join_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 | /* |
no test coverage detected