MCPcopy Create free account
hub / github.com/IoLanguage/io / UArray_findLastPathComponent

Function UArray_findLastPathComponent

libs/basekit/source/UArray_path.c:45–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45long 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
67UArray *UArray_lastPathComponent(const UArray *self) {
68 long pos = UArray_findLastPathComponent(self);

Callers 4

UArray_lastPathComponentFunction · 0.85
UArray_fileNameFunction · 0.85

Calls 3

UArray_stackRangeFunction · 0.85
UArray_rFindAnyValue_Function · 0.85

Tested by

no test coverage detected