MCPcopy Index your code
hub / github.com/RsyncProject/rsync / pathjoin

Function pathjoin

util1.c:890–906  ·  view source on GitHub ↗

Join strings p1 & p2 into "dest" with a guaranteed '/' between them. (If * p1 ends with a '/', no extra '/' is inserted.) Returns the length of both * strings + 1 (if '/' was inserted), regardless of whether the null-terminated * string fits into destsize. */

Source from the content-addressed store, hash-verified

888 * strings + 1 (if '/' was inserted), regardless of whether the null-terminated
889 * string fits into destsize. */
890size_t pathjoin(char *dest, size_t destsize, const char *p1, const char *p2)
891{
892 size_t len = strlcpy(dest, p1, destsize);
893 if (len < destsize - 1) {
894 if (!len || dest[len-1] != '/')
895 dest[len++] = '/';
896 if (len < destsize - 1)
897 len += strlcpy(dest + len, p2, destsize - len);
898 else {
899 dest[len] = '\0';
900 len += strlen(p2);
901 }
902 }
903 else
904 len += strlen(p2) + 1; /* Assume we'd insert a '/'. */
905 return len;
906}
907
908/* Join any number of strings together, putting them in "dest". The return
909 * value is the length of all the strings, regardless of whether the null-

Callers 14

hard_link_checkFunction · 0.85
finish_hard_linkFunction · 0.85
log_formattedFunction · 0.85
setup_merge_fileFunction · 0.85
get_cvs_excludesFunction · 0.85
partial_dir_fnameFunction · 0.85
include_configFunction · 0.85
secure_relative_openFunction · 0.85
try_dests_regFunction · 0.85
try_dests_nonFunction · 0.85
recv_generatorFunction · 0.85
check_alt_basis_dirsFunction · 0.85

Calls 1

strlcpyFunction · 0.85

Tested by

no test coverage detected