From b81dd59593433dc3d904601aeabe375268bebe61 Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Wed, 29 Jan 2025 19:36:05 +0000 Subject: [PATCH] Update sk1/compressor.c --- sk1/compressor.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sk1/compressor.c b/sk1/compressor.c index b516b2c..65137b0 100644 --- a/sk1/compressor.c +++ b/sk1/compressor.c @@ -1 +1,21 @@ -@ \ No newline at end of file +#include + +int copy_file(const char *a, const char *b) +{ + FILE *x = fopen(a, "rb"); if (!x) return -1; + FILE *y = fopen(b, "wb"); if (!y) { fclose(x); return -1; } + int c, n = 0; + while ((c = fgetc(x)) != EOF) + { + fputc(c, y); + n++; + } + fclose(x); + fclose(y); + return n; +} + +int compress_1(const char *a, const char *b){return copy_file(a,b);} +int compress_2(const char *a, const char *b){return copy_file(a,b);} +int decompress_1(const char *a, const char *b){return copy_file(a,b);} +int decompress_2(const char *a, const char *b){return copy_file(a,b);}