changeset 46:7cb9fad3f5ee

Patch a bug that would make files cap at 1.4 MB seriously. wtf was i thinking?
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Fri, 20 May 2022 14:41:46 -0400
parents d8ac17c6d6f2
children 7cb4ca7cf257
files src/main.c
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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);