| 261 | } |
| 262 | |
| 263 | std::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 | |
| 286 | std::vector<std::string> MinimalCreateDirSet(std::vector<std::string> dirs) { |
| 287 | std::sort(dirs.begin(), dirs.end()); |