| 55 | } |
| 56 | |
| 57 | std::string task(std::int64_t offset, std::int64_t length, |
| 58 | std::string const& bucket, std::string const& object, int fd) { |
| 59 | auto client = gcs::Client::CreateDefaultClient().value(); |
| 60 | auto is = client.ReadObject(bucket, object, |
| 61 | gcs::ReadRange(offset, offset + length)); |
| 62 | |
| 63 | std::vector<char> buffer(1024 * 1024L); |
| 64 | std::int64_t count = 0; |
| 65 | std::int64_t write_offset = offset; |
| 66 | do { |
| 67 | is.read(buffer.data(), buffer.size()); |
| 68 | if (is.bad()) break; |
| 69 | count += is.gcount(); |
| 70 | check_system_call("pwrite()", |
| 71 | ::pwrite(fd, buffer.data(), is.gcount(), write_offset)); |
| 72 | write_offset += is.gcount(); |
| 73 | } while (not is.eof()); |
| 74 | return fmt::format("Download range [{}, {}] got {}/{} bytes", offset, |
| 75 | offset + length, count, length); |
| 76 | } |
| 77 | |
| 78 | using ::gcs_fast_transfers::file_info; |
| 79 | using ::gcs_fast_transfers::format_size; |
nothing calls this directly
no test coverage detected