]> gitweb.hhaalo.de Git - discspan.git/commitdiff
add: filecopy.c
authorBastian Dehn <hhaalo@arcor.de>
Sun, 19 Nov 2017 17:48:59 +0000 (18:48 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 19 Nov 2017 17:48:59 +0000 (18:48 +0100)
Makefile
discspan.c
filecopy.c [new file with mode: 0644]
filecopy.h [new file with mode: 0644]

index 84aae1f49c164f51928324a1b5f0e0428a26347f..1238d693a8def5960ca78119f03eb9c2c1b42f2e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,10 @@ CFLAGS=-Wall
 BINPATH=/usr/bin
 
 all: discspan
-discspan: discspan.c file_size.h
-       $(CC) $(CFLAGS) -o discspan discspan.c
+discspan: discspan.c filecopy.o
+       $(CC) $(CFLAGS) -o discspan discspan.c filecopy.o
+filecopy.o: filecopy.c filecopy.h
+       $(CC) $(CFLAGS) -c -o filecopy.o filecopy.c
 
 install:
        chmod 755 discspan
@@ -13,4 +15,4 @@ install:
 uninstall:
        rm $(BINPATH)/discspan
 clean:
-       rm discspan
+       rm -f discspan filecopy.o
index 1d63a399e01f2a2cac9d3005ff83071ea0a37ccb..67a295cf4492ecabbfed90bf90b429cebfef8f66 100644 (file)
@@ -4,24 +4,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include "file_size.h"
-
-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);
-}
+#include "filecopy.h"
 
 int exists(const char *fname)
 {
diff --git a/filecopy.c b/filecopy.c
new file mode 100644 (file)
index 0000000..2578e00
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include "filecopy.h"
+
+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);
+}
diff --git a/filecopy.h b/filecopy.h
new file mode 100644 (file)
index 0000000..04c4781
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef FILE_COPY_H_
+#define FILE_COPY_H_
+
+void filecopy(const char *fsource, const char *ftarget);
+
+#endif /* FILE_COPY_H_ */