#include #include #include #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; }