]> git.scottworley.com Git - overonion/blobdiff - reverse_test.c
Switch to stdio for output. It's simpler
[overonion] / reverse_test.c
index fe35bcc303a04330c55e7bbd890f5fde8b590efb..512edaa7477b77d9d8a193bf40ca2b66ff985302 100644 (file)
@@ -13,8 +13,10 @@ char* reverse_to_temp_file(const char* input_file) {
   char* temp_filename = strdup("/tmp/reverse_test.XXXXXX");
   int fd = mkstemp(temp_filename);
   if (fd == -1) err(EX_IOERR, "Couldn't make a temporary file");
   char* temp_filename = strdup("/tmp/reverse_test.XXXXXX");
   int fd = mkstemp(temp_filename);
   if (fd == -1) err(EX_IOERR, "Couldn't make a temporary file");
-  reverse_file(input_file, fd);
-  if (close(fd) == -1) err(EX_IOERR, "Couldn't close temporary file");
+  FILE* f = fdopen(fd, "w");
+  if (f == NULL) err(EX_IOERR, "Couldn't open temporary file");
+  reverse_file(input_file, f);
+  if (fclose(f) == EOF) err(EX_IOERR, "Couldn't close temporary file");
   return temp_filename;
 }
 
   return temp_filename;
 }