diff options
Diffstat (limited to '8.1/main.c')
-rw-r--r-- | 8.1/main.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/8.1/main.c b/8.1/main.c new file mode 100644 index 0000000..e3e5dd1 --- /dev/null +++ b/8.1/main.c @@ -0,0 +1,25 @@ +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include "filecopy.h" +#include "error.h" + +int main(int argc, char *argv[]) +{ + ssize_t fd; + + if (argc == 1) { + filecopy(STDIN_FILENO, STDOUT_FILENO); + } else { + while (--argc > 0) { + if ((fd = open(*++argv, O_RDONLY)) == -1) { + error("cp: can't open %s", *argv); + } else { + filecopy(fd, STDOUT_FILENO); + close(fd); + } + } + } + + return 0; +} |