shithub: choc

Download patch

ref: 8f956718644e9f6e59c1ac3e9d527a7799e55d87
parent: 9e71dbbd21c72ef8f5a1478efa1596fe1b353307
parent: 01038bc020424a53c55e512afe12c0e7e6a31ec2
author: Fabian Greffrath <[email protected]>
date: Tue Nov 22 09:31:30 EST 2016

Merge pull request #818 from CapnClever/hexen-copyfile

hexen/sv_save.c: revert 9e71dbb, fix fwrite check

--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -3257,7 +3257,7 @@
     byte *buffer;
     int file_length, file_remaining;
     FILE *read_handle, *write_handle;
-    int buf_count, read_count;
+    int buf_count, read_count, write_count;
 
     read_handle = fopen(source_name, "rb");
     if (read_handle == NULL)
@@ -3300,9 +3300,10 @@
             I_Error ("Couldn't read file %s", source_name);
         }
 
-        if (read_count < buf_count)
+        write_count = fwrite(buffer, 1, buf_count, write_handle);
+        if (write_count < buf_count)
         {
-            I_Error ("Couldn't read file %s", dest_name);
+            I_Error ("Couldn't write to file %s", dest_name);
         }
 
         file_remaining -= buf_count;