bool use_striper)
{
string oid(objname);
- bufferlist indata;
- bool stdio = false;
- if (strcmp(infile, "-") == 0)
- stdio = true;
-
- int ret;
+ bool stdio = (strcmp(infile, "-") == 0);
+ int ret = 0;
int fd = STDIN_FILENO;
if (!stdio)
fd = open(infile, O_RDONLY);
cerr << "error reading input file " << infile << ": " << cpp_strerror(errno) << std::endl;
return 1;
}
- char *buf = new char[op_size];
int count = op_size;
uint64_t offset = 0;
while (count != 0) {
- count = read(fd, buf, op_size);
+ bufferlist indata;
+ count = indata.read_fd(fd, op_size);
if (count < 0) {
ret = -errno;
cerr << "error reading input file " << infile << ": " << cpp_strerror(ret) << std::endl;
}
continue;
}
- indata.append(buffer::ptr(buffer::create_static(count, buf)));
if (use_striper) {
if (offset == 0)
ret = striper.write_full(oid, indata);
else
ret = io_ctx.write(oid, indata, count, offset);
}
- indata.clear();
if (ret < 0) {
goto out;
out:
if (fd != STDOUT_FILENO)
VOID_TEMP_FAILURE_RETRY(close(fd));
- delete[] buf;
return ret;
}