Update sk1/compressor.c

This commit is contained in:
Yurii Yakovenko 2025-01-29 19:36:05 +00:00
parent 1a5daf1c34
commit b81dd59593

View File

@ -1 +1,21 @@
@
#include <stdio.h>
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);}