| 267 | } |
| 268 | |
| 269 | Status CopyDirectory(Env* env, const std::string& source_path, const std::string& dest_path, |
| 270 | WritableFileOptions opts) { |
| 271 | bool is_dir; |
| 272 | RETURN_NOT_OK(env->IsDirectory(source_path, &is_dir)); |
| 273 | |
| 274 | if (!is_dir) { |
| 275 | return Status::InvalidArgument("source is not a directory"); |
| 276 | } |
| 277 | |
| 278 | vector<string> children; |
| 279 | RETURN_NOT_OK(ListFilesInDir(env, source_path, &children)); |
| 280 | |
| 281 | RETURN_NOT_OK(env->CreateDir(dest_path)); |
| 282 | for (const auto& c : children) { |
| 283 | string source = JoinPathSegments(source_path, c); |
| 284 | string dest = JoinPathSegments(dest_path, c); |
| 285 | RETURN_NOT_OK(env->IsDirectory(source, &is_dir)); |
| 286 | if (is_dir) { |
| 287 | RETURN_NOT_OK(CopyDirectory(env, source, dest, opts)); |
| 288 | } else { |
| 289 | RETURN_NOT_OK(CopyFile(env, source, dest, opts)); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return Status::OK(); |
| 294 | } |
| 295 | |
| 296 | Status DeleteExcessFilesByPattern(Env* env, const string& pattern, int max_matches) { |
| 297 | // Negative numbers don't make sense for our interface. |
nothing calls this directly
no test coverage detected