X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Fcat_src%2Fmain.c;h=3fae4c6c1f149fd716b1b0aa804ae70db11b0b34;hb=6a99a6d70179161964d47de9a825fd61e8445b86;hp=443a5deeafacf09dc149bc0e146b035c930bd9a0;hpb=d0b4559f2936f6d9f06be0f7c3c51527a480ec0d;p=tpg%2Facess2.git diff --git a/Usermode/Applications/cat_src/main.c b/Usermode/Applications/cat_src/main.c index 443a5dee..3fae4c6c 100644 --- a/Usermode/Applications/cat_src/main.c +++ b/Usermode/Applications/cat_src/main.c @@ -1,7 +1,6 @@ /* * Acess2 CAT command */ -#include #include #include @@ -13,7 +12,6 @@ */ int main(int argc, char *argv[]) { - int fd; int num; char buf[BUF_SIZE]; @@ -22,19 +20,19 @@ int main(int argc, char *argv[]) return -1; } - fd = open(argv[1], OPENFLAG_READ); - if(fd == -1) { + FILE *fp = fopen(argv[1], "r"); + if(!fp) { printf("Unable to open '%s' for reading\n", argv[1]); return -1; } do { - num = read(fd, buf, BUF_SIZE); + num = fread(buf, BUF_SIZE, 1, fp); if(num < 0) break; - write(1, buf, num); + fwrite(buf, num, 1, stdout); } while(num == BUF_SIZE); - close(fd); + fclose(fp); printf("\n"); return 0;