| 10 | #include <stddef.h> |
| 11 | |
| 12 | void UArray_appendPath_(UArray *self, const UArray *path) { |
| 13 | const UArray sep = UArray_stackAllocedWithCString_(OS_PATH_SEPARATOR); |
| 14 | |
| 15 | int selfEndsWithSep = IS_PATH_SEPERATOR(UArray_lastLong(self)); |
| 16 | int pathStartsWithSep = IS_PATH_SEPERATOR(UArray_firstLong(path)); |
| 17 | |
| 18 | if (!selfEndsWithSep && !pathStartsWithSep) { |
| 19 | if (self->size != 0) |
| 20 | UArray_append_(self, &sep); |
| 21 | UArray_append_(self, path); |
| 22 | } else if (selfEndsWithSep && pathStartsWithSep) { |
| 23 | const UArray pathPart = UArray_stackRange(path, 1, path->size - 1); |
| 24 | UArray_append_(self, &pathPart); |
| 25 | } else { |
| 26 | UArray_append_(self, path); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | void UArray_removeLastPathComponent(UArray *self) { |
| 31 | long pos = UArray_findLastPathComponent(self); |
no test coverage detected