Patrick Venture | c18e2b6 | 2018-11-21 14:19:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "fs.hpp" |
| 18 | |
Patrick Venture | 48eb402 | 2019-03-08 13:08:42 -0800 | [diff] [blame] | 19 | #include <filesystem> |
Patrick Venture | c18e2b6 | 2018-11-21 14:19:28 -0800 | [diff] [blame] | 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
| 23 | namespace blobs |
| 24 | { |
Patrick Venture | 48eb402 | 2019-03-08 13:08:42 -0800 | [diff] [blame] | 25 | namespace fs = std::filesystem; |
Patrick Venture | c18e2b6 | 2018-11-21 14:19:28 -0800 | [diff] [blame] | 26 | |
| 27 | std::vector<std::string> getLibraryList(const std::string& path, |
| 28 | PathMatcher check) |
| 29 | { |
| 30 | std::vector<std::string> output; |
| 31 | |
| 32 | for (const auto& p : fs::recursive_directory_iterator(path)) |
| 33 | { |
| 34 | auto ps = p.path().string(); |
| 35 | |
| 36 | if (check(ps)) |
| 37 | { |
| 38 | output.push_back(ps); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /* Algorithm ends up being two-pass, but expectation is a list under 10. */ |
| 43 | return output; |
| 44 | } |
| 45 | |
| 46 | } // namespace blobs |