src/server/util/util.c

changeset 114
c3a0f1275d71
parent 113
57e706fed20a
child 118
38bf6dd8f4e7
equal deleted inserted replaced
113:57e706fed20a 114:c3a0f1275d71
473 NSAPI_PUBLIC 473 NSAPI_PUBLIC
474 sstr_t util_path_append(pool_handle_t *pool, char *path, char *ch) { 474 sstr_t util_path_append(pool_handle_t *pool, char *path, char *ch) {
475 sstr_t parent = sstr(path); 475 sstr_t parent = sstr(path);
476 sstr_t child = sstr(ch); 476 sstr_t child = sstr(ch);
477 sstr_t newstr; 477 sstr_t newstr;
478 sstr_t s; 478
479 UcxAllocator a = util_pool_allocator(pool);
479 if(parent.ptr[parent.length-1] == '/') { 480 if(parent.ptr[parent.length-1] == '/') {
480 s.length = 0; 481 newstr = sstrcat_a(&a, 2, parent, child);
481 } else { 482 } else {
482 s = S("/"); 483 newstr = sstrcat_a(&a, 3, parent, S("/"), child);
483 }
484
485 UcxAllocator a = util_pool_allocator(pool);
486 if(s.length == 1) {
487 newstr = sstrcat_a(&a, 3, parent, s, child);
488 } else {
489 newstr = sstrcat_a(&a, 2, parent, child);
490 } 484 }
491 485
492 return newstr; 486 return newstr;
493 } 487 }
494 488

mercurial