# HG changeset patch # User Paper <37962225+mrpapersonic@users.noreply.github.com> # Date 1653072106 14400 # Node ID 7cb9fad3f5ee9130e5a7138f592c488d2c93198c # Parent d8ac17c6d6f2126dda5b5dce3d3f19fd6b992e73 Patch a bug that would make files cap at 1.4 MB seriously. wtf was i thinking? diff -r d8ac17c6d6f2 -r 7cb9fad3f5ee src/main.c --- a/src/main.c Fri May 20 06:38:21 2022 -0400 +++ b/src/main.c Fri May 20 14:41:46 2022 -0400 @@ -40,11 +40,13 @@ } int copy_file(char* source_file, char* target_file) { + char ch; FILE *source, *target; source = fopen(source_file, "rb"); - if (source == NULL) return 1; + if (source == NULL) + return 1; target = fopen(target_file, "wb"); @@ -53,13 +55,8 @@ return 1; } - size_t n, m; - unsigned char buff[8192]; - do { - n = fread(buff, 1, sizeof(buff), source); - if (n) m = fwrite(buff, 1, n, target); - else m = 0; - } while ((n > 0) && (n == m)); + while( ( ch = fgetc(source) ) != EOF ) + fputc(ch, target); fclose(target); fclose(source);