std::size_t RecordReader::Read()

in src/pipemode_op/RecordReader/RecordReader.cpp [62:79]


std::size_t RecordReader::Read(void* dest, std::size_t nbytes) {
    if (fd_ == UNSET_FILE_DESCRIPTOR) {
        throw std::runtime_error("File does not exist: " + file_path_);
    }
    std::size_t bytes_read = 0;
    while (nbytes) {
        ssize_t read_amount = read(fd_, dest + bytes_read, std::min(nbytes, read_size_));
        if (-1 == read_amount) {
            throw std::system_error(errno, std::system_category());
        }
        if (!read_amount) {
            break;
        }
        bytes_read += read_amount;
        nbytes -= read_amount;
    }
    return bytes_read;
}