From: Bastian Dehn Date: Thu, 16 Jul 2015 21:46:33 +0000 (+0200) Subject: +copyfile funktion - input copy to work X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=3d8f07adeddfa5c0016a6101343c094f695a50ca;p=discspan.git +copyfile funktion - input copy to work --- diff --git a/discspan.c b/discspan.c index bcb5e81..339ada1 100644 --- a/discspan.c +++ b/discspan.c @@ -4,6 +4,21 @@ #include #include +void filecopy(const char *fsource, const char *ftarget) +{ + FILE *source; FILE *target; + char ch; + + source = fopen(fsource, "r"); + target = fopen(ftarget, "w"); + + while((ch = fgetc(source)) != EOF) + fputc(ch, target); + + fclose(source); + fclose(target); +} + int exists(const char *fname) { struct stat buffer; @@ -89,6 +104,7 @@ int main(int argc, char *argv[]) const char *input = argv[1]; const char *output = argv[2]; const char *rest = argv[3]; + const char *work = "work"; unsigned long long split; int c; extern char *optarg; @@ -126,7 +142,9 @@ int main(int argc, char *argv[]) } } - splitter(input, output, rest, split); + filecopy(input, work); + splitter(work, output, rest, split); + remove(work); return 0; }