| 382 | } |
| 383 | |
| 384 | Result<std::shared_ptr<io::OutputStream>> OpenOutputStream( |
| 385 | const std::string& path, bool append, |
| 386 | const std::shared_ptr<const KeyValueMetadata>& metadata) { |
| 387 | ARROW_RETURN_NOT_OK(internal::AssertNoTrailingSlash(path)); |
| 388 | auto parts = SplitAbstractPath(path); |
| 389 | RETURN_NOT_OK(ValidateAbstractPathParts(parts)); |
| 390 | |
| 391 | Entry* parent = FindParent(parts); |
| 392 | if (parent == nullptr || !parent->is_dir()) { |
| 393 | return PathNotFound(path); |
| 394 | } |
| 395 | // Find the file in the parent dir, or create it |
| 396 | const auto& name = parts.back(); |
| 397 | Entry* child = parent->as_dir().Find(name); |
| 398 | File* file; |
| 399 | if (child == nullptr) { |
| 400 | child = new Entry(File(current_time, name)); |
| 401 | parent->as_dir().AssignEntry(name, std::unique_ptr<Entry>(child)); |
| 402 | file = &child->as_file(); |
| 403 | } else if (child->is_file()) { |
| 404 | file = &child->as_file(); |
| 405 | file->mtime = current_time; |
| 406 | } else { |
| 407 | return NotAFile(path); |
| 408 | } |
| 409 | file->metadata = metadata; |
| 410 | auto ptr = std::make_shared<MockFSOutputStream>(file, pool); |
| 411 | if (append && file->data) { |
| 412 | RETURN_NOT_OK(ptr->Write(file->data->data(), file->data->size())); |
| 413 | } |
| 414 | return ptr; |
| 415 | } |
| 416 | |
| 417 | Result<std::shared_ptr<io::BufferReader>> OpenInputReader(const std::string& path) { |
| 418 | ARROW_RETURN_NOT_OK(internal::AssertNoTrailingSlash(path)); |
nothing calls this directly
no test coverage detected