| 164 | } |
| 165 | |
| 166 | static bool is_valid_subpath(const fs::path & path, const fs::path & subpath) { |
| 167 | if (subpath.is_absolute()) { |
| 168 | return false; // never do a / b with b absolute |
| 169 | } |
| 170 | auto b = fs::absolute(path).lexically_normal(); |
| 171 | auto t = (b / subpath).lexically_normal(); |
| 172 | auto [b_end, _] = std::mismatch(b.begin(), b.end(), t.begin(), t.end()); |
| 173 | |
| 174 | return b_end == b.end(); |
| 175 | } |
| 176 | |
| 177 | static void safe_write_file(const fs::path & path, const std::string & data) { |
| 178 | fs::path path_tmp = path.string() + ".tmp"; |
no test coverage detected