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

Function AncestorsFromBasePath

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

Source from the content-addressed store, hash-verified

261}
262
263std::vector<std::string> AncestorsFromBasePath(std::string_view base_path,
264 std::string_view descendant) {
265 std::vector<std::string> ancestry;
266 if (auto relative = RemoveAncestor(base_path, descendant)) {
267 auto relative_segments = fs::internal::SplitAbstractPath(std::string(*relative));
268
269 // the last segment indicates descendant
270 relative_segments.pop_back();
271
272 if (relative_segments.empty()) {
273 // no missing parent
274 return {};
275 }
276
277 for (auto&& relative_segment : relative_segments) {
278 ancestry.push_back(JoinAbstractPath(
279 std::vector<std::string>{std::string(base_path), std::move(relative_segment)}));
280 base_path = ancestry.back();
281 }
282 }
283 return ancestry;
284}
285
286std::vector<std::string> MinimalCreateDirSet(std::vector<std::string> dirs) {
287 std::sort(dirs.begin(), dirs.end());

Callers 1

TESTFunction · 0.85

Calls 6

RemoveAncestorFunction · 0.85
SplitAbstractPathFunction · 0.85
JoinAbstractPathFunction · 0.85
push_backMethod · 0.80
backMethod · 0.80
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.68