| 179 | |
| 180 | |
| 181 | ssize_t readall(int fd, void *buf, size_t nbytes) |
| 182 | // Read all the bytes requested from the given fd. Returns the number of bytes |
| 183 | // read, or -1 on error or 0 on eof. |
| 184 | { |
| 185 | char *cbuf = static_cast<char *>(buf); |
| 186 | size_t total = 0; |
| 187 | |
| 188 | while(nbytes > 0) { |
| 189 | ssize_t bytesread = read(fd, cbuf, nbytes); |
| 190 | if(bytesread <= 0) { |
| 191 | return bytesread; |
| 192 | } |
| 193 | |
| 194 | cbuf += bytesread; |
| 195 | nbytes -= bytesread; |
| 196 | total += bytesread; |
| 197 | } |
| 198 | |
| 199 | return total; |
| 200 | } |
| 201 | |
| 202 | bool isDirectory(const std::string& file) { |
| 203 | struct stat st; |
no outgoing calls
no test coverage detected