| 105 | } |
| 106 | return total; |
| 107 | } |
| 108 | |
| 109 | ssize_t KittyIOFile::pwrite(kt_off64_t offset, const void *buffer, size_t len) |
| 110 | { |
| 111 | _error = 0; |
| 112 | |
| 113 | if (_fd < 0) |
| 114 | return -1; |
| 115 | |
| 116 | const char *ptr = static_cast<const char *>(buffer); |
| 117 | size_t total = 0; |
| 118 | while (total < len) |
| 119 | { |
| 120 | size_t toWrite = std::min(len - total, KT_IO_CHUNK_SIZE); |
| 121 | ssize_t n = KT_EINTR_RETRY(kt_pwrite64(_fd, ptr + total, toWrite, (kt_off64_t)(offset + total))); |
| 122 | if (n <= 0) |
| 123 | { |
| 124 | _error = (n < 0) ? errno : 0; |
| 125 | return total > 0 ? total : (_error == 0 ? 0 : -1); |
| 126 | } |
| 127 | total += n; |
| 128 | } |
| 129 | return total; |
| 130 | } |
| 131 | |
| 132 | bool KittyIOFile::readToString(std::string *str) |
| 133 | { |
| 134 | _error = 0; |
| 135 |
no outgoing calls
no test coverage detected