OrionUserland
Barry Removing binaries f8ba6df (3 years, 1 month ago)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#include <dirent.h>
#define BUF_SIZE (4096 * 4)
/* Main function */
int
main(int argc, char *argv[])
{
int fd, sz, i;
char buf[BUF_SIZE];
if (argc < 2) {
printf("Usage: %s <file> [<file>...]\n");
return 0;
}
for (i = 1; i < argc; i++) {
fd = open(argv[i], O_RDONLY);
if (fd < 0) {
printf("%s: %s: ", argv[0], argv[i]);
perror(NULL);
continue;
}
while ((sz = read(fd, buf, sizeof(buf))) > 0) {
if (write(STDOUT_FILENO, buf, sz) < 0) {
printf("%s: write: ", argv[0]);
perror(NULL);
}
}
if (sz < 0) {
printf("%s: read: ", argv[0]);
perror(NULL);
}
close(fd);
}
return 0;
}