X-Git-Url: http://git.scottworley.com/overonion/blobdiff_plain/b398ee5ae7abfa019f84628204f3c1cd146ed39e..e8aa0cd30a2f35c30e88b437cb40f1685cb5b3b9:/reverse_lib.c diff --git a/reverse_lib.c b/reverse_lib.c index a800db8..e69922b 100644 --- a/reverse_lib.c +++ b/reverse_lib.c @@ -22,7 +22,7 @@ static void write_all(int fd, const void *buf, size_t count) { } } -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"); @@ -46,12 +46,12 @@ void reverse_file(const char* input_filename) { 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) {