MCPcopy Create free account
hub / github.com/apache/arrow / SplitAbstractPath

Function SplitAbstractPath

cpp/src/arrow/filesystem/path_util.cc:37–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35// XXX How does this encode Windows UNC paths?
36
37std::vector<std::string> SplitAbstractPath(const std::string& path, char sep) {
38 std::vector<std::string> parts;
39 auto v = std::string_view(path);
40 // Strip trailing separator
41 if (v.length() > 0 && v.back() == sep) {
42 v = v.substr(0, v.length() - 1);
43 }
44 // Strip leading separator
45 if (v.length() > 0 && v.front() == sep) {
46 v = v.substr(1);
47 }
48 if (v.length() == 0) {
49 return parts;
50 }
51
52 auto append_part = [&parts, &v](size_t start, size_t end) {
53 parts.emplace_back(v.substr(start, end - start));
54 };
55
56 size_t start = 0;
57 while (true) {
58 size_t end = v.find_first_of(sep, start);
59 append_part(start, end);
60 if (end == std::string::npos) {
61 break;
62 }
63 start = end + 1;
64 }
65 return parts;
66}
67
68std::string SliceAbstractPath(const std::string& s, int offset, int length, char sep) {
69 if (offset < 0 || length < 0) {

Callers 15

ParseKeysMethod · 0.85
InspectMethod · 0.85
InspectMethod · 0.85
InspectMethod · 0.85
StartsWithAnyOfFunction · 0.85
EXPECT_OK_AND_ASSIGNFunction · 0.85
ParseFunction · 0.85
FromStringMethod · 0.85
FromStringMethod · 0.85
TESTFunction · 0.85
OpenOutputStreamMethod · 0.85
OpenInputReaderMethod · 0.85

Calls 4

backMethod · 0.80
substrMethod · 0.80
emplace_backMethod · 0.80
lengthMethod · 0.45

Tested by 3

EXPECT_OK_AND_ASSIGNFunction · 0.68
ParseFunction · 0.68
TESTFunction · 0.68