| 171 | Return true if successful. */ |
| 172 | |
| 173 | static bool |
| 174 | simple_cat (char *buf, idx_t bufsize) |
| 175 | { |
| 176 | /* Loop until the end of the file. */ |
| 177 | |
| 178 | while (true) |
| 179 | { |
| 180 | /* Read a block of input. */ |
| 181 | |
| 182 | ssize_t n_read = read (input_desc, buf, bufsize); |
| 183 | if (n_read < 0) |
| 184 | { |
| 185 | error (0, errno, "%s", quotef (infile)); |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | /* End of this file? */ |
| 190 | |
| 191 | if (n_read == 0) |
| 192 | return true; |
| 193 | |
| 194 | /* Write this block out. */ |
| 195 | |
| 196 | if (full_write (STDOUT_FILENO, buf, n_read) != n_read) |
| 197 | write_error (); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /* Write any pending output to STDOUT_FILENO. |
| 202 | Pending is defined to be the *BPOUT - OUTBUF bytes starting at OUTBUF. |