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

Function MakeAbstractPathRelative

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

Source from the content-addressed store, hash-verified

209}
210
211Result<std::string> MakeAbstractPathRelative(const std::string& base,
212 const std::string& path) {
213 if (base.empty() || base.front() != kSep) {
214 return Status::Invalid("MakeAbstractPathRelative called with non-absolute base '",
215 base, "'");
216 }
217 auto b = EnsureLeadingSlash(RemoveTrailingSlash(base));
218 auto p = std::string_view(path);
219 if (p.substr(0, b.size()) != std::string_view(b)) {
220 return Status::Invalid("Path '", path, "' is not relative to '", base, "'");
221 }
222 p = p.substr(b.size());
223 if (!p.empty() && p.front() != kSep && b.back() != kSep) {
224 return Status::Invalid("Path '", path, "' is not relative to '", base, "'");
225 }
226 return std::string(RemoveLeadingSlash(p));
227}
228
229bool IsAncestorOf(std::string_view ancestor, std::string_view descendant) {
230 ancestor = RemoveTrailingSlash(ancestor);

Callers 1

TESTFunction · 0.85

Calls 8

EnsureLeadingSlashFunction · 0.85
RemoveLeadingSlashFunction · 0.85
substrMethod · 0.80
backMethod · 0.80
RemoveTrailingSlashFunction · 0.70
InvalidFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68