| 55 | } |
| 56 | total += n; |
| 57 | } |
| 58 | return total; |
| 59 | } |
| 60 | |
| 61 | ssize_t KittyIOFile::write(const void *buffer, size_t len) |
| 62 | { |
| 63 | _error = 0; |
| 64 | |
| 65 | if (_fd < 0) |
| 66 | return -1; |
| 67 | |
| 68 | const char *ptr = static_cast<const char *>(buffer); |
| 69 | size_t total = 0; |
| 70 | |
| 71 | while (total < len) |
| 72 | { |
| 73 | size_t toWrite = std::min(len - total, KT_IO_CHUNK_SIZE); |
| 74 | ssize_t n = KT_EINTR_RETRY(::write(_fd, ptr + total, toWrite)); |
| 75 | if (n <= 0) |
| 76 | { |
| 77 | _error = (n < 0) ? errno : 0; |
| 78 | return total > 0 ? total : (_error == 0 ? 0 : -1); |
| 79 | } |
| 80 | total += n; |
| 81 | } |
no outgoing calls
no test coverage detected