| 35 #include <cx/string.h> |
35 #include <cx/string.h> |
| 36 #include <cx/buffer.h> |
36 #include <cx/buffer.h> |
| 37 |
37 |
| 38 UiPathElm* ui_default_pathelm_func(const char* full_path, size_t len, size_t* ret_nelm, void* data) { |
38 UiPathElm* ui_default_pathelm_func(const char* full_path, size_t len, size_t* ret_nelm, void* data) { |
| 39 cxstring *pathelms; |
39 cxstring *pathelms; |
| 40 size_t nelm = cx_strsplit_a(cxDefaultAllocator, cx_strn(full_path, len), CX_STR("/"), 4096, &pathelms); |
40 size_t nelm = cx_strsplit_a(cxDefaultAllocator, cx_strn(full_path, len), cx_str("/"), 4096, &pathelms); |
| 41 |
41 |
| 42 if (nelm == 0) { |
42 if (nelm == 0) { |
| 43 *ret_nelm = 0; |
43 *ret_nelm = 0; |
| 44 return NULL; |
44 return NULL; |
| 45 } |
45 } |
| 102 |
102 |
| 103 if (all_printable && escape) { |
103 if (all_printable && escape) { |
| 104 size_t capa = str.length + 32; |
104 size_t capa = str.length + 32; |
| 105 char *space = cxMallocDefault(capa); |
105 char *space = cxMallocDefault(capa); |
| 106 if (space == NULL) return cx_mutstrn(NULL, 0); |
106 if (space == NULL) return cx_mutstrn(NULL, 0); |
| 107 cxBufferInit(&buf, space, capa, NULL, CX_BUFFER_AUTO_EXTEND); |
107 cxBufferInit(&buf, NULL, space, capa, CX_BUFFER_AUTO_EXTEND); |
| 108 cxBufferWrite(str.ptr, 1, i, &buf); |
108 cxBufferWrite(str.ptr, 1, i, &buf); |
| 109 all_printable = false; |
109 all_printable = false; |
| 110 } |
110 } |
| 111 if (escape) { |
111 if (escape) { |
| 112 cxBufferPut(&buf, '\\'); |
112 cxBufferPut(&buf, '\\'); |