}
}
-void reverse_file(const char* input_filename) {
+void reverse_file(const char* input_filename, int output_fd) {
int fd = open(input_filename, O_RDONLY);
if (fd == -1) {
err(EX_NOINPUT, "Could not open specified file");
for (off_t p = stats.st_size - 1; p >= 0; p--) {
buf[buf_offset++] = m[p];
if (buf_offset >= BUFFER_SIZE) {
- write_all(1, buf, buf_offset);
+ write_all(output_fd, buf, buf_offset);
buf_offset = 0;
}
}
if (buf_offset) {
- write_all(1, buf, buf_offset);
+ write_all(output_fd, buf, buf_offset);
}
if (munmap(m, map_size) == -1) {