| 43 | } |
| 44 | |
| 45 | long UArray_findLastPathComponent(const UArray *self) { |
| 46 | if (self->size) { |
| 47 | UArray seps = UArray_stackAllocedWithCString_(IO_PATH_SEPARATORS); |
| 48 | UArray s = UArray_stackRange(self, 0, self->size); |
| 49 | long pos = 0; |
| 50 | |
| 51 | while (s.size && |
| 52 | (pos = UArray_rFindAnyValue_(&s, &seps)) == s.size - 1) { |
| 53 | s.size = pos; |
| 54 | } |
| 55 | |
| 56 | if (pos == -1) { |
| 57 | pos = 0; |
| 58 | } else { |
| 59 | pos++; |
| 60 | } |
| 61 | return pos; |
| 62 | } |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | UArray *UArray_lastPathComponent(const UArray *self) { |
| 68 | long pos = UArray_findLastPathComponent(self); |
no test coverage detected