46 const std::string &to, int64_t offset) {
53 from_fd = client->open(from, 0);
55 client->seek(from_fd, offset);
57 to_fd = client->create(to, Filesystem::OPEN_FLAG_OVERWRITE, -1, -1, -1);
69 client->decode_response_pread(event, (
const void **)&dst, (uint64_t *)&offset, &amount);
73 send_buf.
set(dst, amount,
false);
74 client->append(to_fd, send_buf);
82 client->read(from_fd, BUFFER_SIZE, &sync_handler);
85 client->close(from_fd);
91 client->close(from_fd);
111 if ((fp = fopen(from.c_str(),
"r")) == 0)
115 if (fseek(fp, (
long)offset, SEEK_SET) != 0)
119 fd = client->create(to, Filesystem::OPEN_FLAG_OVERWRITE, -1, -1, -1);
122 for (
int i=0; i<3; i++) {
126 send_buf.
set(buf, nread,
true);
127 client->append(fd, send_buf);
134 send_buf.
set(buf, nread,
true);
135 client->append(fd, send_buf);
157 if ((fp = fopen(to.c_str(),
"w+")) == 0)
160 int32_t fd = client->open(from, 0);
163 client->seek(fd, offset);
175 client->decode_response_pread(event, (
const void **)&dst, (uint64_t *)&offset, &amount);
178 if (fwrite(dst, amount, 1, fp) != 1)
187 client->read(fd, BUFFER_SIZE, &sync_handler);
A memory buffer of static size.
void set(uint8_t *data, uint32_t len, bool take_ownership=true)
Sets data pointer; the existing buffer is discarded and deleted.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
void copy(ClientPtr &client, const std::string &from, const std::string &to, int64_t offset=0)
void copy_to_local(ClientPtr &client, const std::string &from, const std::string &to, int64_t offset=0)
bool wait_for_reply(EventPtr &event)
This method is used by a client to synchronize.
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Logging routines and macros.
Compatibility Macros for C/C++.
DispatchHandler class used to synchronize with response messages.
void copy_from_local(ClientPtr &client, const std::string &from, const std::string &to, int64_t offset=0)
This is a generic exception class for Hypertable.
Declarations of utility functions.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Declarations for DispatchHandlerSynchronizer.