diff options
Diffstat (limited to '8.1/filecopy.c')
-rw-r--r-- | 8.1/filecopy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/8.1/filecopy.c b/8.1/filecopy.c new file mode 100644 index 0000000..b35ccbd --- /dev/null +++ b/8.1/filecopy.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include "filecopy.h" +#include "error.h" + +void filecopy(int ifd, int ofd) +{ + ssize_t n; + char buff[BUFSIZ]; + + while ((n = read(ifd, buff, BUFSIZ)) > 0) + if (write(ofd, buff, n) != n) + error("cat: write error"); +} |